hgePolygonMap Class Reference

Container for polygons & entitys. More...

#include <hgePolygonMap.h>

List of all members.

Public Member Functions

bool SaveFile (std::string filename="MyFile.map")
bool LoadFile (std::string filename="MyFile.map")
std::vector< hgeEntity * > * GetDynamicEntityList (int m_renderlayer)
std::vector< hgeEntity * > * GetDynamicEntityList (std::string m_classname)
hgePolygonGetStaticEntityFromProperty (std::string m_pname, std::string m_pval)
hgePolygonGetDynamicEntityFromProperty (std::string m_pname, std::string m_pval)
void RegisterEntityClass (std::string entclass, hgeEntity *ent)
void SetTransform (hgeVector m_pos, float m_zoom=1)
hgeVector MapToScreen (hgeVector pos)
hgeVector ScreenToMap (hgeVector pos)
void AddDynamicEntity (hgeEntity *entity, bool initialize_entity=true)
void RemoveDynamicEntitys (std::string entity_class)
bool TestVisibility (hgePolygon *p, float padding=0)
hgePolygonTestPoint (hgeVector pos, int test_type=COLLIDE_STATIC, std::string class_filter="", int layer_filter=-1)
hgeIntersect Test (hgeShape *shape, hgeVector offset=hgeVector(0, 0), hgePolygon **return_poly=NULL, int test_type=COLLIDE_STATIC, std::string class_filter="", int layer_filter=-1)
hgeIntersect TestEx (hgeEntityEx *polygon, hgeVector offset=hgeVector(0, 0), float rot=0, hgePolygon **return_poly=NULL, int test_type=COLLIDE_STATIC, std::string class_filter="", int layer_filter=-1)
void Clear ()
void Update (float dt)
void Render ()
 hgePolygonMap (hgeVector m_viewSize=hgeVector(800, 600))


Detailed Description

The polygon map class acts as the center point of your game. It will handle rendering the map and your in-game entitys, updating & removing entitys, the camera, collision testing, and more!

Member Function Documentation

void hgePolygonMap::AddDynamicEntity ( hgeEntity entity,
bool  initialize_entity = true 
)

Manually Add a dynamic entity to the map after it has been loaded.

Parameters:
entity Pointer to an hgeEntity instance to add
Todo:
Write more about this function.

hgePolygon * hgePolygonMap::GetDynamicEntityFromProperty ( std::string  m_pname,
std::string  m_pval 
)

Returns a polygon pointer given a property & value in entity data.

Parameters:
m_pname Property name to check, eg "sprite"
m_pval Property value to check, eg "test.png"
Returns:
hgePolygon pointer
Remarks:
Uses a linear search across all dynamic entitys. Use sparingly.
See also:
hgeProperties

hgePolygon * hgePolygonMap::GetStaticEntityFromProperty ( std::string  m_pname,
std::string  m_pval 
)

Returns a polygon pointer given a property & value in entity data.

Parameters:
m_pname Property name to check, eg "sprite"
m_pval Property value to check, eg "test.png"
Returns:
hgePolygon pointer
Remarks:
Uses a linear search across all polygons. Use sparingly.
See also:
hgeProperties

bool hgePolygonMap::LoadFile ( std::string  filename = "MyFile.map"  ) 

Loads a map file.

Parameters:
filename Location of the map file to load, eg "maps/my_level.map".
Returns:
Returns false if map load failed.
Remarks:
If the map loads to fail the reason is written into the HGE log file.

Todo:
this could have an optional callback to a user defined RegisterEntity function

hgeVector hgePolygonMap::MapToScreen ( hgeVector  pos  ) 

Converts map coordinates to screen coordinates.

Parameters:
pos Vector in world coordinates.
Returns:
Vector in screen coordinates.
See also:
ScreenToMap

void hgePolygonMap::RegisterEntityClass ( std::string  entclass,
hgeEntity ent 
)

Links a hgeEntity derived class to a given classname.

Parameters:
entclass String containing the class name you wish to link the entity to.
ent Pointer to an instance of the class to link to the classname. The map will handle this pointer once registered.
Remarks:
example:
map->RegisterEntityClass("Player", new entPlayer() );
See also:
hgeEntity

void hgePolygonMap::RemoveDynamicEntitys ( std::string  entity_class  ) 

Removes dynamic entitys by their classname.

Parameters:
entity_class Class name to search for.
Remarks:
Great for removing groups of entitys. Entitys are deleted at the next safe opportunity.

void hgePolygonMap::Render (  ) 

Renders the map.

