edu.trinity.cs.gamecore
Interface GameSetup<B extends Block<B,E>,E extends GameEntity<B,E>>

All Known Implementing Classes:
BasicGameSetup, EditorSetup

public interface GameSetup<B extends Block<B,E>,E extends GameEntity<B,E>>

This interface 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 a basic implementation of this interface as well as the other various interfaces in code format. Implementations of all the other classes will only be distributed in compiled, .jar format. Over the course of the semester, the students will modify the implementation to fit their game and write their own implementations of the basic interfaces to provide the behavior of the game.

The implementation of this class should specify the abstract superclasses students are using for their game as the generic types. It is also recommended that your implementation use the singleton pattern. The code you are provided with does this so that you will have something to follow. Students should also add other public methods to there implementation as needed for their game. Refer to the documentation of the provided BasicGameSetup to see this.

This interface is a generic that takes the general block type and the general entity type for each game.


Method Summary
 Player<B,E> 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<B,E> 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.
 void setMainFrame(MainFrame<B,E> 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.
 

Method Detail

setMainFrame

void setMainFrame(MainFrame<B,E> 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.

getLocalPlayer

Player<B,E> getLocalPlayer()
Returns the instance of your Player subclass that should be used in this game. Your implementation can return a more specific type. This is highly recommended as it will prevent you from having to do so much casting of the player type.


getPriorityQueue

PriorityQueue<B,E> getPriorityQueue()
Return the priority queue that you are using for the game. You will write two of these during the semester.


getScrollingX

int getScrollingX()
Tells the display class is this game has a scrolling background in the X direction. If this returns a value less than 1, then no scrolling will occur side-to-side. If it returns a positive value, then that many blocks will be displayed horizontally.

Returns:
This value tells the program how many squares across it should draw around the player. Return -1 for no scrolling.

getScrollingY

int getScrollingY()
Tells the display class is this game has a scrolling background in the Y direction. If this returns a value less than 1, then no scrolling will occur top-to-bottom. If it returns a positive value, then that many blocks will be displayed vertically.

Returns:
This value tells the program how many squares across it should draw around the player. Return -1 for no scrolling.

useDrawOptimization

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.

getMenuBar

javax.swing.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.


stopGame

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