org.deken.game.map
Class GameMap

java.lang.Object
  extended by org.deken.game.map.GameMap
All Implemented Interfaces:
Updateable
Direct Known Subclasses:
FreeStyleMap, TileMap

public abstract class GameMap
extends java.lang.Object
implements Updateable


Nested Class Summary
static class GameMap.QUEUE
           
 
Field Summary
protected  Background background
           
protected  CollisionMap collisionMap
           
protected  java.util.List<GComponent> components
           
protected  Layout layout
           
protected  MapRenderer mapRenderer
           
protected  MapSize mapSize
           
protected  java.util.Collection<Updateable> updateables
           
 
Constructor Summary
GameMap()
           
 
Method Summary
 void addComponents(GComponent gComponent)
          add a GameComponent to the map, which will be displayed on top of everything else.
abstract  void addSection(Section section, GameLocation gameLocation)
          Add a Section to the specified location.
abstract  void addSprite(Sprite sprite, GameLocation gameLocation)
          Add a sprite to the specified location.
abstract  Sprite addSpriteCopy(Sprite sprite, GameLocation gameLocation)
          Add a copy of the sprite to the specified location.
abstract  Decor addTile(Decor decor, GameLocation gameLocation)
          Add a Tile to the specified location.
abstract  Decor addTile(Decor decor, GameLocation gameLocation, boolean placeHolder, boolean nonTileCollision)
          Add a Tile to the specified location.
 void addUpdateable(Updateable updateable)
          Used for adding additional elements that are updateable.
 void clearQueueComponents()
           
 void draw(java.awt.Graphics2D graphics)
          Draws the GameMap, usually by using a MapRenderer.
 Actions getActions()
           
 Background getBackground()
           
 GComponent getComponentByName(java.lang.String name)
          Returns a component in the map by its name.
 java.util.Collection<GComponent> getComponents()
          Returns the list of all GameComponents.
 Layout getLayout()
           
 MapSize getMapSize()
           
 java.lang.String getName()
           
abstract  Actor getPlayer()
          Gets the player Sprite.
abstract  java.util.Collection<Sprite> getSprites()
          Returns the list of all moving sprites.
abstract  MapElement getTile(int x, int y, int z)
          Returns the MapElement at the map grid location.
 boolean removeComponent(GComponent component)
          Removes the specified GComponent from the map.
abstract  boolean removeSprite(Sprite sprite)
           
abstract  Decor removeTile(GameLocation gameLocation)
           
 void setBackground(Background background)
           
abstract  void setCollisionMap(CollisionMap collisionMap)
           
 void setLayout(Layout layout)
           
 void setMapRenderer(MapRenderer mapRenderer)
           
 void setMapSize(MapSize mapSize)
           
 void setName(java.lang.String name)
           
abstract  void setPlayer(Actor player, GameLocation gameLocation)
          Sets the player Sprite.
 void setScreenSize(int width, int height)
          Set the size of the screen.
protected  void setupPlayer(Actor player)
          If player is a KeyPollListener, add the
 void update(long elapseTime)
          Update the elements in the GameMap.
 void updateQueueComponent(GComponent gComponent, GameMap.QUEUE queue)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

background

protected Background background

mapSize

protected MapSize mapSize

updateables

protected java.util.Collection<Updateable> updateables

collisionMap

protected CollisionMap collisionMap

components

protected java.util.List<GComponent> components

layout

protected Layout layout

mapRenderer

protected MapRenderer mapRenderer
Constructor Detail

GameMap

public GameMap()
Method Detail

addComponents

public void addComponents(GComponent gComponent)
add a GameComponent to the map, which will be displayed on top of everything else.

Parameters:
gComponent -

addSection

public abstract void addSection(Section section,
                                GameLocation gameLocation)
Add a Section to the specified location. This method should be synchronized.

Parameters:
section - Section
gameLocation - GameLocation

addSprite

public abstract void addSprite(Sprite sprite,
                               GameLocation gameLocation)
Add a sprite to the specified location. This method should be synchronized.

Parameters:
sprite - Sprite
gameLocation - GameLocation

addSpriteCopy

