added ability to lock dice
This commit is contained in:
parent
2544da0313
commit
40bcbee4e9
2 changed files with 22 additions and 3 deletions
|
@ -47,9 +47,18 @@ public class Game extends ApplicationAdapter {
|
|||
public void processInput() {
|
||||
Input input = Gdx.input;
|
||||
|
||||
if (input.isKeyJustPressed(Input.Keys.R)) {
|
||||
if (input.isKeyJustPressed(Input.Keys.R)) { //reroll dice
|
||||
dice.forEach(Die::roll);
|
||||
}
|
||||
|
||||
for (int i = 0; i < dice.size(); i++) { //lock dice, iterating over for each keycode
|
||||
Die die = dice.get(i); //die iterator is looking at
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue