diff --git a/core/src/com/monjaro/gamejam/Actor.java b/core/src/com/monjaro/gamejam/Actor.java index d18653e..f27cb5e 100644 --- a/core/src/com/monjaro/gamejam/Actor.java +++ b/core/src/com/monjaro/gamejam/Actor.java @@ -1,10 +1,11 @@ package com.monjaro.gamejam; -import com.badlogic.gdx.math.Shape2D; + +import com.badlogic.gdx.graphics.g2d.SpriteBatch; public abstract class Actor { public abstract void tick(); - public abstract void render(); + public abstract void render(SpriteBatch batch); } diff --git a/core/src/com/monjaro/gamejam/Die.java b/core/src/com/monjaro/gamejam/Die.java index 94d889a..7e348ad 100644 --- a/core/src/com/monjaro/gamejam/Die.java +++ b/core/src/com/monjaro/gamejam/Die.java @@ -1,6 +1,8 @@ package com.monjaro.gamejam; + import com.badlogic.gdx.math.Rectangle; +import com.badlogic.gdx.graphics.g2d.SpriteBatch; public class Die extends Actor { @@ -35,10 +37,9 @@ public class Die extends Actor { } @Override - public void render() { - for (Face face : faces){ - face.render(); + public void render(SpriteBatch batch) { + for (Face face : faces) { + face.render(batch); } } - } diff --git a/core/src/com/monjaro/gamejam/Face.java b/core/src/com/monjaro/gamejam/Face.java index 6b339b8..c80aa45 100644 --- a/core/src/com/monjaro/gamejam/Face.java +++ b/core/src/com/monjaro/gamejam/Face.java @@ -1,26 +1,33 @@ package com.monjaro.gamejam; - +import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.math.Rectangle; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; public class Face extends Actor{ private Rectangle shape; - private int pips; + private final List pips = new ArrayList<>(); - public Face(int pips) { - this.pips = pips; + public Face(int pipCount) { + //ro adds pips here } - public int getPips() { - return pips; + public int getValue() { + return pips.size(); } - public void setPips(int pips) { - this.pips = pips; + public List getPips() { + return Collections.unmodifiableList(pips); } - private static class Pip { + public void removePip(Pip pip) { + pips.remove(pip); + } + + public static class Pip { private final double x, y; @@ -54,7 +61,7 @@ public class Face extends Actor{ } @Override - public void render() { + public void render(SpriteBatch batch) { } diff --git a/core/src/com/monjaro/gamejam/Game.java b/core/src/com/monjaro/gamejam/Game.java index 071881f..e441b05 100644 --- a/core/src/com/monjaro/gamejam/Game.java +++ b/core/src/com/monjaro/gamejam/Game.java @@ -5,13 +5,21 @@ import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.Texture; 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; +import java.util.List; +import java.util.Set; public class Game extends ApplicationAdapter { + private final Set actors = new HashSet<>(); + private SpriteBatch batch; private Texture img; - private static int TICKS_PER_SECOND; + private final static int TICKS_PER_SECOND = 60; private double tickProgress = 0; @Override @@ -21,20 +29,22 @@ public class Game extends ApplicationAdapter { } public void tick() { - + actors.forEach(Actor::tick); } @Override public void render() { - Gdx.graphics.getDeltaTime(); + tickProgress += Gdx.graphics.getDeltaTime() / TICKS_PER_SECOND; while (tickProgress >= 1) { //tick as many times as needed tick(); tickProgress--; } - ScreenUtils.clear(1, 0, 0, 1); + ScreenUtils.clear(0, 0, 0, 1); batch.begin(); - batch.draw(img, 0, 0); + + actors.forEach(a -> a.render(batch)); + batch.end(); } @@ -44,4 +54,12 @@ public class Game extends ApplicationAdapter { img.dispose(); } + private void addActor(Actor actor) { + actors.add(actor); + } + + private void removeActor(Actor actor) { + actors.remove(actor); + } + }