Game Engine 2D Platformer
Public Member Functions | List of all members
TileMap Class Reference

TileMap class is used to create and generate a map. More...

#include <TileMap.hpp>

Public Member Functions

 TileMap (std::string tileSheetFileName, std::string _TileMapPath, int levelWidth, int levelHeight, int _TileSize, SDL_Renderer *ren)
 Constuctor for a TileMap. Takes in a file path for a tile sheet, file for tile map path, level width, level height, tile size, and a renderer. More...
 
 ~TileMap ()
 Destructor for a tilemap. More...
 
void GenerateSimpleMap (std::vector< int > &collectablesAvailable)
 Temporary function for generating a simple map to display some tiles. More...
 
void PrintMap ()
 Function for printing text to console. More...
 
void SetTile (int x, int y, int type)
 Set the 'type' of tile at an x and y position. More...
 
int GetTileType (int x, int y)
 Return the tile type at an x and y position. More...
 
void Render (SDL_Renderer *ren, int x, std::vector< std::shared_ptr< GameEntity >> &obstacles, std::shared_ptr< GameEntity > mainCharacter)
 Draw all of the tiles in the tilemap. More...
 
void setTileSheetMap (int width, int height)
 Helper function to set the tMap i.e. More...
 
std::vector< int > getEnemyData ()
 

Detailed Description

TileMap class is used to create and generate a map.

Constructor & Destructor Documentation

◆ TileMap()

TileMap::TileMap ( std::string  tileSheetFileName,
std::string  _TileMapPath,
int  levelWidth,
int  levelHeight,
int  _TileSize,
SDL_Renderer *  ren 
)

Constuctor for a TileMap. Takes in a file path for a tile sheet, file for tile map path, level width, level height, tile size, and a renderer.

Parameters
std::stringtileSheetFileName
std::string_TileMapPath
intlevelWidth
intlevelHeight
int_TileSize
SDL_Rendererren

◆ ~TileMap()

TileMap::~TileMap ( )

Destructor for a tilemap.

Member Function Documentation

◆ GenerateSimpleMap()

void TileMap::GenerateSimpleMap ( std::vector< int > &  collectablesAvailable)

Temporary function for generating a simple map to display some tiles.

Helper function to generate a simple map and collectables array.

◆ getEnemyData()

std::vector< int > TileMap::getEnemyData ( )

◆ GetTileType()

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

Return the tile type at an x and y position.

Gets tile type.

Parameters
intx
inty

◆ PrintMap()

void TileMap::PrintMap ( )

Function for printing text to console.

Helper function to print out the tile map to the console.

◆ Render()

void TileMap::Render ( SDL_Renderer *  ren,
int  xPos,
std::vector< std::shared_ptr< GameEntity >> &  obstacles,
std::shared_ptr< GameEntity mainCharacter 
)

Draw all of the tiles in the tilemap.

Renders tiles on a screen.

Parameters
SDL_Rendererren
intxPos
std::vector<GameEntity*> &obstacles
GameEntity*mainCharacter

◆ SetTile()

void TileMap::SetTile ( int  x,
int  y,
int  type 
)

Set the 'type' of tile at an x and y position.

Sets a tile a certain type.

Parameters
intx
inty
inttype

◆ setTileSheetMap()

void TileMap::setTileSheetMap ( int  width,
int  height 
)

Helper function to set the tMap i.e.

Sets values of tile sheet into a map.

TileMap for reverse look-up in the Tile Atlas

Parameters
intwidth
intheight

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