merge
This commit is contained in:
commit
ac960c53cd
3 changed files with 6 additions and 16 deletions
|
@ -68,7 +68,7 @@ public class Die extends Actor {
|
|||
Face.Pip decayed = pips.get(random.nextInt(pips.size()));
|
||||
face.removePip(decayed);
|
||||
|
||||
game.addFallingPip(new FallingPip(new Transform(transform.getX(), transform.getY(), 0, 0), face.equals(getFace())));
|
||||
game.addFallingPip(new FallingPip(new Transform(transform.getX(), transform.getY(), 0, 0)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,18 +10,12 @@ public class FallingPip extends Actor {
|
|||
|
||||
private final Transform transform;
|
||||
private final Vector2 velocity;
|
||||
private final float rotationalVelocity;
|
||||
|
||||
private final boolean onTop;
|
||||
|
||||
public FallingPip(Transform transform, boolean onTop) {
|
||||
public FallingPip(Transform transform) {
|
||||
Random random = new Random();
|
||||
|
||||
this.transform = transform;
|
||||
velocity = new Vector2(5 * (-0.5f + random.nextFloat()), 2 + random.nextFloat() * 3);
|
||||
rotationalVelocity = 40 * (-0.5f + random.nextFloat());
|
||||
|
||||
this.onTop = onTop;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -30,7 +24,6 @@ public class FallingPip extends Actor {
|
|||
|
||||
transform.x += velocity.x;
|
||||
transform.y += velocity.y;
|
||||
transform.rotation += rotationalVelocity;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -43,8 +36,4 @@ public class FallingPip extends Actor {
|
|||
return transform.y <= 25;
|
||||
}
|
||||
|
||||
public boolean isOnTop() {
|
||||
return onTop;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -85,6 +85,7 @@ public class Game extends ApplicationAdapter {
|
|||
processInput();
|
||||
|
||||
fallingPips.forEach(Actor::tick);
|
||||
fallingPips.removeIf(FallingPip::isOffScreen);
|
||||
}
|
||||
|
||||
public void processInput() {
|
||||
|
@ -161,13 +162,13 @@ public class Game extends ApplicationAdapter {
|
|||
ScreenUtils.clear(0, 0, 0, 1);
|
||||
batch.begin();
|
||||
|
||||
for (FallingPip pip : fallingPips) if (!pip.isOnTop()) pip.render(batch);
|
||||
|
||||
for (Die die : dice) {
|
||||
die.render(batch);
|
||||
}
|
||||
|
||||
for (FallingPip pip : fallingPips) if (pip.isOnTop()) pip.render(batch); //on top
|
||||
for (FallingPip pip : fallingPips) { //on top
|
||||
pip.render(batch);
|
||||
}
|
||||
|
||||
int y = Gdx.graphics.getHeight() / 3 * 2 - 25;
|
||||
for (Decay decay : round.getDecays()) {
|
||||
|
|
Loading…
Add table
Reference in a new issue