Building Game Engines
Map Class Reference

Define a gameobject map to render background image. More...

#include <Map.h>

Inheritance diagram for Map:
Inheritance graph
Collaboration diagram for Map:
Collaboration graph

Public Member Functions

 Map ()
 Constructor. More...
 
void Update (int x, int y, int *params) override
 Update the position of image in the map. More...
 
void Render (SDL_Renderer *ren) override
 Render the background image to the active viewport. More...
 
int * getTileArr ()
 Get current tile array. More...
 
void setEnemies (std::vector< GameObject * > &currEnemies)
 
void resetEnemies ()
 reset all active enemies to valid pos and plan new paths More...
 
void clearEnemies ()
 clear all active enemies (deactivate) More...
 
- Public Member Functions inherited from GameObject
 GameObject ()
 Constructor. More...
 
 ~GameObject ()
 Destructor. More...
 
virtual void processInput (SDL_Event e)
 Virtual method. Process user input. More...
 
void removeComponent (std::string key)
 Remove a component in this gameobject. More...
 
void addComponent (std::string key, Component *component)
 Add a component in this gameobject. More...
 
ComponentgetComponent (std::string key)
 Get an reference of a component. More...
 
void setActive (bool newState)
 activate / deactivate game object. inactive object won't be updated and rendered More...
 
bool isActive ()
 Get the state of the game. More...
 
int getID ()
 Get the unique id of the gameobject. More...
 

Additional Inherited Members

- Static Public Attributes inherited from GameObject
static int idCounter = 0
 
- Protected Attributes inherited from GameObject
std::map< std::string, Component * > m_components
 Store all the game components in a map. More...
 
bool objState
 deactivated objects won't get updated/rendered More...
 
int id
 the unique id More...
 

Detailed Description

Define a gameobject map to render background image.

Constructor & Destructor Documentation

◆ Map()

Map::Map ( )

Constructor.

Member Function Documentation

◆ clearEnemies()

void Map::clearEnemies ( )

clear all active enemies (deactivate)

◆ getTileArr()

int * Map::getTileArr ( )

Get current tile array.

Returns
Return an array.

◆ Render()

void Map::Render ( SDL_Renderer *  ren)
overridevirtual

Render the background image to the active viewport.

Parameters
renReference to SDL renderer.

Reimplemented from GameObject.

◆ resetEnemies()

void Map::resetEnemies ( )

reset all active enemies to valid pos and plan new paths

◆ setEnemies()

void Map::setEnemies ( std::vector< GameObject * > &  currEnemies)
inline

◆ Update()

void Map::Update ( int  x,
int  y,
int *  params 
)
overridevirtual

Update the position of image in the map.

Parameters
xThe x location of the background image.
yThe x location of the background image.
paramsAn int array stores additional data.

Reimplemented from GameObject.