Building Game Engines
|
#include <TileMap.hpp>
Public Member Functions | |
TileMap (SDL_Texture *texture, int rows, int cols, int _TileWidth, int _TileHeight, int _mapX, int _mapY) | |
~TileMap () | |
void | LoadMap (const char *filename) |
void | SaveMap (const char *filename) |
void | PrintMap () |
void | SetTile (int x, int y, int type) |
int | GetTileType (int x, int y) |
int | GetNumRows () |
int | GetNumCols () |
SDL_Rect | GetTileRect (int x, int y) |
virtual void | Render (SDL_Renderer *ren) |
virtual void | Update () |
![]() | |
Component () | |
virtual | ~Component ()=0 |
The Tile map for the game acts a component Evertything is based off the array m_tiles
TileMap::TileMap | ( | SDL_Texture * | texture, |
int | rows, | ||
int | cols, | ||
int | _TileWidth, | ||
int | _TileHeight, | ||
int | _mapX, | ||
int | _mapY | ||
) |
Consructor that takes in texture: The texture row: The total number of rows col: The total number of Cols _TileWidth: Whats the width of each tile _TileHeiht: Whats the height of the tile _mapx: How many Col _mapy: How many rows
TileMap::~TileMap | ( | ) |
Destructor Destruct the Tile map and make sure the nothing is left hanging
int TileMap::GetNumCols | ( | ) |
Returns the number of columns in the tile map
int TileMap::GetNumRows | ( | ) |
Returns the number of rows in the tile map
SDL_Rect TileMap::GetTileRect | ( | int | x, |
int | y | ||
) |
Returns an SDL_Rect with the dimensions of the tile at the given position This is based of x and y
int TileMap::GetTileType | ( | int | x, |
int | y | ||
) |
Returns the type of a tile at the given position Based of x and y given cords
void TileMap::LoadMap | ( | const char * | filename | ) |
Reads in the given file into the map array
void TileMap::PrintMap | ( | ) |
Prints out the array of tiles for debuging and vizuil assistance.
Prints the map to the console
|
virtual |
Renders all of the tiles in the tile map Uses the world Renderer
Implements Component.
void TileMap::SaveMap | ( | const char * | filename | ) |
Saves the current state of the tile map to a txt file with the given name, overwriting the file if it exists and making it if it doesnt
void TileMap::SetTile | ( | int | x, |
int | y, | ||
int | type | ||
) |
Allows for tiles to be set from outside the scope Does the math from x and y to find spot in array
Sets the type of a tile at the given position
|
virtual |
Does nothing Yet
Implements Component.