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] 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(); }