merging
This commit is contained in:
commit
808b1a8d65
3 changed files with 27 additions and 7 deletions
|
@ -4,6 +4,7 @@ package com.monjaro.gamejam;
|
||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||||
|
|
||||||
public abstract class Actor {
|
public abstract class Actor {
|
||||||
|
|
||||||
public abstract void tick();
|
public abstract void tick();
|
||||||
|
|
||||||
public abstract void render(SpriteBatch batch);
|
public abstract void render(SpriteBatch batch);
|
||||||
|
|
|
@ -1,19 +1,25 @@
|
||||||
package com.monjaro.gamejam;
|
package com.monjaro.gamejam;
|
||||||
|
|
||||||
|
|
||||||
import com.badlogic.gdx.math.Rectangle;
|
|
||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
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 {
|
public class Die extends Actor {
|
||||||
|
|
||||||
private Rectangle shape;
|
private final Rectangle shape;
|
||||||
/*
|
/*
|
||||||
0
|
0
|
||||||
1 2 3 4
|
1 2 3 4
|
||||||
5
|
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() {
|
public Die() {
|
||||||
int[] pips = {4, 6, 5, 1, 2, 3};
|
int[] pips = {4, 6, 5, 1, 2, 3};
|
||||||
|
@ -39,6 +45,19 @@ public class Die extends Actor {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(SpriteBatch batch) {
|
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<Face.Pip> pips = face.getPips();
|
||||||
|
Face.Pip decayed = pips.get(random.nextInt());
|
||||||
|
face.removePip(decayed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ 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;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void create() {
|
public void create() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue