Class GameSetup


public class GameSetup

This class provides methods for the main frame to get the components of the
game. When a MainFrame is created, it is passed one of these. Basically,
by using different GameSetup instances, the game can take on many different
forms with the same "standard" mechanism around it.

Students will be given this class and the various interfaces in code format.
My implmentations of all the other classes will only be distributed in compiled,
.jar format. Over the course of the semester, the students will modify the
methods of this class and write their own implementations of the basic
interfaces to provide the behavior of the game.

DO NOT modify the signatures of the methods provided here. You can add
other methods to this class, but don't change the ones that are present
or your code is likely to stop working inside the framework.


Method Summary
 static voidconstructVariables()
          This method should be called in your main before you create your MainFrame.
 static PlayergetLocalPlayer()
          Returns the instance of your Player subclass that should be used in this game.
 static JMenuBargetMenuBar()
          This function returns a JMenuBar object that will be added to the main
display window.
 static PriorityQueuegetPriorityQueue()
          Return the priority queue that you are using for the game.
 static booleangetScaling()
          This method tells the display class if the images in the game should be
scaled.
 static intgetScrolling()
          Tells the display class is this game has a scrolling background.
 static voidsetMainFrame(MainFrame 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.
 static voidstopGame()
          This function will automatically be called when the player begins to return
something other than GAME_RUNNING.
 static booleanuseDrawOptimization()
          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.

Method Detail

constructVariables

public static void constructVariables()
This method should be called in your main before you create your MainFrame.
It should initialize all of your variables that are related to the general
state of the game.

getLocalPlayer

public static Player getLocalPlayer()
Returns the instance of your Player subclass that should be used in this game.

getMenuBar

public static JMenuBar getMenuBar()
This function returns a JMenuBar object that will be added to the main
display window. All of the functions that you want the menus to be able
to doo will need to be connected from here.

getPriorityQueue

public static PriorityQueue getPriorityQueue()
Return the priority queue that you are using for the game. You will write
two of these during the semester.

getScaling

public static boolean getScaling()
This method tells the display class if the images in the game should be
scaled. If you turn this off your window will be fixed to a given size
and the user won't be able to scale it. You will have to make
sure that all your blocks use the same image size. The drawing program
assumes that the size of the 0,0 block should be used for all. The reason
you would want this option off is if you want to draw an entity that is
larger than a single block. Doing so will complicate your life though so
I recommend that this return true unless you have a very compelling reason
to do otherwise.
Returns: Whether images should be scaled for this game.

getScrolling

public static int getScrolling()
Tells the display class is this game has a scrolling background. I have
not done that much testing on the scrolling backgrounds. They should work,
but there are no promises. Debugging for you will probably be easier if
you can see the whole screen anyway.
Returns: This value tells the program how many squares across it should draw around the player. Return -1 for no scrolling.

setMainFrame

public static void setMainFrame(MainFrame 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.
Parameters:
mf The MainFrame object the game is being played in.

stopGame

public static void stopGame()
This function will automatically be called when the player begins to return
something other than GAME_RUNNING.

useDrawOptimization

public static 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. This
can be significantly faster. However, if it is true, it means that changes
to blocks won't normally be drawn so you can't have animated blocks, or
moving blocks, or blocks that disappear (doors). This flag is checked
at every step so you could have it return true most of the time, but return
false when some event has occured that should require the blocks to be
redrawn.
Returns: Whether or not the framework should double-buffer the blocks as a background image.

Association Links

to Class Player

to Class PriorityQueue

to Class Screen

to Class MainFrame