Skip to content
Snippets Groups Projects
Commit 9fb828d5 authored by Sander Skogh Linnerud's avatar Sander Skogh Linnerud
Browse files

Merge remote-tracking branch 'origin/main' into refactor

parents 2eb7efe8 809b4d9c
No related branches found
No related tags found
1 merge request!73refactor
Pipeline #275663 passed
...@@ -23,7 +23,8 @@ public class HowToPlayView extends ViewState { ...@@ -23,7 +23,8 @@ public class HowToPlayView extends ViewState {
"This is the piece Phenoix, as you can see it can only move like a box around it.", "This is the piece Phenoix, as you can see it can only move like a box around it.",
"This is the piece Snake, this pice work like a bishop, but it jumps diagonaly instead", "This is the piece Snake, this pice work like a bishop, but it jumps diagonaly instead",
"And last new piece is the Thief, this piece can move like a rook, but it jumps like the snake", "And last new piece is the Thief, this piece can move like a rook, but it jumps like the snake",
"After choosing loadout and mapsize, you can click \"Start Game\" to start the game. Good luck!" "After choosing loadout and mapsize, you can click \"Start Game\" to start the game.",
"To win the game, you need to capture your opponent's king. Good luck!"
}; };
private final String[] imgUrls = { "images/howtoplay-1.png", "images/howtoplay-2.png", "images/howtoplay-3.png", private final String[] imgUrls = { "images/howtoplay-1.png", "images/howtoplay-2.png", "images/howtoplay-3.png",
...@@ -45,9 +46,15 @@ public class HowToPlayView extends ViewState { ...@@ -45,9 +46,15 @@ public class HowToPlayView extends ViewState {
} }
private void addImg(Table table) { private void addImg(Table table) {
try {
Texture logoTexture = new Texture(Gdx.files.internal(getImgUrl())); Texture logoTexture = new Texture(Gdx.files.internal(getImgUrl()));
Image logo = new Image(logoTexture); Image logo = new Image(logoTexture);
table.add(logo).center(); table.add(logo).center();
}
// Catch exception if image index is out of bounds or image is not found
// Simply do not add the image in this case
catch (Exception e) {
}
table.row(); table.row();
} }
...@@ -64,7 +71,11 @@ public class HowToPlayView extends ViewState { ...@@ -64,7 +71,11 @@ public class HowToPlayView extends ViewState {
} }
private String getImgUrl() { private String getImgUrl() {
return imgUrls[HowToPlayController.getCurrentPage() - 1]; int index = HowToPlayController.getCurrentPage() - 1;
if (index < 0 || index >= imgUrls.length) {
throw new RuntimeException("Invalid index");
}
return imgUrls[index];
} }
private String getDescription() { private String getDescription() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment