LPCGame
A Simple 2d Game Engine
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
Map Class Reference

Handles the tile map. More...

#include <map.h>

Inherited by MapEditor.

Public Member Functions

void Draw (std::weak_ptr< Camera > cam)
 
void GenerateStressMap (Json::Value val)
 
int CalculateIndex (int x, int y, int w, int h) const
 
std::set< int > CalculateIndex (Recti area) const
 
CollisionMap GetCollisionMap (const Recti &target, int distance=2)
 
Recti Box () const
 Get the map's box.
 
void LoadTileSet (std::shared_ptr< TileSet > ts)
 Sets the tileset.
 
std::string File () const
 Get the map filename.
 
Json::Value Save ()
 
void Load (Json::Value val)
 
void Load (const std::string &file)
 

Protected Attributes

std::vector< TilemTiles
 
Recti mBox
 
std::shared_ptr< TileSetmTileSet
 
std::string mFile
 
CameralastCamera
 
std::set< int > indices
 

Detailed Description

Handles the tile map.

Takes care of a simple tile based map

Member Function Documentation

int Map::CalculateIndex ( int  x,
int  y,
int  w,
int  h 
) const

Calculate the index of the tile at the point

Parameters
xThe point's x coordinate
yThe point's y coordinate
Returns
The index of the tile at the point
Exceptions
RuntimeError if the point is off the map, must catch this
std::set< int > Map::CalculateIndex ( Recti  area) const

Calculate the indices of all the tiles within an area

Parameters
areaThe area to get tile indices in
Returns
A set of ints containing the tile indices
Exceptions
Runtimeerror if the set is empty
void Map::Draw ( std::weak_ptr< Camera cam)

Draw the tiles on the screen, relative to the camera

Parameters
camThe camera so we can get the offsets/check if things are in camera
void Map::GenerateStressMap ( Json::Value  val)

Generate a stress testing map with a specified number of tiles

Parameters
valThe Json::Value to load the stress test from
CollisionMap Map::GetCollisionMap ( const Recti target,
int  distance = 2 
)

Get the collision map within distance of the target

Parameters
targetThe target to get the nearby collision map around
distanceThe distance in tiles to return the map of
Returns
The collision map of local tiles
void Map::Load ( Json::Value  val)

Load the map from a Json::Value

Parameters
valThe Json::Value to load from
void Map::Load ( const std::string &  file)

Load the map from another file

Parameters
fileThe file to load the map from
Json::Value Map::Save ( )

Save the map data to a Json::Value

Returns
The map data as a Json::Value

The documentation for this class was generated from the following files: