Building Game Engines
Public Member Functions | List of all members
TileMap Class Reference

#include <TileMap.hpp>

Inheritance diagram for TileMap:
Inheritance graph
Collaboration diagram for TileMap:
Collaboration graph

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 ()
 
- Public Member Functions inherited from Component
 Component ()
 
virtual ~Component ()=0
 

Detailed Description

The Tile map for the game acts a component Evertything is based off the array m_tiles

Constructor & Destructor Documentation

◆ TileMap()

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::~TileMap ( )

Destructor Destruct the Tile map and make sure the nothing is left hanging

Member Function Documentation

◆ GetNumCols()

int TileMap::GetNumCols ( )

Returns the number of columns in the tile map

◆ GetNumRows()

int TileMap::GetNumRows ( )

Returns the number of rows in the tile map

◆ GetTileRect()

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

◆ GetTileType()

int TileMap::GetTileType ( int  x,
int  y 
)

Returns the type of a tile at the given position Based of x and y given cords

◆ LoadMap()

void TileMap::LoadMap ( const char *  filename)

Reads in the given file into the map array

Here is the call graph for this function:

◆ PrintMap()

void TileMap::PrintMap ( )

Prints out the array of tiles for debuging and vizuil assistance.

Prints the map to the console

◆ Render()

void TileMap::Render ( SDL_Renderer *  ren)
virtual

Renders all of the tiles in the tile map Uses the world Renderer

Implements Component.

Here is the call graph for this function:

◆ SaveMap()

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

Here is the call graph for this function:

◆ SetTile()

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

◆ Update()

void TileMap::Update ( )
virtual

Does nothing Yet

Implements Component.


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