|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectJTP.GamePlayer
public class GamePlayer
Defines function and rendering of the gameplay component.
Field Summary | |
---|---|
static int |
AUTOSTART
|
static int |
COOP
Cooperative two player mode |
static int |
CUSTOM_DEATH_MESSAGE_LEVEL
|
static int |
DOWN
|
static int |
FINISHED_LEVEL
|
static int |
FINISHED_SET
|
static int |
GAMEOVER
|
static int |
INVALID_MOVE
|
static int |
LEFT
|
static int |
LIFE_LOST
|
static int |
LOAD_CANCELLED
loadLevelSet method return value |
static int |
LOAD_NOT2P
loadLevelSet method return value |
static int |
LOAD_OK
loadLevelSet method return value |
static int |
MEDIAMERGE_LEVEL
|
static int |
MOVED
|
static int |
NONE
|
static int |
NUMBERED_LEVEL
|
static int |
P1
ID of first player |
static int |
P2
ID of second player |
static int |
QUIT
|
static int |
RESET
|
static int |
RIGHT
|
static int |
SINGLE
Single player mode |
static int |
SKIPPED_LEVEL
|
static int |
UP
|
static int |
VS
Versus two player mode |
static int |
VS_CHOOSE
Versus mode with choice between simulatenous and alternate modes |
static int |
VS_TURN_BASED
Versus alternate two player mode |
Constructor Summary | |
---|---|
GamePlayer(Images imgData,
ScreenFrames frames,
TilePainter tPainter,
Color txtColor,
Font txtFont,
int stringSpacing,
int numSpacing,
Graphics2D g,
String lvlSetFilename,
String beepSoundName,
SplashMessage message,
Screen screen)
Creates a new GamePlayer instance with the given attributes |
Method Summary | |
---|---|
void |
activateMediaMerge()
Indicate that the MediaMerge tile should be shown in this levelset. |
void |
activateTestMode()
Indicate that the editor originating test mode is active Note: This is reset each time a new levelset is loaded |
boolean |
automaticMovesLeft()
Returns true if there are any automatic moves left |
int |
clickResult(int button)
Indicate a mouse button has been pressed. |
int |
currentFrameMode()
Returns what borders (frames) are being rendered |
void |
draw(Graphics2D g)
Depending on situation this will either render only the timer (i.e. |
void |
drawAll(Graphics2D g)
|
void |
enableUnlocking()
Indicate that this levelset's levels have to be unlocked Note: Unlock status is reset each time a new levelset is loaded |
int |
gameMode()
Returns the currently set game mode |
int |
getGameMode()
Returns the current game mode |
protected LevelSet |
getLevelSet()
Returns the active levelset |
int |
getScore()
Returns total score up to now Note: Scoring status is reset each time a new levelset is loaded |
int |
getState()
Returns the current game state (e.g. |
boolean |
levelHasNotStarted()
Checks whether the level has been started |
void |
loadLevelSet(String filename,
Graphics2D g)
Loads a levelset from a file. |
int |
loadLevelSet(String filename,
int gameMode,
Component c,
Graphics2D g)
Loads a levelset from a file with the specified game mode. |
int |
loadLevelSet(URL fileURL,
Graphics2D g)
Loads a levelset from the given location |
int |
loadLevelSet(URL fileURL,
int gameMode,
Component c,
Graphics2D g)
Loads a levelset from a location with the specified game mode. |
int |
performMoves(int keyP1,
int keyP2)
Moves one or both players (or executes control command, e.g. |
void |
revokeMediaMergeTile()
Indicate that the MediaMerge tile should not be used anymore |
boolean |
scoringEnabled()
Indicates whether scoring is turned on Note: Scoring status is reset each time a new levelset is loaded |
void |
setLevel(int index)
Choose which level to play |
void |
setLevelSet(LevelSet ls,
int gameMode,
boolean score,
Graphics2D g)
Loads a levelset straight from its native format. |
void |
setLives(int amount,
Graphics2D g)
Sets number of lives player has at beginning of levelset. |
void |
stopAndToggleTimer()
Like in chess - stops one timer and activates it for the other player |
boolean |
testModeActive()
Checks whether the (editor) test mode is on |
void |
unpauseTimer()
|
void |
updateState(boolean requestMessages)
|
boolean |
updateUI(Point mouseLocation)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int SINGLE
public static final int COOP
public static final int VS
public static final int VS_TURN_BASED
public static final int VS_CHOOSE
public static final int LOAD_OK
loadLevelSet
method return value
public static final int LOAD_NOT2P
loadLevelSet
method return value
public static final int LOAD_CANCELLED
loadLevelSet
method return value
public static final int NONE
public static final int UP
public static final int DOWN
public static final int LEFT
public static final int RIGHT
public static final int AUTOSTART
public static final int MOVED
public static final int GAMEOVER
public static final int FINISHED_SET
public static final int FINISHED_LEVEL
public static final int INVALID_MOVE
public static final int LIFE_LOST
public static final int RESET
public static final int QUIT
public static final int SKIPPED_LEVEL
public static final int MEDIAMERGE_LEVEL
public static final int NUMBERED_LEVEL
public static final int CUSTOM_DEATH_MESSAGE_LEVEL
public static final int P1
public static final int P2
Constructor Detail |
---|
public GamePlayer(Images imgData, ScreenFrames frames, TilePainter tPainter, Color txtColor, Font txtFont, int stringSpacing, int numSpacing, Graphics2D g, String lvlSetFilename, String beepSoundName, SplashMessage message, Screen screen) throws NullPointerException, IllegalArgumentException, IOException
GamePlayer
instance with the given attributes
imgData
- global image resourcesframes
- for drawing borders and backgroundtPainter
- for drawing tilestxtColor
- colour of all text (except tile numbers)txtFont
- style used for all text (except tile numbers)stringSpacing
- vertical spacing (in pixels) between text elementsnumSpacing
- horizontal spacing (in pixels from left) for status
numbers (e.g. lives left)g
- graphics context for drawinglvlSetFilename
- levelset to initially load (in single player mode),
can also be set to null
if a levelset is to be loaded laterbeepSoundName
- full path to countdown "beep" soundmessage
- popup message handlerscreen
- parent component
NullPointerException
IllegalArgumentException
IOException
Method Detail |
---|
public void loadLevelSet(String filename, Graphics2D g) throws IOException
filename
- absolute path to levelset fileg
- graphics context for drawing
IOException
public int loadLevelSet(String filename, int gameMode, Component c, Graphics2D g) throws IOException, IllegalArgumentException
filename
- absolute path to levelset filegameMode
- e.g. SINGLE
c
- parent component for drawing dialogsg
- graphics context for drawing
LOAD_OK
IOException
IllegalArgumentException
public int loadLevelSet(URL fileURL, Graphics2D g) throws IOException
fileURL
- absolute location of levelset fileg
- graphics context for drawing
LOAD_OK
IOException
public int loadLevelSet(URL fileURL, int gameMode, Component c, Graphics2D g) throws IOException, IllegalArgumentException, NullPointerException
fileURL
- absolute path to levelset filegameMode
- e.g. SINGLE
c
- parent component for drawing dialogsg
- graphics context for drawing
LOAD_OK
IOException
IllegalArgumentException
NullPointerException
protected LevelSet getLevelSet()
public void enableUnlocking()
public boolean scoringEnabled()
true
is scoring system it turned onpublic int gameMode()
SINGLE
public int getScore()
0
public void setLevel(int index)
index
- the level numberpublic void setLevelSet(LevelSet ls, int gameMode, boolean score, Graphics2D g) throws NullPointerException, IllegalArgumentException
ls
- the levelset to loadgameMode
- e.g. SINGLE
score
- whether to enable scoring or notg
- graphics context to use for drawing
NullPointerException
IllegalArgumentException
public int performMoves(int keyP1, int keyP2)
public boolean automaticMovesLeft()
public void stopAndToggleTimer()
public void unpauseTimer()
public void updateState(boolean requestMessages)
public boolean updateUI(Point mouseLocation)
public int clickResult(int button)
updateUIb
first to set the correct mouse location.
button
- the mouse button
QUIT
if the close button has been pressedpublic int getState()
GAMEOVER
)
public boolean levelHasNotStarted()
true
if the level has been startedpublic void activateMediaMerge()
public void revokeMediaMergeTile()
public void activateTestMode()
public boolean testModeActive()
true
if test mode is activepublic int getGameMode()
SINGLE
public void setLives(int amount, Graphics2D g) throws IllegalArgumentException
amount
- number of lives to give one or both playersg
- graphics context to use for rendering
IllegalArgumentException
public void draw(Graphics2D g)
GameTimer
instance has requested a refresh) or everything
public void drawAll(Graphics2D g)
public int currentFrameMode()
ScreenFrames
class for possible return values
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |