Animal details - UQcsse3200/2024-studio-1 GitHub Wiki
Introduction
The Animal details page within How To Play menu provides user with all types of animals they will face within the game.
Overview
The menu can be found after clicking on "About Animals" in main How To Play menu.
Technical Information
AnimalDisplay.java
Java class contains all necessary components for the Animals menu.
Texts of description and picture directories are stored in the paragraphs array.
String[] animalDescriptions = {
"Rat - 100 Health, 10 Base Attack, 1 Attack Range, 2 Attack Rate",
"Dog - 300 Health, 20 Base Attack, 1.5 Attack Range, 1 Attack Rate",
"Minotaur - 400 Health, 35 Base Attack, 2 Attack Range, 0.5 Attack Rate",
"Dino - 300 Health, 10 Base Attack, 1.2 Attack Range, 1 Attack Rate",
"Bat - 50 Health, 10 Base Attack, 1 Attack Range, 1.2 Attack Rate",
"Snake - 300 Health, 10 Base Attack, 1 Attack Range, 0.8 Attack Rate",
"Bear - 600 Health, 35 Base Attack, 1.5 Attack Range, 0.5 Attack Rate"
};
String[] animalImagePaths = {
"images/how-to-play/animals/rat.png",
"images/how-to-play/animals/dog.png",
"images/how-to-play/animals/minotaur.png",
"images/how-to-play/animals/dino.png",
"images/how-to-play/animals/bat.png",
"images/how-to-play/animals/snake.png",
"images/how-to-play/animals/bear.png"
};
Components like texts and buttons of the menu are displayed in tables, which makes everything aligned and have the same structure with every other screens. A for loop is used to add every descriptions and pictures into the table:
Table table = new Table();
for (int i = 0; i < animalDescriptions.length; i++) {
Image animalImage = new Image(new Texture(Gdx.files.internal(animalImagePaths[i])));
Label animalLabel = new Label(animalDescriptions[i], skin);
table.add(animalImage).size(75, 70).pad(10);
table.add(animalLabel).pad(10).left().row();
}
return table;