|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectGameCanvas
client.framework.views.GameView
public abstract class GameView
The class responsible for running the game and displaying the game board. Contains lists of objects to draw to the game board, as well methods for detecting collisions and handling movement. The class is also responsible for detecting in-game user inputs and handling these.
Field Summary | |
---|---|
protected TiledLayer |
background
|
protected int |
boardHeight
|
protected int |
boardWidth
|
protected LayerManager |
layerManager
|
protected AbstractGame |
model
|
Constructor Summary | |
---|---|
GameView(AbstractGame model)
Constructor for the GameView class . |
Method Summary | |
---|---|
void |
check()
Method called continously throughout a game. |
void |
checkInput()
Checks whether any keys have been pressed. |
protected abstract void |
clean()
Abstract method that should contain functionality for releasing occupied resources and resetting the game view's state. |
void |
commandAction(Command command,
Displayable displayable)
Method inherited from the CommandListener interface. |
protected abstract Image |
createBackgroundImage()
Abstract method that is used for defining the background of the game board. |
abstract java.lang.Object |
detectObjectCollision(AbstractPlayer player,
int[] movement)
This method is called continuously throughout the game in order to detect collisions with game objects other than players. |
protected AbstractPlayer |
detectPlayerCollision(AbstractPlayer mover,
int[] movement)
Detects whether the local player collides with any of the other players. |
protected int |
detectWallCollision(AbstractPlayer player,
int[] movement)
Checks whether the player collides with one of the four walls. |
void |
drawBoard(Graphics graphics)
Draws the game board with its objects on the middle of the mobile phone's screen. |
void |
fireBoardChanged()
Called whenever a change to the game board has been detected. |
int[] |
getSize()
Returns the size of the game board. |
abstract void |
handleObjectCollision(java.lang.Object collidesWith,
int[] movement)
This method is called whenever a collision with a game specific object is detected, and is responsible for handling this event. |
protected abstract void |
handlePlayerCollision(AbstractPlayer collidesWith,
int[] movement)
This method is called whenever a collision with another player is detected, and is responsible for handling this event. |
protected void |
initPlayers()
Initialises the players' sprites. |
boolean |
isRunning()
Checks whether a game is currently running. |
void |
notifyAboutPlayerAdded(AbstractPlayer player)
Adds the specified player to the game board. |
void |
removePlayer(AbstractPlayer player)
Removes the specified player from the game board. |
protected abstract void |
specialCheck()
Method called each time the check() method is
called. |
void |
startGame(int[] screenResolution)
Starts a new game with the specified size of the game board. |
void |
stopGame()
Stops the current game, and sets the running parameter to false. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected AbstractGame model
protected LayerManager layerManager
protected TiledLayer background
protected int boardWidth
protected int boardHeight
Constructor Detail |
---|
public GameView(AbstractGame model)
GameView class
.
Initialises the game objects, creates the game board and
initialises the commands.
model
- The underlying game model, which handles communication.Method Detail |
---|
public void fireBoardChanged()
public void check()
public int[] getSize()
public void checkInput()
check()
public void drawBoard(Graphics graphics)
graphics
- The GameCanvas
' Graphics
object.public void commandAction(Command command, Displayable displayable)
CommandListener
interface. This
method is called whenever the user selects a command displayed
at the bottom of the screen. In this implementation, the only
command available is "Exit", which returns the player to the
lobby.
command
- The command causing the method to be called.displayable
- The currently displayed screen.protected AbstractPlayer detectPlayerCollision(AbstractPlayer mover, int[] movement)
mover
- The player trying to perform the movement.movement
- The movement to take place.
protected void initPlayers()
Sprite
object, and places these on the game board
using the layerManager
object.
AbstractPlayer.getSprite()
protected abstract Image createBackgroundImage()
protected abstract void specialCheck()
check()
method is
called. This method should contain the game specific checks
that need to be performed as long as the game is running.
check()
protected abstract void handlePlayerCollision(AbstractPlayer collidesWith, int[] movement)
movement
parameter contains the move that will cause the collision if
it is carried out.
collidesWith
- The player with which a collision is detected.movement
- The move causing the collisiondetectPlayerCollision(client.framework.models.AbstractPlayer, int[])
public abstract void handleObjectCollision(java.lang.Object collidesWith, int[] movement)
movement
parameter contains the move that would cause the collision if
it is carried out.
collidesWith
- The object with which a collision is detected.movement
- The move causing the collision.detectObjectCollision(client.framework.models.AbstractPlayer, int[])
public abstract java.lang.Object detectObjectCollision(AbstractPlayer player, int[] movement)
player
- The player trying to movemovement
- The movement to take place.
protected int detectWallCollision(AbstractPlayer player, int[] movement)
player
- The player trying to movemovement
- The movement to take place
check()
public void removePlayer(AbstractPlayer player)
player
- The player to remove from the game board.public void notifyAboutPlayerAdded(AbstractPlayer player)
player
- The player to add to the game board.public void startGame(int[] screenResolution)
screenResolution
- An array containing the height and width of the game board.public boolean isRunning()
public void stopGame()
clean()
method to release occupied resources.
protected abstract void clean()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |