Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members   Related Pages  

Map Class Reference

The game map can load itself from a file and draw itself. More...

#include <Map.h>

List of all members.

Public Methods

 Map ()
 Constructor.

 ~Map ()
 Destructor.

bool load (const char *fn)
 Load a map file.

void draw (const Point &pt, int scrWidth, int scrHeight)
 Draws the map around the specified point.

void draw (int scrWidth, int scrHeight, int cameraFlags)
 Draws the map around the specified Entity target that was set in the setCameraTarget method.

int getNumCameras () const
 Returns the number of cameras for this Map.

void setCameraTarget (const Entity *target, int camera)
 Sets the map's camera to look at the given target.

const TilegetTileAt (const Point &pt) const
 Returns the tile at the supplied point, which must be in the map (passes the !isLocationOutside test).

bool isLocationOutside (const TileLocation &loc) const
 Returns true if the given TileLocation is not on the map -- meaning it is not a valid tile coordinate.

bool isLocationOutside (const Point &pt) const
 Returns true if the given Point is not on the map -- meaning it is not a valid tile coordinate.

bool isLocationOutside (const Point3D &pt) const
 Returns true if the given Point is not on the map -- meaning it is not a valid tile coordinate.

bool isLocationOutside (const Rect &r) const
 Returns true if any point of the given Rect is off the map.

int getRectHeight (const Rect &r) const
 Returns the highest height on the map in the given Rect.

int getPointHeight (const Point &p) const
 Returns the height of the tile specified by the given point.

int getPointHeight (const Point3D &p) const
 Returns the height of the tile specified by the given point.

void addToRenderList (Drawable &obj)
 Adds the given object to the rendering list.

void clearRenderList ()
 Clears all Entities that were added to the render list.

int getMapLength () const
 Returns the length of the map.

int getMapWidth () const
 Returns the width of the map.

Point getStartingPoint ()
 Randomly selects one of the starting points specified in the map.

void addPowerups ()
 Adds the powerups in this map to the game.


Static Public Methods

Point getScreenTileOffset (const Point &pt, float startX, float startY)
 Given the point in map coordinates, returns the screen coordinate offset from the given startX and startY.


Static Public Attributes

const int CAMERA0 = 1
 Flag for the first camera.

const int CAMERA1 = 2
 Flag for the second camera.


Detailed Description

The game map can load itself from a file and draw itself.

A Map in Super IsoBomb consists of a rectangular grid of tiles each 1.0f wide and 1.0f tall. Specifing world coordinates in this way makes interpreting values easier, eliminates multiplations, and provides a very easy conversion from world coordinates into integer tile coordinates.

A Map can also render itself and all of the objects onto a screen. It supports two camera targets for split screen.


Constructor & Destructor Documentation

Map::Map  
 

Constructor.

Map::~Map  
 

Destructor.


Member Function Documentation

void Map::addPowerups  
 

Adds the powerups in this map to the game.

void Map::addToRenderList Drawable   obj
 

Adds the given object to the rendering list.

The given object must be inside of the map coordinates. The parameter "obj" is not modified, but must be mutable since the Drawable::draw method is allowed to be mutable.

Parameters:
obj  the object to add.

void Map::clearRenderList  
 

Clears all Entities that were added to the render list.

An Entity must be removed from the list before it can change map location.

void Map::draw int    scrWidth,
int    scrHeight,
int    cameraFlags
 

Draws the map around the specified Entity target that was set in the setCameraTarget method.

If a target is not set, the map is centered on the point 0, 0.

The cameraFlags parameter is constructed by bitwise ORing the flags for the cameras you want to show (CAMERA0, CAMERA1). If more than one camera is displayed, the given area is split up into different viewports.

See also:
draw( const Point&, int, int )
Parameters:
scrWidth  the width of the view window
scrHeight  the height of the view window
cameraFlags  which cameras to show

void Map::draw const Point   pt,
int    scrWidth,
int    scrHeight
 

Draws the map around the specified point.

Must be called between a Begin/End scene pair. All entities added to the render list are rendered with Entity::draw if their tile is on the screen. This version of draw ignores the camera target that was set with setCameraTarget.

Parameters:
pt  the point to center the map about
scrWidth  the width of the view window
scrHeight  the height of the view window

int Map::getMapLength  
 

Returns the length of the map.

Returns:
the length of the map

int Map::getMapWidth  
 

Returns the width of the map.

Returns:
the width of the map

int Map::getNumCameras  
 

Returns the number of cameras for this Map.

Currently returns 2.

int Map::getPointHeight const Point3D   p const
 

Returns the height of the tile specified by the given point.

The given point must be on the map (therefore it should pass the isLocationOutside test before this call.

int Map::getPointHeight const Point   p const
 

Returns the height of the tile specified by the given point.

The given point must be on the map (therefore it should pass the isLocationOutside test before this call.

int Map::getRectHeight const Rect   r const
 

Returns the highest height on the map in the given Rect.

The Rect's width and height must both be < 1.0 for this method to work properly.

Point Map::getScreenTileOffset const Point   pt,
float    startX,
float    startY
[static]
 

Given the point in map coordinates, returns the screen coordinate offset from the given startX and startY.

This implements isometric projection (2:1 ratio).

Point Map::getStartingPoint  
 

Randomly selects one of the starting points specified in the map.

Removes the selected point from the list to ensure that the same point isn't picked for both players.

Returns:
a starting point

const Tile * Map::getTileAt const Point   pt const
 

Returns the tile at the supplied point, which must be in the map (passes the !isLocationOutside test).

Parameters:
pt  the point of the desired Tile
Returns:
the Tile found

bool Map::isLocationOutside const Rect   r const
 

Returns true if any point of the given Rect is off the map.

bool Map::isLocationOutside const Point3D   pt const
 

Returns true if the given Point is not on the map -- meaning it is not a valid tile coordinate.

bool Map::isLocationOutside const Point   pt const
 

Returns true if the given Point is not on the map -- meaning it is not a valid tile coordinate.

bool Map::isLocationOutside const TileLocation   loc const
 

Returns true if the given TileLocation is not on the map -- meaning it is not a valid tile coordinate.

bool Map::load const char *    fn
 

Load a map file.

Parameters:
fn  the filename of the map file
Returns:
true if the file was loaded succesfully

void Map::setCameraTarget const Entity   target,
int    camera
 

Sets the map's camera to look at the given target.

Every time the renderer is called with the draw method, Map examines this Entity's position as information to center the view about.

You can pass NULL to the parameter target to unset the current camera target. A camera must have a target set in order to be rendered.

Map has several cameras (2 at this time). The camera parameter denotes which camera to set the target for. The first camera is camera 0, the second 1, and so on.


Member Data Documentation

const int Map::CAMERA0 = 1 [static]
 

Flag for the first camera.

const int Map::CAMERA1 = 2 [static]
 

Flag for the second camera.


The documentation for this class was generated from the following files:
Generated on Tue Mar 4 02:29:26 2003 for SuperIsoBomb by doxygen1.2.18