|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectfang.GameLevel
public abstract class GameLevel
This class mimicks the GameLoop. Any game which extends GameLoop can be made to extend GameLevel instead and then can be incorporated into a multi-level game. See the examples on the FANG Engine website.
| Field Summary | |
|---|---|
protected AnimationCanvas |
canvas
the place where sprites are drawn. |
protected Random |
random
the random number generator use this generator for all random number in order to maintain consistency in multiplayer games. |
| Constructor Summary | |
|---|---|
GameLevel()
|
|
| Method Summary | |
|---|---|
abstract void |
advanceFrame(double timePassed)
This method is where the game logic will be applied. |
void |
cancelAlarm(Alarm alarm)
removes all pending alarms on this object. |
void |
cancelAllAlarms()
removes all pending alarms. |
void |
cleanUp()
this method will be called by the FANG Engine just before terminating the level in case the level needs an opportunity to perform some final operations |
void |
clearPersistence()
clears all peristent objects in this level from the collections of persistent objects |
void |
clearPersistence(Alarm alarm)
removes the alarm from the collection of alarms which will persist after the level ends. |
void |
clearPersistence(Sound sound)
removes the sound from the collection of sounds which will persist after the level ends. |
void |
clearPersistence(Sprite sprite)
removes the sprite from the collection of sprites which will persist after the level ends. |
protected void |
finishGame()
sets the game state to game over. |
void |
finishLevel()
finishes this level such that advanceFrame will not be called again. |
Alarm[] |
getAlarms()
gets the list of alarms scheduled to go off in the future. |
int |
getID()
gets the index of the current player. |
int |
getNumberOfPlayers()
gets the number of connected players in this game. |
Alarm[] |
getPersistentAlarms()
gets all the alarms which are set to persist after the level ends. |
Sound[] |
getPersistentSounds()
gets all the sounds which are set to persist after the level ends. |
Sprite[] |
getPersistentSprites()
gets all the sprites which are set to persist after the level ends. |
Player |
getPlayer()
gets the current player object. |
protected Player |
getPlayer(int playerIndex)
gets the player object for a given player number. |
protected Player |
getPlayer(String name)
gets the player object for a given player name. |
URL |
getResource(String filename)
loads a resource relative to the package of the game. |
double |
getTime()
gets the time in seconds since the game has started |
boolean |
imagesCached()
gets whether to clear the cached images or not. |
void |
initializePersistantState(Alarm[] alarms,
Sprite[] sprites,
Sound[] sounds)
copies all of the peristent alarms, sprites, and sounds into this level's persistence collections |
boolean |
isMuted()
returns true if muted, false if not muted |
boolean |
isPaused()
returns true if paused, false if the game is running |
boolean |
isPeristent(Alarm alarm)
indicates whether this alarm is part of the collection of alarms which will persist after the level terminates |
boolean |
isPeristent(Sound sound)
indicates whether this sound is part of the collection of sounds which will persist after the level terminates |
boolean |
isPeristent(Sprite sprite)
indicates whether this sprite is part of the collection of sprites which will persist after the level terminates |
void |
pauseToggle()
changes between paused and unpaused |
void |
persist(Alarm alarm)
adds an alarm to the collection of alarms which will persist after the level ends. |
void |
persist(Sound sound)
adds a sound to the collection of sounds which will persist after the level ends. |
void |
persist(Sprite sprite)
adds a sprite to the collection of sprites which will persist after the level ends. |
void |
postAdvanceFrame()
|
protected void |
removeLevelObjects()
removes all the non-persistent sprites, alarms, and sounds |
void |
resetTime()
makes the current time zero |
void |
scheduleAbsolute(Alarm alarm,
double absolute)
sets and alarm to go off at a time relative to the beginning of time (zero). |
void |
scheduleRelative(Alarm alarm,
double relative)
sets and alarm to go off relative to the current time. |
void |
sendMessage(Object localMessage)
sends a message to all of the clients |
void |
setCacheImages(boolean cacheImages)
sets whether to clear the cached images or not. |
void |
setCacheSounds(boolean cacheSounds)
sets whether to clear the cached sounds or not. |
void |
setGameLoop(GameLoop loop)
sets the GameLoop object this level will use to implement the majority of its methods. |
void |
setHelp(String help)
sets the help screen. |
void |
setNextLevel(GameLevel level)
sets the next level which will execute once this level has finished. |
boolean |
soundsCached()
gets whether to clear the cached sounds or not. |
abstract void |
startLevel()
starts the level. |
void |
startOver()
starts the game over. |
void |
startOverLevel()
begins this level again by the next advanceFrame |
void |
toggleAudible()
Deprecated. this method is depricated and should not be used; use toggleSound instead |
void |
toggleSound()
switches between mute and audible. |
String |
toString()
gets the name of this class |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected AnimationCanvas canvas
protected Random random
| Constructor Detail |
|---|
public GameLevel()
| Method Detail |
|---|
public void setCacheImages(boolean cacheImages)
cacheImages - true indicates the images currently in the cache should remain in
the cache, false means to clear them.public void setCacheSounds(boolean cacheSounds)
cacheSounds - true indicates the sounds currently in the cache should remain in
the cache, false means to clear them.public boolean imagesCached()
public boolean soundsCached()
public void initializePersistantState(Alarm[] alarms,
Sprite[] sprites,
Sound[] sounds)
alarms - the alarms which came from the last levelsprites - the sprites which came from the last levelsounds - the sounds which came from the last lelelpublic void setGameLoop(GameLoop loop)
loop - the GameLoop object of the main game@Deprecated public void toggleAudible()
public void toggleSound()
public boolean isMuted()
public void sendMessage(Object localMessage)
localMessage - a Serializable message which is sent to all clientspublic boolean isPaused()
public void pauseToggle()
public URL getResource(String filename)
filename - the name of the file
public abstract void startLevel()
public abstract void advanceFrame(double timePassed)
timePassed - the duration of time which has passed since the last frame was
calculated or displayed.public void postAdvanceFrame()
public void cleanUp()
protected final void finishGame()
protected void removeLevelObjects()
public void setNextLevel(GameLevel level)
level - the next levelpublic void finishLevel()
public String toString()
toString in class Objectpublic void startOverLevel()
public void persist(Alarm alarm)
alarm - the alarm to keep after the level terminatespublic void persist(Sprite sprite)
sprite - the sprite to keep after the level terminatespublic void persist(Sound sound)
sound - the sound to keep after the level terminatespublic void clearPersistence(Alarm alarm)
alarm - the alarm to remove from the persistent collectionpublic void clearPersistence(Sprite sprite)
sprite - the sprite to remove from the persistent collectionpublic void clearPersistence(Sound sound)
sound - the sound to remove from the persistent collectionpublic void clearPersistence()
public Alarm[] getPersistentAlarms()
public Sprite[] getPersistentSprites()
public Sound[] getPersistentSounds()
public int getNumberOfPlayers()
public int getID()
protected final Player getPlayer(int playerIndex)
playerIndex - the player number. See getNumberOfPlayers to determine how many
players are connected to this game.
protected final Player getPlayer(String name)
name - String name associated with the Player
public Player getPlayer()
public void scheduleRelative(Alarm alarm,
double relative)
alarm - the class to call the alarm method onrelative - the time from now in seconds to call the alarm method
public void scheduleAbsolute(Alarm alarm,
double absolute)
alarm - the class to call the alarm method onabsolute - the time in seconds to call the alarm methodpublic void cancelAlarm(Alarm alarm)
alarm - the object that is the target of a pending alarmpublic void cancelAllAlarms()
public Alarm[] getAlarms()
public boolean isPeristent(Alarm alarm)
alarm - the alarm to check
public boolean isPeristent(Sprite sprite)
sprite - the sprite to check
public boolean isPeristent(Sound sound)
sound - the alarm to check
public void startOver()
public void setHelp(String help)
help - the path to the html help screen which will be displayedpublic double getTime()
public void resetTime()
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||