Merge branch 'main' of github.com:Wil-Ro/gamejam2024
This commit is contained in:
commit
c4559837bb
3 changed files with 33 additions and 9 deletions
|
@ -14,11 +14,13 @@ public class Die extends Actor {
|
||||||
1 2 3 4
|
1 2 3 4
|
||||||
5
|
5
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private final Face[] faces = new Face[6];
|
private final Face[] faces = new Face[6];
|
||||||
private int faceIndex = 3;
|
private int faceIndex = 3;
|
||||||
|
|
||||||
private final Random random = new Random(); //TODO use central random
|
private final Random random = new Random(); //TODO use central random
|
||||||
|
|
||||||
|
|
||||||
public Die() {
|
public Die() {
|
||||||
int[] pips = {4, 6, 5, 1, 2, 3};
|
int[] pips = {4, 6, 5, 1, 2, 3};
|
||||||
for (int i = 0; i < faces.length; i++) {
|
for (int i = 0; i < faces.length; i++) {
|
||||||
|
@ -43,9 +45,7 @@ public class Die extends Actor {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(SpriteBatch batch) {
|
public void render(SpriteBatch batch) {
|
||||||
for (Face face : faces) {
|
faces[faceIndex].render(batch);
|
||||||
face.render(batch);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void roll() {
|
public void roll() {
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package com.monjaro.gamejam;
|
package com.monjaro.gamejam;
|
||||||
|
import com.badlogic.gdx.graphics.Texture;
|
||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||||
|
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
|
||||||
import com.badlogic.gdx.math.Rectangle;
|
import com.badlogic.gdx.math.Rectangle;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -11,8 +13,24 @@ public class Face extends Actor{
|
||||||
|
|
||||||
private final List<Pip> pips = new ArrayList<>();
|
private final List<Pip> pips = new ArrayList<>();
|
||||||
|
|
||||||
|
private static Texture blankFaceSprite;
|
||||||
|
private static Texture pipSprite;
|
||||||
|
|
||||||
public Face(int pipCount) {
|
public Face(int pipCount) {
|
||||||
//ro adds pips here
|
addPipsForValue(pipCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addPipsForValue(int value){
|
||||||
|
int[][] positions = {{25, 25}, {75, 75}, {25, 75}, {75, 25}, {25, 50}, {75, 50}};
|
||||||
|
|
||||||
|
if (value%2 == 0) {
|
||||||
|
pips.add(new Pip(50, 50));
|
||||||
|
value--;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < value ; i++) {
|
||||||
|
pips.add(new Pip(positions[i][0], positions[i][1]));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getValue() {
|
public int getValue() {
|
||||||
|
@ -29,18 +47,18 @@ public class Face extends Actor{
|
||||||
|
|
||||||
public static class Pip {
|
public static class Pip {
|
||||||
|
|
||||||
private final double x, y;
|
private final float x, y;
|
||||||
|
|
||||||
public Pip(double x, double y) {
|
public Pip(float x, float y) {
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getX() {
|
public float getX() {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getY() {
|
public float getY() {
|
||||||
return y;
|
return y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +80,12 @@ public class Face extends Actor{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(SpriteBatch batch) {
|
public void render(SpriteBatch batch) {
|
||||||
|
batch.draw(blankFaceSprite, shape.x, shape.y, shape.width, shape.height);
|
||||||
|
for(Pip pip : pips){
|
||||||
|
batch.draw(pipSprite,
|
||||||
|
shape.x + (shape.width*pip.x/100f),
|
||||||
|
shape.y + (shape.width*pip.y/100f));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ public class Game extends ApplicationAdapter {
|
||||||
private final static int TICKS_PER_SECOND = 60;
|
private final static int TICKS_PER_SECOND = 60;
|
||||||
private double tickProgress = 0;
|
private double tickProgress = 0;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void create() {
|
public void create() {
|
||||||
batch = new SpriteBatch();
|
batch = new SpriteBatch();
|
||||||
|
|
Loading…
Add table
Reference in a new issue