merge
This commit is contained in:
commit
aef7e2c955
3 changed files with 22 additions and 26 deletions
|
@ -16,13 +16,12 @@ public class Die extends Actor {
|
|||
*/
|
||||
private final Face[] faces = new Face[6];
|
||||
private int faceIndex = 3;
|
||||
private boolean locked = false;
|
||||
private boolean selected = false;
|
||||
|
||||
private static Texture lockedSprite;
|
||||
|
||||
private final Random random = new Random(); //TODO use central random
|
||||
|
||||
|
||||
public Die(float x, float y, float width, float height) {
|
||||
transform = new Transform(x, y, width, height);
|
||||
|
||||
|
@ -79,14 +78,14 @@ public class Die extends Actor {
|
|||
return getFaceValue() <= 0;
|
||||
}
|
||||
|
||||
public boolean isLocked() {
|
||||
return locked;
|
||||
public boolean isSelected() {
|
||||
return selected;
|
||||
}
|
||||
|
||||
public void setLocked(boolean locked) {
|
||||
if (locked != this.locked)
|
||||
public void setSelected(boolean selected) {
|
||||
if (selected != this.selected)
|
||||
{
|
||||
if (locked) {
|
||||
if (selected) {
|
||||
transform.y += 64;
|
||||
transform.rotation = 20;
|
||||
}
|
||||
|
@ -96,7 +95,7 @@ public class Die extends Actor {
|
|||
}
|
||||
} // terrible
|
||||
|
||||
this.locked = locked;
|
||||
this.selected = selected;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,14 +13,10 @@ import com.monjaro.gamejam.segment.KinSegment;
|
|||
import com.monjaro.gamejam.segment.Segment;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class Game extends ApplicationAdapter {
|
||||
|
||||
private final Set<Actor> actors = new HashSet<>();
|
||||
|
||||
private final List<Die> dice = new ArrayList<>();
|
||||
private final List<Segment> segments = new ArrayList<>();
|
||||
|
||||
|
@ -57,15 +53,13 @@ public class Game extends ApplicationAdapter {
|
|||
|
||||
public void tick() {
|
||||
processInput();
|
||||
|
||||
actors.forEach(Actor::tick);
|
||||
}
|
||||
|
||||
public void processInput() {
|
||||
Input input = Gdx.input;
|
||||
|
||||
if (input.isKeyJustPressed(Input.Keys.R)) { //reroll dice that aren't locked
|
||||
dice.stream().filter(d -> !d.isLocked()).forEach(Die::roll);
|
||||
dice.stream().filter(d -> !d.isSelected()).forEach(Die::roll);
|
||||
|
||||
System.out.println("=".repeat(100));
|
||||
for (Segment segment : segments) {
|
||||
|
@ -78,7 +72,7 @@ public class Game extends ApplicationAdapter {
|
|||
int keyCode = Input.Keys.NUM_1 + i; //keycode for the current die, 1, 2...9, 0 on keyboard
|
||||
|
||||
if (input.isKeyJustPressed(keyCode)) { //if key corresponding to die has been pressed
|
||||
die.setLocked(!die.isLocked()); //flip lock state
|
||||
die.setSelected(!die.isSelected()); //flip lock state
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -94,8 +88,6 @@ public class Game extends ApplicationAdapter {
|
|||
ScreenUtils.clear(0, 0, 0, 1);
|
||||
batch.begin();
|
||||
|
||||
actors.forEach(a -> a.render(batch));
|
||||
|
||||
//TODO debug
|
||||
for (Die die : dice) {
|
||||
die.render(batch);
|
||||
|
@ -105,7 +97,7 @@ public class Game extends ApplicationAdapter {
|
|||
for (Segment segment : segments) {
|
||||
String prefix = "[#9E65A8]";
|
||||
if (segment.isDestroyed()) prefix = "[#EBE5EC]";
|
||||
else if (segment.isDestroyedBy(dice)) prefix = "[#528154]";
|
||||
else if (segment.isDestroyedBy(getSelectedDice())) prefix = "[#528154]";
|
||||
|
||||
font.draw(batch, prefix + segment.getName(), x += 75, Gdx.graphics.getHeight() - 100);
|
||||
}
|
||||
|
@ -120,12 +112,10 @@ public class Game extends ApplicationAdapter {
|
|||
img.dispose();
|
||||
}
|
||||
|
||||
private void addActor(Actor actor) {
|
||||
actors.add(actor);
|
||||
}
|
||||
|
||||
private void removeActor(Actor actor) {
|
||||
actors.remove(actor);
|
||||
public List<Die> getSelectedDice() {
|
||||
return dice.stream()
|
||||
.filter(d -> !d.isSelected())
|
||||
.toList();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,7 +3,14 @@ package com.monjaro.gamejam;
|
|||
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||
|
||||
public class UI extends Actor{
|
||||
Transform transform
|
||||
private Transform position;
|
||||
private Texture
|
||||
|
||||
public void setPosition(int x, int y){
|
||||
position.x = x;
|
||||
position.y = y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue