From 07a94943b9e7727a4dad1d0166ae31ef3b3c1016 Mon Sep 17 00:00:00 2001 From: pgruevski Date: Thu, 20 Sep 2012 21:17:59 -0400 Subject: [PATCH] Distributed files into packages. Fixed David's author tag. --- .../com/mazebuilder/root/GameplayState.java | 43 +++++++++++++++++ .../com/mazebuilder/root/MainMenuState.java | 47 +++++++++++++++++++ .../com/mazebuilder/root/MazebuilderGame.java | 31 ++++++++++++ .../test/com/mazebuilder/toys/TestSlick.java | 39 +++++++++++++++ 4 files changed, 160 insertions(+) create mode 100644 Mazebuilder/src/com/mazebuilder/root/GameplayState.java create mode 100644 Mazebuilder/src/com/mazebuilder/root/MainMenuState.java create mode 100644 Mazebuilder/src/com/mazebuilder/root/MazebuilderGame.java create mode 100644 Mazebuilder/test/com/mazebuilder/toys/TestSlick.java diff --git a/Mazebuilder/src/com/mazebuilder/root/GameplayState.java b/Mazebuilder/src/com/mazebuilder/root/GameplayState.java new file mode 100644 index 0000000..653dc7c --- /dev/null +++ b/Mazebuilder/src/com/mazebuilder/root/GameplayState.java @@ -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; + } + +} diff --git a/Mazebuilder/src/com/mazebuilder/root/MainMenuState.java b/Mazebuilder/src/com/mazebuilder/root/MainMenuState.java new file mode 100644 index 0000000..563fbe4 --- /dev/null +++ b/Mazebuilder/src/com/mazebuilder/root/MainMenuState.java @@ -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; + } + +} diff --git a/Mazebuilder/src/com/mazebuilder/root/MazebuilderGame.java b/Mazebuilder/src/com/mazebuilder/root/MazebuilderGame.java new file mode 100644 index 0000000..0fca77b --- /dev/null +++ b/Mazebuilder/src/com/mazebuilder/root/MazebuilderGame.java @@ -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(); + } +} diff --git a/Mazebuilder/test/com/mazebuilder/toys/TestSlick.java b/Mazebuilder/test/com/mazebuilder/toys/TestSlick.java new file mode 100644 index 0000000..da95071 --- /dev/null +++ b/Mazebuilder/test/com/mazebuilder/toys/TestSlick.java @@ -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(); + } + } +} \ No newline at end of file