|
LPCGame
A Simple 2d Game Engine
|
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< Tile > | mTiles |
| Recti | mBox |
| std::shared_ptr< TileSet > | mTileSet |
| std::string | mFile |
| Camera * | lastCamera |
| std::set< int > | indices |
Handles the tile map.
Takes care of a simple tile based map
| int Map::CalculateIndex | ( | int | x, |
| int | y, | ||
| int | w, | ||
| int | h | ||
| ) | const |
Calculate the index of the tile at the point
| x | The point's x coordinate |
| y | The point's y coordinate |
| Runtime | Error 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
| area | The area to get tile indices in |
| Runtime | error if the set is empty |
| void Map::Draw | ( | std::weak_ptr< Camera > | cam | ) |
Draw the tiles on the screen, relative to the camera
| cam | The 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
| val | The 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
| target | The target to get the nearby collision map around |
| distance | The distance in tiles to return the map of |
| void Map::Load | ( | Json::Value | val | ) |
Load the map from a Json::Value
| val | The Json::Value to load from |
| void Map::Load | ( | const std::string & | file | ) |
Load the map from another file
| file | The file to load the map from |
| Json::Value Map::Save | ( | ) |
Save the map data to a Json::Value