From 2624277302172af960fe3aa42a8b607b502240e0 Mon Sep 17 00:00:00 2001 From: James <150948866+jameslaight@users.noreply.github.com> Date: Sat, 20 Apr 2024 15:24:09 +0100 Subject: [PATCH] add roll and decay --- core/src/com/monjaro/gamejam/Die.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/core/src/com/monjaro/gamejam/Die.java b/core/src/com/monjaro/gamejam/Die.java index 68d46b8..d3242cb 100644 --- a/core/src/com/monjaro/gamejam/Die.java +++ b/core/src/com/monjaro/gamejam/Die.java @@ -3,6 +3,10 @@ package com.monjaro.gamejam; import com.badlogic.gdx.math.Rectangle; import com.badlogic.gdx.graphics.g2d.SpriteBatch; +import javax.print.attribute.standard.PrinterIsAcceptingJobs; +import java.util.List; +import java.util.Random; + public class Die extends Actor { private Rectangle shape; @@ -12,6 +16,9 @@ public class Die extends Actor { 5 */ private 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}; @@ -43,11 +50,15 @@ public class Die extends Actor { } public void roll() { - + faceIndex = random.nextInt(6); } - public void decay() { - + 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); + } } }