phoenix::PhTileMap Class Reference

Tile map. More...

#include <PhTileMap.h>

Inheritance diagram for phoenix::PhTileMap:

phoenix::PhSceneNode

List of all members.

Public Member Functions

 PhTileMap (PhSceneManager *sc, PhVector2d s, PhVector2d ts, PhTexture *t, float d=-100.0f)
 Construct.
virtual ~PhTileMap ()
 Destruct.
void setTile (int x, int t)
 Set tile.
void setTile (PhVector2d pos, int t)
 Set tile.
int getTile (int x)
 Get tile.
int getTile (PhVector2d pos)
 Get tile.
void setMapSize (PhVector2d s)
 Set map size.
PhVector2d getMapSize ()
 Get map size.
void setTileSize (PhVector2d s)
 Set tile size.
PhVector2d getTileSize ()
 Get tile size.
void setTexture (PhTexture *t)
 Set texture.
PhTexturegetTexture ()
 Get texture.
void saveMap (string f)
 Save map.
void loadMap (string f)
 Load map.
void onRender ()
 Render call.
void onPreRender ()
 Pre-render call.
void onPostRender ()
 Post-render call.

Protected Member Functions

void allocateTiles ()
 Allocates the map vector.

Protected Attributes

vector< int > map
 Stores the values of the tiles.
PhVector2d tilesize
 Stores the size of each tile (in pixels).
PhVector2d tilemapsize
 Stores the size of the map itself (in tiles).
PhTexturetexture
 Texture that is used to peice together the map.
PhSceneManagersmgr
 Pointer to the scene manager.


Detailed Description

Tile map.

A simple yet highly effective tilemap scene node. Once it is created it's self-contained. The scene manager takes care of rendering it, all you really have to do is create the map and load it.


Constructor & Destructor Documentation

phoenix::PhTileMap::PhTileMap ( PhSceneManager sc,
PhVector2d  s,
PhVector2d  ts,
PhTexture t,
float  d = -100.0f 
)

Construct.

Builds a tilemap scene node.

Parameters:
sc Pointer to the scene manager.
s Size of the tilemap (in tiles).
ts Size of each tile in the tilemap (in pixels).
t Texture where the tiles will come from.
d Depth of the tile map (default -100.0f).


Member Function Documentation

void phoenix::PhTileMap::setTile ( int  x,
int  t 
)

Set tile.

Sets the tile at the given index to the given value.

Parameters:
x Index of the tile.
t New value of the tile.
See also:
getTile()

void phoenix::PhTileMap::setTile ( PhVector2d  pos,
int  t 
)

Set tile.

Sets the tile at the given position to the given value.

Parameters:
pos The position of the tile, ie <2,2> is the second tile from the top, second tile from the left.
t The new value of the tile.
See also:
getTile()

int phoenix::PhTileMap::getTile ( int  x  ) 

Get tile.

Parameters:
x Index of the tile.
Returns:
The value of the tile at index X.
See also:
setTile()

int phoenix::PhTileMap::getTile ( PhVector2d  pos  ) 

Get tile.

Parameters:
pos Position of the tile.
Returns:
The value of the tile at the given position.
See also:
setTile()

void phoenix::PhTileMap::setMapSize ( PhVector2d  s  ) 

Set map size.

Parameters:
s The new size of the map, in tiles.
See also:
getMapSize()

PhVector2d phoenix::PhTileMap::getMapSize (  ) 

Get map size.

Returns:
The size of the map, in tiles.
See also:
setMapSize()

void phoenix::PhTileMap::setTileSize ( PhVector2d  s  ) 

Set tile size.

Parameters:
s The new size of the tiles, in pixels.
See also:
getTileSize()

PhVector2d phoenix::PhTileMap::getTileSize (  ) 

Get tile size.

Returns:
The size of the tiles, in pixels.
See also:
setTileSize()

void phoenix::PhTileMap::setTexture ( PhTexture t  ) 

Set texture.

Parameters:
t The new tile sheet texture.
See also:
getTexture()

PhTexture* phoenix::PhTileMap::getTexture (  ) 

Get texture.

Returns:
The tile sheet texture.
See also:
setTexture()

void phoenix::PhTileMap::saveMap ( string  f  ) 

Save map.

Saves the current tilemap to a file.
File format information:
first four bytes are the x of the mapsize.
second four bytes are the y of the mapsize.
third set of bytes is the x of the tilesize.
fourth set of bytes is the y of the tilesize.
remaining bytes each contain one tile.

Parameters:
f Filename to save it to.
See also:
loadMap()

void phoenix::PhTileMap::loadMap ( string  f  ) 

Load map.

Loads a tilemap from a file.

Parameters:
f The filename to load from.
See also:
saveMap()

void phoenix::PhTileMap::onRender (  )  [virtual]

Render call.

Any nodes that called phoenix::PhSceneManger::registerForRendering() will first be sorted according to their depth, then this function is called for each node in order. It is highly suggested that you put any drawing code in this function. Of course, it's possible to draw during any of the three node passes, but this pass is the only one that is exclusive (Nodes must register) and is the only one that is depth sorted.

Reimplemented from phoenix::PhSceneNode.

void phoenix::PhTileMap::onPreRender (  )  [virtual]

Pre-render call.

All nodes in the list will have this function called by the scenemanger once per frame. Overloading this is required. If the scene node wants to be drawn it must call phoenix::PhSceneManger::registerForRendering().

Reimplemented from phoenix::PhSceneNode.

void phoenix::PhTileMap::onPostRender (  )  [inline, virtual]

Post-render call.

The third render pass takes place at the end of every frame, the scene manager calls this function for every node in the list, and any code that should happen after everything is drawn should go here.

Reimplemented from phoenix::PhSceneNode.


The documentation for this class was generated from the following file:
Generated on Tue Nov 20 21:59:25 2007 for Phoenix by  doxygen 1.5.4