public abstract Sprite addSpriteCopy(Sprite sprite,
                                     GameLocation gameLocation)
Add a copy of the sprite to the specified location. This method should be synchronized.

Parameters:
sprite - Sprite
gameLocation - GameLocation
Returns:
Sprite Returns the copied Sprite

addTile

public abstract Decor addTile(Decor decor,
                              GameLocation gameLocation)
Add a Tile to the specified location. This method should be synchronized.

Parameters:
decor - Decor
gameLocation - GameLocation
Returns:
Decor Returns the copied Decor

addTile

public abstract Decor addTile(Decor decor,
                              GameLocation gameLocation,
                              boolean placeHolder,
                              boolean nonTileCollision)
Add a Tile to the specified location. This method should be synchronized. If the tile is a placeHolder, it will not be rendered. If the tile is nonTileCollision, it will not be collided through normal tile collision, it will be added to the CollisionMap.

Parameters:
decor -
gameLocation -
placeHolder -
nonTileCollision -
Returns:
Decor

addUpdateable

public void addUpdateable(Updateable updateable)
Used for adding additional elements that are updateable.

Parameters:
updateable - Updateable

clearQueueComponents

public void clearQueueComponents()

draw

public void draw(java.awt.Graphics2D graphics)
Draws the GameMap, usually by using a MapRenderer. This method should be synchronized.

Parameters:
graphics - Graphics2D

getActions

public Actions getActions()

getBackground

public Background getBackground()

getComponents

public java.util.Collection<GComponent> getComponents()
Returns the list of all GameComponents.

Returns:
Collection

getComponentByName

public GComponent getComponentByName(java.lang.String name)
Returns a component in the map by its name. If it is not in the GameMap's component list, it will retrieve it from the Layout's component list.

Parameters:
name -
Returns:

getLayout

public Layout getLayout()

getMapSize

public MapSize getMapSize()
Returns:
MapSize

getName

public java.lang.String getName()
Specified by:
getName in interface Updateable
Returns:
String

getPlayer

public abstract Actor getPlayer()
Gets the player Sprite.

Returns:
Actor

getSprites

public abstract java.util.Collection<Sprite> getSprites()
Returns the list of all moving sprites.

Returns:
Collection

getTile

public abstract MapElement getTile(int x,
                                   int y,
                                   int z)
Returns the MapElement at the map grid location.

Parameters:
x - int
y - int
z - int
Returns:
MapElement

removeComponent

public boolean removeComponent(GComponent component)
Removes the specified GComponent from the map.

Parameters:
component -
Returns:
if the GComponent was removed or not.

removeSprite

public abstract boolean removeSprite(Sprite sprite)
Parameters:
sprite -
Returns:
sprite removed.

removeTile

public abstract Decor removeTile(GameLocation gameLocation)
Parameters:
gameLocation -
Returns:
Decor

setBackground

public void setBackground(Background background)
Parameters:
background -

setCollisionMap

public abstract void setCollisionMap(CollisionMap collisionMap)
Parameters:
collisionMap - CollisionMap

setLayout

public void setLayout(Layout layout)
Parameters:
layout -

setMapRenderer

public void setMapRenderer(MapRenderer mapRenderer)
Parameters:
mapRenderer - MapRenderer

setMapSize

public void setMapSize(MapSize mapSize)
Parameters:
mapSize - MapSize

setName

public void setName(java.lang.String name)
Parameters:
name - String

setPlayer

public abstract void setPlayer(Actor player,
                               GameLocation gameLocation)
Sets the player Sprite. This method should be synchronized.

Parameters:
player - Actor
gameLocation - GameLocation

setScreenSize

public void setScreenSize(int width,
                          int height)
Set the size of the screen. This can be adjustable.

Parameters:
width - int
height - int

update

public void update(long elapseTime)
Update the elements in the GameMap.

Specified by:
update in interface Updateable
Parameters:
elapseTime - long

updateQueueComponent

public void updateQueueComponent(GComponent gComponent,
                                 GameMap.QUEUE queue)

setupPlayer

protected void setupPlayer(Actor player)
If player is a KeyPollListener, add the

Parameters:
player -