diff --git a/core/src/com/monjaro/gamejam/Actor.java b/core/src/com/monjaro/gamejam/Actor.java index f27cb5e..de35aa4 100644 --- a/core/src/com/monjaro/gamejam/Actor.java +++ b/core/src/com/monjaro/gamejam/Actor.java @@ -4,6 +4,7 @@ package com.monjaro.gamejam; import com.badlogic.gdx.graphics.g2d.SpriteBatch; public abstract class Actor { + public abstract void tick(); public abstract void render(SpriteBatch batch); diff --git a/core/src/com/monjaro/gamejam/Die.java b/core/src/com/monjaro/gamejam/Die.java index dc41a51..b748866 100644 --- a/core/src/com/monjaro/gamejam/Die.java +++ b/core/src/com/monjaro/gamejam/Die.java @@ -1,19 +1,25 @@ package com.monjaro.gamejam; - -import com.badlogic.gdx.math.Rectangle; import com.badlogic.gdx.graphics.g2d.SpriteBatch; +import com.badlogic.gdx.math.Rectangle; + +import java.util.List; +import java.util.Random; public class Die extends Actor { - private Rectangle shape; + private final Rectangle shape; /* 0 1 2 3 4 5 */ - private Face[] faces = new Face[6]; - private int topFace = 0; + + private final Face[] faces = new Face[6]; + private int faceIndex = 3; + + private final Random random = new Random(); //TODO use central random + public Die() { int[] pips = {4, 6, 5, 1, 2, 3}; @@ -39,6 +45,19 @@ public class Die extends Actor { @Override public void render(SpriteBatch batch) { - faces[topFace].render(batch); + faces[faceIndex].render(batch); } + + public void roll() { + faceIndex = random.nextInt(6); + } + + public void decay() { //remove a pip from all faces of this die + for (Face face : faces) { + List pips = face.getPips(); + Face.Pip decayed = pips.get(random.nextInt()); + face.removePip(decayed); + } + } + } diff --git a/core/src/com/monjaro/gamejam/Game.java b/core/src/com/monjaro/gamejam/Game.java index d959cd0..c3781b6 100644 --- a/core/src/com/monjaro/gamejam/Game.java +++ b/core/src/com/monjaro/gamejam/Game.java @@ -21,7 +21,7 @@ public class Game extends ApplicationAdapter { private final static int TICKS_PER_SECOND = 60; private double tickProgress = 0; - + @Override public void create() {