hgeVector hgePolygonMap::ScreenToMap ( hgeVector  pos  ) 

Converts screen coordinates to world coordinates.

Parameters:
pos Vector in screen coordinates.
Returns:
Vector in world coordinates.
See also:
MapToScreen

void hgePolygonMap::SetTransform ( hgeVector  m_pos,
float  m_zoom = 1 
)

Sets the cameras position & zoom over the map.

Parameters:
m_pos Camera position, in world coordinates.
m_zoom Camera zoom.
See also:
ScreeToMap() | MapToScreen()

hgeIntersect hgePolygonMap::Test ( hgeShape shape,
hgeVector  offset = hgeVector(0,0),
hgePolygon **  return_poly = NULL,
int  test_type = COLLIDE_STATIC,
std::string  class_filter = "",
int  layer_filter = -1 
)

Test the map & entitys for a collision with a given shape.

Parameters:
shape Pointer to a hgeShape derivative, eg a line, circle, or polygon
offset Vector specifying an offset to test the shape at
return_poly Pointer which is set to the polygon hit in the collision test
test_type Determines collision test type. Possible values are:
COLLIDE_STATIC - Tests the given shape against all static polygons.
COLLIDE_DYNAIC - Tests the given shape against dynamic entitys.
COLLIDE_MULTI - Tests for multiple collisions.

These parameters can be added together, eg COLLIDE_STATIC + COLLIDE_MULTIPLE
class_filter String specifying a specific classname of entity to test against
layer_filter Integer specifying a particular map layer to perform the collision test on
Returns:
hgeIntersect struct containing the collision details
Remarks:
The test_type should be carefully decided for the job at hand as it can result in slow performance with large arrays of dynamic entitys.
See also:
hgeIntersect

hgeIntersect hgePolygonMap::TestEx ( hgeEntityEx polygon,
hgeVector  offset = hgeVector(0,0),
float  rot = 0,
hgePolygon **  return_poly = NULL,
int  test_type = COLLIDE_STATIC,
std::string  class_filter = "",
int  layer_filter = -1 
)

Test the map & entitys for a collision with an hgeEntityEx, including an offset rotation.

Parameters:
shape Pointer to a hgeEntityEx derivative, eg a line, circle, or polygon
offset Vector specifying an offset to test the shape at
rot Float specifying an offset angle to test the shape at
return_poly Pointer which is set to the polygon hit in the collision test
test_type Determines collision test type. Possible values are:
COLLIDE_STATIC - Tests the given shape against all static polygons.
COLLIDE_DYNAIC - Tests the given shape against dynamic entitys.
COLLIDE_MULTI - Tests for multiple collisions.

These parameters can be added together, eg COLLIDE_STATIC + COLLIDE_MULTIPLE
class_filter String specifying a specific classname of entity to test against
layer_filter Integer specifying a particular map layer to perform the collision test on
Returns:
hgeIntersect struct containing the collision details
Remarks:
The test_type should be carefully decided for the job at hand as it can result in slow performance with large arrays of dynamic entitys.
See also:
hgeIntersect
Todo:
Test rotated polygons against dynamic entitys

hgePolygon * hgePolygonMap::TestPoint ( hgeVector  point,
int  test_type = COLLIDE_STATIC,
std::string  class_filter = "",
int  layer_filter = -1 
)

Finds polygon at specified point.

Parameters:
pos Point to test, in world coordinates.
test_type Determines collision test type. Possible values are:
COLLIDE_STATIC - Tests the given shape against all static polygons.
COLLIDE_DYNAIC - Tests the given shape against dynamic entitys.
COLLIDE_MULTI - Tests for multiple collisions.

These parameters can be added together, eg COLLIDE_STATIC + COLLIDE_MULTIPLE
class_filter String specifying a specific classname of entity to test against
layer_filter Integer specifying a particular map layer to perform the collision test on
Returns:
Returns polygon at point specified, or NULL
Remarks:
Does not support the COLLIDE_MULTI flag.

bool hgePolygonMap::TestVisibility ( hgePolygon p,
float  padding = 0 
)

Tests if a polygon is visible to the camera.

Parameters:
p Polygon to test
padding Padding value around the edges of the screen to add to the visibility test.
Returns:
True, if polygon is visible.

void hgePolygonMap::Update ( float  dt  ) 

Updates the map & entitys.

Parameters:
dt Delta time
Remarks:
Update is important to be called since it prepares an optimized set of visible data for the map to use
internally and on render.


Generated on Wed Apr 29 12:56:50 2009 for Opal by  doxygen 1.5.8