Updated extra feature
This commit is contained in:
parent
d954190882
commit
b90faa13b8
@ -2,11 +2,12 @@ package it.cavallium.warppi.extra.tetris;
|
||||
|
||||
public class TetrisGame {
|
||||
|
||||
static final int WIDTH = 10, HEIGHT = 22;
|
||||
BlockType[] grid;
|
||||
BlockType[] hovergrid;
|
||||
GameStatus gameStatus = GameStatus.INITIAL;
|
||||
int score = 0;
|
||||
private static final int WIDTH = 10, HEIGHT = 22;
|
||||
private BlockType[] grid;
|
||||
private BlockType[] hovergrid;
|
||||
private GameStatus gameStatus = GameStatus.INITIAL;
|
||||
private int score = 0;
|
||||
private double currentTime = 0;
|
||||
|
||||
public TetrisGame() {
|
||||
|
||||
@ -16,6 +17,17 @@ public class TetrisGame {
|
||||
grid = new BlockType[WIDTH * HEIGHT];
|
||||
hovergrid = new BlockType[WIDTH * HEIGHT];
|
||||
score = 0;
|
||||
currentTime = 0;
|
||||
gameStatus = GameStatus.PLAYING;
|
||||
}
|
||||
|
||||
public void gameTick(float dt, boolean leftPressed, boolean rightPressed, boolean downPressed, boolean okPressed,
|
||||
boolean backPressed) {
|
||||
currentTime += dt;
|
||||
if (gameStatus == GameStatus.INITIAL) {
|
||||
playAgain();
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,16 @@ public class TetrisScreen extends Screen {
|
||||
|
||||
private TetrisGame g;
|
||||
|
||||
private boolean leftPressed;
|
||||
|
||||
private boolean rightPressed;
|
||||
|
||||
private boolean downPressed;
|
||||
|
||||
private boolean okPressed;
|
||||
|
||||
private boolean backPressed;
|
||||
|
||||
private GraphicEngine e;
|
||||
|
||||
private Renderer r;
|
||||
@ -50,6 +60,7 @@ public class TetrisScreen extends Screen {
|
||||
@Override
|
||||
public void beforeRender(final float dt) {
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glClearColor(0xff000000);
|
||||
g.gameTick(dt, leftPressed, rightPressed, downPressed, okPressed, backPressed);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -58,7 +69,60 @@ public class TetrisScreen extends Screen {
|
||||
TetrisScreen.skin.use(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onKeyPressed(KeyPressedEvent k) {
|
||||
switch (k.getKey()) {
|
||||
case LEFT: {
|
||||
leftPressed = true;
|
||||
return true;
|
||||
}
|
||||
case RIGHT: {
|
||||
rightPressed = true;
|
||||
return true;
|
||||
}
|
||||
case DOWN: {
|
||||
downPressed = true;
|
||||
return true;
|
||||
}
|
||||
case OK: {
|
||||
okPressed = true;
|
||||
return true;
|
||||
}
|
||||
case BACK: {
|
||||
backPressed = true;
|
||||
return true;
|
||||
}
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyReleased(KeyReleasedEvent k) {
|
||||
switch (k.getKey()) {
|
||||
case LEFT: {
|
||||
leftPressed = false;
|
||||
return true;
|
||||
}
|
||||
case RIGHT: {
|
||||
rightPressed = false;
|
||||
return true;
|
||||
}
|
||||
case DOWN: {
|
||||
downPressed = false;
|
||||
return true;
|
||||
}
|
||||
case OK: {
|
||||
okPressed = false;
|
||||
return true;
|
||||
}
|
||||
case BACK: {
|
||||
backPressed = false;
|
||||
return true;
|
||||
}
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public boolean mustBeRefreshed() {
|
||||
return true;
|
||||
|
@ -19,7 +19,7 @@ import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
|
||||
import it.cavallium.warppi.util.Utils;
|
||||
|
||||
public abstract class RFTFont implements BinaryFont {
|
||||
|
||||
|
||||
public boolean[][] rawchars;
|
||||
public int[] chars32;
|
||||
public int minBound = 10;
|
||||
|
Loading…
Reference in New Issue
Block a user