-
Notifications
You must be signed in to change notification settings - Fork 1
/
TetrisMenuState.java
50 lines (41 loc) · 1.48 KB
/
TetrisMenuState.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package tetris.game;
import org.newdawn.slick.Color;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.Input;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.state.BasicGameState;
import org.newdawn.slick.state.StateBasedGame;
public class TetrisMenuState extends BasicGameState{
private Image img;
private String newGame, quit;
@Override
public void init(GameContainer container, StateBasedGame game) throws SlickException {
img = new Image("C:\\Users\\calreiter16\\Desktop\\AHA\\AHA 15-16\\AP Computer Science\\Tetris2.0\\jdl.png");
newGame = "NEW GAME (ENTER)";
quit = "QUIT (ESC)";
}
@Override
public void update(GameContainer container, StateBasedGame game, int delta) throws SlickException {
if (container.getInput().isKeyPressed(Input.KEY_ENTER)) {
container.getInput().clearKeyPressedRecord();
game.enterState(Tetris.GAME_STATE);
}
if (container.getInput().isKeyPressed(Input.KEY_ESCAPE)) {
System.exit(0);
}
}
@Override
public void render(GameContainer c, StateBasedGame arg1, Graphics g) throws SlickException {
img.draw(c.getWidth()/5, c.getHeight()/5, c.getWidth()/5, c.getHeight()/5);
g.setColor(Color.white);
//change to be font - text selection capabilites
g.drawString(newGame, c.getWidth()/2, c.getHeight()/2);
g.drawString(quit, c.getWidth()/2, c.getHeight()/2+50);
}
@Override
public int getID() {
return Tetris.MENU_STATE;
}
}