This class serves as a gameobject to edit, save or load tilemaps. More...
#include <TileMapEditor.hpp>
Public Member Functions | |
TileMapEditor ()=default | |
Default constructor. More... | |
~TileMapEditor ()=default | |
Default destructor. More... | |
void | processInput (SDL_Event e) override |
Process user input. More... | |
void | respondToInput (int mouseX, int mouseY, int clicked, int current_level) |
void | Render (SDL_Renderer *ren) override |
Render something to the active viewport. More... | |
void | Update (int x, int y, int *params) override |
Update something and then call Render() function. More... | |
void | SaveMap (const char *const fileName) |
Save tilemap to a local file. More... | |
void | SaveEnemy (const char *const fileName) |
Save enemies data to a local file. More... | |
void | LoadEnemy (const char *const fileName) |
Load enemies data from local file. More... | |
void | drawRightGrids (SDL_Renderer *renderer) |
Draw right grids. More... | |
void | drawLeftGrids (SDL_Renderer *renderer) |
Draw left grids. More... | |
void | getCurrentPath () |
Get current source file of the tilemap. More... | |
void | addEnemy (int row, int col, int id, int HP, bool isAct) |
Add enemy into the map. More... | |
std::vector< GameObject * > | getAllEnemies () |
Get all the enemies stored in the editor. More... | |
void | setPlayer (GameObject *player) |
Set the player in the editor. More... | |
void | setAvailableEnemies (std::vector< GameObject * > &enemies) |
Refresh enemies stored in the editor. More... | |
Public Member Functions inherited from GameObject | |
GameObject () | |
Constructor. More... | |
~GameObject () | |
Destructor. 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... | |
Component * | getComponent (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... | |
This class serves as a gameobject to edit, save or load tilemaps.
The properties in this class are inherited from the GameObject class and add some new functions to allow users to edit,save or load tilemaps. The left grids display all the available tiles and the right grids show the preview of the edited tilemap.
|
default |
Default constructor.
|
default |
Default destructor.
void TileMapEditor::addEnemy | ( | int | row, |
int | col, | ||
int | id, | ||
int | HP, | ||
bool | isAct | ||
) |
Add enemy into the map.
row | The row number of the enemy. |
col | The column number of the enemy. |
id | The id of the enemy. Mainly used when switching levels or load local enemy data. -1 when add enemy by using the tile map editor. |
HP | The amount of health points of this enemy. |
isAct | Whether this enemy should be active. |
void TileMapEditor::drawLeftGrids | ( | SDL_Renderer * | renderer | ) |
Draw left grids.
renderer | A structure that contains a rendering state. |
void TileMapEditor::drawRightGrids | ( | SDL_Renderer * | renderer | ) |
Draw right grids.
renderer | A structure that contains a rendering state. |
|
inline |
Get all the enemies stored in the editor.
void TileMapEditor::getCurrentPath | ( | ) |
Get current source file of the tilemap.
void TileMapEditor::LoadEnemy | ( | const char *const | fileName | ) |
Load enemies data from local file.
fileName | The file name. |
|
overridevirtual |
Process user input.
e | A SDL_Event that contains structures for the different event types. |
Reimplemented from GameObject.
|
overridevirtual |
Render something to the active viewport.
ren | Reference to SDL renderer. |
Reimplemented from GameObject.
void TileMapEditor::respondToInput | ( | int | mouseX, |
int | mouseY, | ||
int | clicked, | ||
int | current_level | ||
) |
void TileMapEditor::SaveEnemy | ( | const char *const | fileName | ) |
Save enemies data to a local file.
fileName | The file name. |
void TileMapEditor::SaveMap | ( | const char *const | fileName | ) |
Save tilemap to a local file.
fileName | The file name of the edited tilemap. |
|
inline |
Refresh enemies stored in the editor.
enemies | The new gameobject vector contains all the enemies. |
|
inline |
Set the player in the editor.
player | New player object. |
|
overridevirtual |
Update something and then call Render() function.
x | An int variable. |
y | An int variable. |
params | A dynamic array to store multiple int values. |
Reimplemented from GameObject.