Annchienta::MapManager Class Reference

List of all members.

Public Member Functions

void cameraFollow (StaticObject *object)
void cameraPeekAt (StaticObject *object, bool instantly=false)
void draw () const
StaticObjectgetCameraFollow () const
int getCameraX () const
int getCameraY () const
MapgetCurrentMap () const
int getMaxAscentHeight () const
int getMaxDescentHeight () const
StaticObjectgetObject (const char *name)
int getTileHeight () const
int getTileWidth () const
int getUpdatesNeeded () const
bool isRunning () const
 MapManager ()
void renderFrame () const
void resync ()
void run ()
void setCameraX (int x)
void setCameraY (int y)
void setCurrentMap (Map *map)
void setMaxAscentHeight (int maxAscentHeight)
void setMaxDescentHeight (int maxDescentHeight)
void setNullMap ()
void setOnUpdateCode (const char *code)
void setOnUpdateScript (const char *filename)
void setTileHeight (int tileHeight)
void setTileWidth (int tileWidth)
void setUpdatesPerSecond (int)
void stop ()
void update (bool updateInput=true)
void updateOnce (bool updateInput=true)
 ~MapManager ()

Private Attributes

StaticObjectcameraTarget
int cameraX
int cameraY
MapcurrentMap
InputManagerinputManager
int maxAscentHeight
int maxDescentHeight
char * onUpdateCode
char * onUpdateScript
bool running
int tileHeight
int tileWidth
int updatesPerSecond


Constructor & Destructor Documentation

Annchienta::MapManager::MapManager (  ) 

Annchienta::MapManager::~MapManager (  ) 


Member Function Documentation

void Annchienta::MapManager::cameraFollow ( StaticObject object  ) 

Makes the camera smoothly follow object, until another object is set. If you don't want to follow any objects anymore, use cameraFollow(0).

void Annchienta::MapManager::cameraPeekAt ( StaticObject object,
bool  instantly = false 
)

Makes the camera have a quick peek at the provided object. Usually, this means the camera will move one step in the directioin of object. If you want to instantly peek at object, set instantly to true.

void Annchienta::MapManager::draw (  )  const

Draws the current Map to the screen.

StaticObject* Annchienta::MapManager::getCameraFollow (  )  const

Returns:
The object followed by the camera, see cameraFollow().

int Annchienta::MapManager::getCameraX (  )  const

Returns:
The current camera X offset.

int Annchienta::MapManager::getCameraY (  )  const

Returns:
The current camera Y offset.

Map* Annchienta::MapManager::getCurrentMap (  )  const

Returns:
A reference to the current Map.

int Annchienta::MapManager::getMaxAscentHeight (  )  const

Returns:
The max ascent height. See setMaxAscentHeight().

int Annchienta::MapManager::getMaxDescentHeight (  )  const

Returns:
The max descent height. See setMaxDescentHeight().

StaticObject* Annchienta::MapManager::getObject ( const char *  name  ) 

Searches the current Map for a StaticObject with the given name. This basically calls to Map::getObject().

int Annchienta::MapManager::getTileHeight (  )  const

Returns:
The current Tile height.

int Annchienta::MapManager::getTileWidth (  )  const

Returns:
The current Tile width.

int Annchienta::MapManager::getUpdatesNeeded (  )  const

bool Annchienta::MapManager::isRunning (  )  const

Polls if the game (the MapManager) is running.

void Annchienta::MapManager::renderFrame (  )  const

The same as draw()... both are kept for comptability issues.

void Annchienta::MapManager::resync (  ) 

Resynchronizes the timing. Some explanation:

Every time update() is called, the MapManager calls updateOnce() a number of times. When more time has passed since the last update, updateOnce() will be called more.

When, for example, you use a blocking function you wrote yourself that displays a text window, a lot of time will pass. This would mean that updateOnce() would be called hundreds of times.

In order to prevent this, call this function at the end of your function. That way, the number of updates will be reduced to a more fitting number.

void Annchienta::MapManager::run (  ) 

This function runs the MapManager. It should basically run your game. It does not return until the player quits the game.

void Annchienta::MapManager::setCameraX ( int  x  ) 

Sets the camera X offset. This can also be handled automatically by using cameraFollow() or cameraPeekAt().

void Annchienta::MapManager::setCameraY ( int  y  ) 

Sets the camera Y offset.

void Annchienta::MapManager::setCurrentMap ( Map map  ) 

Sets the current Map to be displayed, updated...

void Annchienta::MapManager::setMaxAscentHeight ( int  maxAscentHeight  ) 

Sets the maximum height the player can ascent during one step. If the height difference is larger than this value, the player will not be able to enter the Tile.

void Annchienta::MapManager::setMaxDescentHeight ( int  maxDescentHeight  ) 

Sets the maximum height the player can descent during one step. If the height difference is larger than this value, the player will not be able to enter the Tile.

void Annchienta::MapManager::setNullMap (  ) 

Sets a NullMap, which simply means no Map. I don't think anyone needs this, actually?

void Annchienta::MapManager::setOnUpdateCode ( const char *  code  ) 

Sets a piece of code that will be run every time updateOnce() is called.

void Annchienta::MapManager::setOnUpdateScript ( const char *  filename  ) 

Sets a script that will be run every time updateOnce() is called.

void Annchienta::MapManager::setTileHeight ( int  tileHeight  ) 

Sets the tileheight. You should call this before actually using the MapManager.

Parameters:
tileHeight The new Tile height.

void Annchienta::MapManager::setTileWidth ( int  tileWidth  ) 

Sets the tilewidth. You should call this before actually using the MapManager. Typically, you would use (64,32) or (32,16) for tileWidth and tileHeight.

Parameters:
tileWidth The new Tile width.

void Annchienta::MapManager::setUpdatesPerSecond ( int   ) 

Sets the number of times updateOnce() will be called per second. You usually do this before actually using the MapManager.

void Annchienta::MapManager::stop (  ) 

Stops the MapManager from running. You should call this on game over, when the player quits your game...

void Annchienta::MapManager::update ( bool  updateInput = true  ) 

Updates the MapManager. This calls to updateOnce a number of times, this number depends on the amount set by setUpdatesPerSecond() and the time passed since the last update.

Parameters:
updateInput If we should update the InputManager as well.

void Annchienta::MapManager::updateOnce ( bool  updateInput = true  ) 

Updates the MapManager a single time. This is mostly used internally. See update().


Member Data Documentation


Generated on Wed Feb 4 16:31:47 2009 for Annchienta by  doxygen 1.5.7.1