Skip to content

Commit

Permalink
Added a MainMenu state
Browse files Browse the repository at this point in the history
  • Loading branch information
dxiao committed Sep 19, 2012
1 parent 5d0644d commit e64d345
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Mazebuilder/src/GameplayState.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/
public class GameplayState extends BasicGameState {

static public final int ID = 0;
static public final int ID = 1;

/** Write initialization for the board here */
@Override
Expand All @@ -24,7 +24,7 @@ public void init(GameContainer container, StateBasedGame game)
@Override
public void render(GameContainer container, StateBasedGame game, Graphics g)
throws SlickException {
g.drawString("Hello, Mazebuilder!", 0, 100);
g.drawString("Hello, Mazebuilder! [Gameplay]", 50, 100);
}

/** Each logic step, poll inputs and compute game logic here */
Expand Down
46 changes: 46 additions & 0 deletions Mazebuilder/src/MainMenuState.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.state.BasicGameState;
import org.newdawn.slick.state.StateBasedGame;

/**
* The main menu loop.
*
* @author xiao
*/
public class MainMenuState extends BasicGameState {

static public final int ID = 0;

private StateBasedGame game;

@Override
public void init(GameContainer container, StateBasedGame game)
throws SlickException {
this.game = game;
}

@Override
public void render(GameContainer container, StateBasedGame game, Graphics g)
throws SlickException {
g.drawString("Hello, Mazebuilder! [MainMenu]", 50, 100);
}

@Override
public void update(GameContainer container, StateBasedGame game, int delta)
throws SlickException {
}

@Override
public void mouseClicked(int button, int x, int y, int clickCount) {
game.enterState(GameplayState.ID);
}

@Override
public int getID() {
// TODO Auto-generated method stub
return 0;
}

}
1 change: 1 addition & 0 deletions Mazebuilder/src/MazebuilderGame.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public MazebuilderGame() {

@Override
public void initStatesList(GameContainer gc) throws SlickException {
addState(new MainMenuState());
addState(new GameplayState());
}

Expand Down

0 comments on commit e64d345

Please sign in to comment.