|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.trinity.cs.gamecore.basic.BasicGameSetup
public class BasicGameSetup
This is a simple implementation of the GameSetup interface. It tells the game infrastructure how to render things and is a good place to put things that you need to get to from anywhere.
Students are given this code with assignment #2. The class itself uses the singleton pattern not only so that only one is created, but also so that you can easily get to that one instance from anywhere in your code. For the singleton pattern, the constructor is made private and we put in a static method called instance that checks to see if we have created an instance, creates one if not, and returns the instance.
Feel free to add whatever other methods or members you want into your implementation of GameSetup. This can be a simple way to keep track of information that lots of different entities or blocks need to get hold of.
Method Summary | |
---|---|
BasicPlayer |
getLocalPlayer()
Returns the instance of your Player subclass that should be used in this game. |
javax.swing.JMenuBar |
getMenuBar()
This function returns a JMenuBar object that will be added to the main display window. |
PriorityQueue<BasicBlock,BasicEntity> |
getPriorityQueue()
Return the priority queue that you are using for the game. |
int |
getScrollingX()
Tells the display class is this game has a scrolling background in the x direction. |
int |
getScrollingY()
Tells the display class is this game has a scrolling background in the y direction. |
static BasicGameSetup |
instance()
This method returns the singleton of the BasicGameSetup class. |
void |
setMainFrame(MainFrame<BasicBlock,BasicEntity> mf)
This method is called in the constructor of a main frame so that the GameSetup class will be able to communicate with the frame that the game is being played in. |
void |
stopGame()
This function will automatically be called when the player begins to return something other than GAME_RUNNING. |
boolean |
useDrawOptimization()
If this returns true, the drawing routine will use an optimization of drawing the images for all the blocks once to a large image and just putting up that image as long as the player hasn't changed screens. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static BasicGameSetup instance()
public void setMainFrame(MainFrame<BasicBlock,BasicEntity> mf)
setMainFrame
in interface GameSetup<BasicBlock,BasicEntity>
mf
- The MainFrame object the game is being played in.public BasicPlayer getLocalPlayer()
getLocalPlayer
in interface GameSetup<BasicBlock,BasicEntity>
public PriorityQueue<BasicBlock,BasicEntity> getPriorityQueue()
getPriorityQueue
in interface GameSetup<BasicBlock,BasicEntity>
public int getScrollingX()
getScrollingX
in interface GameSetup<BasicBlock,BasicEntity>
public int getScrollingY()
getScrollingY
in interface GameSetup<BasicBlock,BasicEntity>
public boolean useDrawOptimization()
useDrawOptimization
in interface GameSetup<BasicBlock,BasicEntity>
public javax.swing.JMenuBar getMenuBar()
getMenuBar
in interface GameSetup<BasicBlock,BasicEntity>
public void stopGame()
stopGame
in interface GameSetup<BasicBlock,BasicEntity>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |