rerolls
This commit is contained in:
parent
aef7e2c955
commit
eb526de0fa
3 changed files with 58 additions and 3 deletions
|
@ -27,6 +27,10 @@ public class Game extends ApplicationAdapter {
|
|||
private final static int TICKS_PER_SECOND = 60;
|
||||
private double tickProgress = 0;
|
||||
|
||||
|
||||
private RoundData roundData;
|
||||
private UI ui;
|
||||
|
||||
@Override
|
||||
public void create() {
|
||||
batch = new SpriteBatch();
|
||||
|
@ -34,9 +38,13 @@ public class Game extends ApplicationAdapter {
|
|||
font.getData().markupEnabled = true;
|
||||
img = new Texture("badlogic.jpg");
|
||||
|
||||
ui = new UI(50, 280, 10);
|
||||
roundData = new RoundData(10);
|
||||
|
||||
Face.setBlankFaceSprite(new Texture("blank_die_face.png"));
|
||||
Face.setPipSprite(new Texture("pip.png"));
|
||||
Die.setLockedSprite(new Texture("locked_die_border.png"));
|
||||
UI.setRerollTexture(new Texture("reroll_symbol.png"));
|
||||
|
||||
Vector2 dieSize = new Vector2();
|
||||
float divide = Gdx.graphics.getWidth() / 6f;
|
||||
|
@ -53,13 +61,16 @@ public class Game extends ApplicationAdapter {
|
|||
|
||||
public void tick() {
|
||||
processInput();
|
||||
|
||||
ui.setRemainingRerolls(roundData.getRerolls());
|
||||
}
|
||||
|
||||
public void processInput() {
|
||||
Input input = Gdx.input;
|
||||
|
||||
if (input.isKeyJustPressed(Input.Keys.R)) { //reroll dice that aren't locked
|
||||
if (input.isKeyJustPressed(Input.Keys.R) && roundData.getRerolls() > 0) { //reroll dice that aren't locked
|
||||
dice.stream().filter(d -> !d.isSelected()).forEach(Die::roll);
|
||||
roundData.reduceRerolls(1);
|
||||
|
||||
System.out.println("=".repeat(100));
|
||||
for (Segment segment : segments) {
|
||||
|
@ -103,6 +114,8 @@ public class Game extends ApplicationAdapter {
|
|||
}
|
||||
//-----
|
||||
|
||||
ui.render(batch);
|
||||
|
||||
batch.end();
|
||||
}
|
||||
|
||||
|
|
21
core/src/com/monjaro/gamejam/RoundData.java
Normal file
21
core/src/com/monjaro/gamejam/RoundData.java
Normal file
|
@ -0,0 +1,21 @@
|
|||
package com.monjaro.gamejam;
|
||||
|
||||
public class RoundData {
|
||||
private int rerolls;
|
||||
|
||||
public RoundData(int rerolls){
|
||||
this.rerolls = rerolls;
|
||||
}
|
||||
|
||||
public int getRerolls() {
|
||||
return rerolls;
|
||||
}
|
||||
|
||||
public void setRerolls(int rerolls) {
|
||||
this.rerolls = rerolls;
|
||||
}
|
||||
|
||||
public void reduceRerolls(int i) {
|
||||
rerolls -= i;
|
||||
}
|
||||
}
|
|
@ -1,16 +1,32 @@
|
|||
package com.monjaro.gamejam;
|
||||
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||
|
||||
public class UI extends Actor{
|
||||
private Transform position;
|
||||
private Texture
|
||||
private static Texture rerollTexture;
|
||||
|
||||
private int rerolls;
|
||||
private int remainingRerolls;
|
||||
|
||||
public UI(int x, int y, int rerolls)
|
||||
{
|
||||
position = new Transform(x, y, 0, 0);
|
||||
this.rerolls = rerolls;
|
||||
this.remainingRerolls = rerolls;
|
||||
}
|
||||
|
||||
public void setPosition(int x, int y){
|
||||
position.x = x;
|
||||
position.y = y;
|
||||
}
|
||||
|
||||
public void setRemainingRerolls(int x){remainingRerolls = x;}
|
||||
|
||||
public static void setRerollTexture(Texture texture){rerollTexture = texture;}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
|
||||
|
@ -18,6 +34,11 @@ public class UI extends Actor{
|
|||
|
||||
@Override
|
||||
public void render(SpriteBatch batch) {
|
||||
|
||||
for (int i = 0; i < rerolls; i++) {
|
||||
if (i > remainingRerolls-1)
|
||||
batch.setColor(Color.GRAY);
|
||||
batch.draw(rerollTexture, (position.x + (40f*i)), (position.y));
|
||||
batch.setColor(Color.WHITE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue