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 final static int TICKS_PER_SECOND = 60;
|
||||||
private double tickProgress = 0;
|
private double tickProgress = 0;
|
||||||
|
|
||||||
|
|
||||||
|
private RoundData roundData;
|
||||||
|
private UI ui;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void create() {
|
public void create() {
|
||||||
batch = new SpriteBatch();
|
batch = new SpriteBatch();
|
||||||
|
@ -34,9 +38,13 @@ public class Game extends ApplicationAdapter {
|
||||||
font.getData().markupEnabled = true;
|
font.getData().markupEnabled = true;
|
||||||
img = new Texture("badlogic.jpg");
|
img = new Texture("badlogic.jpg");
|
||||||
|
|
||||||
|
ui = new UI(50, 280, 10);
|
||||||
|
roundData = new RoundData(10);
|
||||||
|
|
||||||
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"));
|
||||||
Die.setLockedSprite(new Texture("locked_die_border.png"));
|
Die.setLockedSprite(new Texture("locked_die_border.png"));
|
||||||
|
UI.setRerollTexture(new Texture("reroll_symbol.png"));
|
||||||
|
|
||||||
Vector2 dieSize = new Vector2();
|
Vector2 dieSize = new Vector2();
|
||||||
float divide = Gdx.graphics.getWidth() / 6f;
|
float divide = Gdx.graphics.getWidth() / 6f;
|
||||||
|
@ -53,13 +61,16 @@ public class Game extends ApplicationAdapter {
|
||||||
|
|
||||||
public void tick() {
|
public void tick() {
|
||||||
processInput();
|
processInput();
|
||||||
|
|
||||||
|
ui.setRemainingRerolls(roundData.getRerolls());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void processInput() {
|
public void processInput() {
|
||||||
Input input = Gdx.input;
|
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);
|
dice.stream().filter(d -> !d.isSelected()).forEach(Die::roll);
|
||||||
|
roundData.reduceRerolls(1);
|
||||||
|
|
||||||
System.out.println("=".repeat(100));
|
System.out.println("=".repeat(100));
|
||||||
for (Segment segment : segments) {
|
for (Segment segment : segments) {
|
||||||
|
@ -103,6 +114,8 @@ public class Game extends ApplicationAdapter {
|
||||||
}
|
}
|
||||||
//-----
|
//-----
|
||||||
|
|
||||||
|
ui.render(batch);
|
||||||
|
|
||||||
batch.end();
|
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;
|
package com.monjaro.gamejam;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.graphics.Color;
|
||||||
|
import com.badlogic.gdx.graphics.Texture;
|
||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||||
|
|
||||||
public class UI extends Actor{
|
public class UI extends Actor{
|
||||||
private Transform position;
|
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){
|
public void setPosition(int x, int y){
|
||||||
position.x = x;
|
position.x = x;
|
||||||
position.y = y;
|
position.y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setRemainingRerolls(int x){remainingRerolls = x;}
|
||||||
|
|
||||||
|
public static void setRerollTexture(Texture texture){rerollTexture = texture;}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void tick() {
|
public void tick() {
|
||||||
|
|
||||||
|
@ -18,6 +34,11 @@ public class UI extends Actor{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(SpriteBatch batch) {
|
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