From cfbe8ad8b439b06e477c5859f12d9f7b86f5af65 Mon Sep 17 00:00:00 2001 From: James <150948866+jameslaight@users.noreply.github.com> Date: Sat, 20 Apr 2024 15:45:42 +0100 Subject: [PATCH 1/3] add numbers for test display --- core/src/com/monjaro/gamejam/Die.java | 8 ++++++++ core/src/com/monjaro/gamejam/Game.java | 19 ++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/core/src/com/monjaro/gamejam/Die.java b/core/src/com/monjaro/gamejam/Die.java index 045c6ed..809de37 100644 --- a/core/src/com/monjaro/gamejam/Die.java +++ b/core/src/com/monjaro/gamejam/Die.java @@ -60,4 +60,12 @@ public class Die extends Actor { } } + public Face getFace() { + return faces[faceIndex]; + } + + public int getFaceValue() { + return getFace().getValue(); + } + } diff --git a/core/src/com/monjaro/gamejam/Game.java b/core/src/com/monjaro/gamejam/Game.java index e441b05..f1fab6c 100644 --- a/core/src/com/monjaro/gamejam/Game.java +++ b/core/src/com/monjaro/gamejam/Game.java @@ -2,10 +2,11 @@ package com.monjaro.gamejam; import com.badlogic.gdx.ApplicationAdapter; import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.Texture; +import com.badlogic.gdx.graphics.g2d.BitmapFont; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.utils.ScreenUtils; -import jdk.vm.ci.hotspot.JFR; import java.util.ArrayList; import java.util.HashSet; @@ -16,7 +17,10 @@ public class Game extends ApplicationAdapter { private final Set actors = new HashSet<>(); + private final List dice = new ArrayList<>(); + private SpriteBatch batch; + private BitmapFont font; private Texture img; private final static int TICKS_PER_SECOND = 60; @@ -25,7 +29,12 @@ public class Game extends ApplicationAdapter { @Override public void create() { batch = new SpriteBatch(); + font = new BitmapFont(); img = new Texture("badlogic.jpg"); + + for (int i = 0; i < 5; i++) { + dice.add(new Die()); + } } public void tick() { @@ -45,6 +54,14 @@ public class Game extends ApplicationAdapter { actors.forEach(a -> a.render(batch)); + //TODO debug + int x = 100; + for (Die die : dice) { + batch.setColor(Color.WHITE); + font.draw(batch, String.valueOf(die.getFaceValue()), x += 50, 100); + } + //----- + batch.end(); } From 686f6c26e2ee0680fb9dff72abe2cfc8b50fab63 Mon Sep 17 00:00:00 2001 From: James <150948866+jameslaight@users.noreply.github.com> Date: Sat, 20 Apr 2024 15:50:42 +0100 Subject: [PATCH 2/3] even -> odd --- core/src/com/monjaro/gamejam/Face.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/src/com/monjaro/gamejam/Face.java b/core/src/com/monjaro/gamejam/Face.java index a037166..0a23eb7 100644 --- a/core/src/com/monjaro/gamejam/Face.java +++ b/core/src/com/monjaro/gamejam/Face.java @@ -1,8 +1,9 @@ package com.monjaro.gamejam; + import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.g2d.SpriteBatch; -import com.badlogic.gdx.graphics.glutils.ShapeRenderer; import com.badlogic.gdx.math.Rectangle; + import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -23,7 +24,7 @@ public class Face extends Actor{ private void addPipsForValue(int value){ int[][] positions = {{25, 25}, {75, 75}, {25, 75}, {75, 25}, {25, 50}, {75, 50}}; - if (value%2 == 0) { + if (value % 2 == 1) { pips.add(new Pip(50, 50)); value--; } From 68c60a22450646c2bfe174c4c579d74b5fd828ff Mon Sep 17 00:00:00 2001 From: James <150948866+jameslaight@users.noreply.github.com> Date: Sat, 20 Apr 2024 16:01:31 +0100 Subject: [PATCH 3/3] fix tick method running at the reciprocal of TPS --- core/src/com/monjaro/gamejam/Game.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/src/com/monjaro/gamejam/Game.java b/core/src/com/monjaro/gamejam/Game.java index 1afdb46..01a4593 100644 --- a/core/src/com/monjaro/gamejam/Game.java +++ b/core/src/com/monjaro/gamejam/Game.java @@ -26,7 +26,6 @@ public class Game extends ApplicationAdapter { private final static int TICKS_PER_SECOND = 60; private double tickProgress = 0; - @Override public void create() { batch = new SpriteBatch(); @@ -40,11 +39,13 @@ public class Game extends ApplicationAdapter { public void tick() { actors.forEach(Actor::tick); + + dice.forEach(Die::roll); } @Override public void render() { - tickProgress += Gdx.graphics.getDeltaTime() / TICKS_PER_SECOND; + tickProgress += Gdx.graphics.getDeltaTime() * TICKS_PER_SECOND; while (tickProgress >= 1) { //tick as many times as needed tick(); tickProgress--;