merge
This commit is contained in:
commit
d06da44e56
3 changed files with 33 additions and 5 deletions
|
@ -60,4 +60,12 @@ public class Die extends Actor {
|
|||
}
|
||||
}
|
||||
|
||||
public Face getFace() {
|
||||
return faces[faceIndex];
|
||||
}
|
||||
|
||||
public int getFaceValue() {
|
||||
return getFace().getValue();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import com.badlogic.gdx.math.Vector2;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
|
||||
|
||||
public class Face extends Actor{
|
||||
|
||||
|
@ -26,7 +26,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--;
|
||||
}
|
||||
|
@ -89,6 +89,8 @@ public class Face extends Actor{
|
|||
{
|
||||
Vector2 position = new Vector2(shape.x + (shape.width*percentages.x/100f) + (float)pipSprite.getWidth()/2,
|
||||
shape.y + shape.width*percentages.y/100f + (float)pipSprite.getHeight()/2);
|
||||
|
||||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -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,26 +17,35 @@ public class Game extends ApplicationAdapter {
|
|||
|
||||
private final Set<Actor> actors = new HashSet<>();
|
||||
|
||||
private final List<Die> dice = new ArrayList<>();
|
||||
|
||||
private SpriteBatch batch;
|
||||
private BitmapFont font;
|
||||
private Texture img;
|
||||
|
||||
private final static int TICKS_PER_SECOND = 60;
|
||||
private double tickProgress = 0;
|
||||
|
||||
|
||||
@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() {
|
||||
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--;
|
||||
|
@ -46,6 +56,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();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue