forked from helloplz/MazeBuilder
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
4 changed files
with
160 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package com.mazebuilder.root; | ||
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; | ||
|
||
/** | ||
* This is the main gameplay loop - gameboard, player movement, etc, should all be in here. | ||
* | ||
* @author dxiao | ||
*/ | ||
public class GameplayState extends BasicGameState { | ||
|
||
static public final int ID = 1; | ||
|
||
/** Write initialization for the board here */ | ||
@Override | ||
public void init(GameContainer container, StateBasedGame game) | ||
throws SlickException { | ||
|
||
} | ||
|
||
/** Each rendering step, draw the game here */ | ||
@Override | ||
public void render(GameContainer container, StateBasedGame game, Graphics g) | ||
throws SlickException { | ||
g.drawString("Hello, Mazebuilder! [Gameplay]", 50, 100); | ||
} | ||
|
||
/** Each logic step, poll inputs and compute game logic here */ | ||
@Override | ||
public void update(GameContainer container, StateBasedGame game, int delta) | ||
throws SlickException { | ||
|
||
} | ||
|
||
@Override | ||
public int getID() { | ||
return ID; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package com.mazebuilder.root; | ||
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 dxiao | ||
*/ | ||
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; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.mazebuilder.root; | ||
import org.newdawn.slick.AppGameContainer; | ||
import org.newdawn.slick.GameContainer; | ||
import org.newdawn.slick.SlickException; | ||
import org.newdawn.slick.state.StateBasedGame; | ||
|
||
/** | ||
* | ||
* @author dxiao | ||
*/ | ||
public class MazebuilderGame extends StateBasedGame { | ||
|
||
public MazebuilderGame() { | ||
super("Mazebuilder v0.0"); | ||
} | ||
|
||
@Override | ||
public void initStatesList(GameContainer gc) throws SlickException { | ||
addState(new MainMenuState()); | ||
addState(new GameplayState()); | ||
} | ||
|
||
public static void main (String args[]) throws SlickException { | ||
AppGameContainer app = new AppGameContainer(new MazebuilderGame()); | ||
|
||
app.setDisplayMode(800, 600, false); | ||
//app.setSmoothDeltas(true); | ||
|
||
app.start(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.mazebuilder.toys; | ||
import org.newdawn.slick.BasicGame; | ||
import org.newdawn.slick.GameContainer; | ||
import org.newdawn.slick.Graphics; | ||
import org.newdawn.slick.SlickException; | ||
import org.newdawn.slick.AppGameContainer; | ||
|
||
/** | ||
* | ||
* @author dxiao | ||
*/ | ||
public class TestSlick extends BasicGame { | ||
|
||
public TestSlick () { | ||
super("SimpleTest"); | ||
} | ||
|
||
@Override | ||
public void init(GameContainer container) throws SlickException {} | ||
|
||
@Override | ||
public void update(GameContainer container, int delta) | ||
throws SlickException {} | ||
|
||
@Override | ||
public void render(GameContainer container, Graphics g) | ||
throws SlickException { | ||
g.drawString("Hello, Slick world!", 0, 100); | ||
} | ||
|
||
public static void main(String[] args) { | ||
try { | ||
AppGameContainer app = new AppGameContainer(new TestSlick ()); | ||
app.start(); | ||
} catch (SlickException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
} |