auto round movement

This commit is contained in:
James 2024-04-21 14:34:37 +01:00
parent 2b50774435
commit 88e6ffff08
2 changed files with 12 additions and 9 deletions

View file

@ -28,6 +28,7 @@ public class Game extends ApplicationAdapter {
private double tickProgress = 0; private double tickProgress = 0;
private Round round; private Round round;
private int roundNumber = 0;
private UI ui; private UI ui;
private SegmentUI segUi; private SegmentUI segUi;
@ -43,7 +44,8 @@ public class Game extends ApplicationAdapter {
ui = new UI(this, 50, 280); ui = new UI(this, 50, 280);
round = generateRound(0); reroll();
nextRound();
Face.setBlankFaceSprite(new Texture("blank_die_face.png")); Face.setBlankFaceSprite(new Texture("blank_die_face.png"));
Face.setPipSprite(new Texture("pip.png")); Face.setPipSprite(new Texture("pip.png"));
@ -60,8 +62,6 @@ public class Game extends ApplicationAdapter {
public void tick() { public void tick() {
processInput(); processInput();
ui.setRerolls(round.getRerolls());
} }
public void processInput() { public void processInput() {
@ -86,6 +86,10 @@ public class Game extends ApplicationAdapter {
dice.forEach(d -> d.setSelected(false)); //unselect all dice dice.forEach(d -> d.setSelected(false)); //unselect all dice
reroll(); //reroll reroll(); //reroll
if (round.getSegments().stream().allMatch(Segment::isDestroyed)) { //if all segments are destroyed, next round
nextRound();
}
} }
} }
} }
@ -148,6 +152,10 @@ public class Game extends ApplicationAdapter {
img.dispose(); img.dispose();
} }
public void nextRound() {
round = generateRound(++roundNumber);
}
public Round generateRound(int difficulty) { public Round generateRound(int difficulty) {
Random random = new Random(); Random random = new Random();
int points = 5 + difficulty * 3; int points = 5 + difficulty * 3;

View file

@ -10,8 +10,6 @@ public class UI extends Actor{
private final Transform position; private final Transform position;
private static Texture rerollTexture; private static Texture rerollTexture;
private int rerolls;
public UI(Game game, int x, int y) { public UI(Game game, int x, int y) {
this.game = game; this.game = game;
position = new Transform(x, y, 0, 0); position = new Transform(x, y, 0, 0);
@ -22,10 +20,6 @@ public class UI extends Actor{
position.y = y; position.y = y;
} }
public void setRerolls(int x){
rerolls = x;
}
public static void setRerollTexture(Texture texture){rerollTexture = texture;} public static void setRerollTexture(Texture texture){rerollTexture = texture;}
@Override @Override
@ -42,4 +36,5 @@ public class UI extends Actor{
batch.setColor(Color.WHITE); batch.setColor(Color.WHITE);
} }
} }
} }