70 lines
1.6 KiB
C++
70 lines
1.6 KiB
C++
/********************\
|
|
| Copyright 2024, |
|
|
| Ulysse Cura |
|
|
\********************/
|
|
|
|
/////////////////////////////////////////////////////////////////////////
|
|
// //
|
|
// Declaration de la classe TileMap, elle sert a charger tout ce //
|
|
// qui est en rapport avec une map. (tileMap, entités, hitbox, etc...) //
|
|
// //
|
|
/////////////////////////////////////////////////////////////////////////
|
|
|
|
#ifndef MAP_HPP
|
|
#define MAP_HPP
|
|
|
|
#include <SDL2/SDL.h>
|
|
#include <string>
|
|
#include <unordered_map>
|
|
#include <vector>
|
|
#include "externLibs/nlohmann/json.hpp"
|
|
#include "Vector2D.hpp"
|
|
|
|
#define TILE_SIZE 16
|
|
#define TILEMAP_SCALE 2
|
|
|
|
using std::string, std::vector, std::unordered_map;
|
|
using json = nlohmann::json;
|
|
|
|
using TileID = int;
|
|
|
|
struct NextMap {
|
|
string path;
|
|
Vector2D<float> playerInitPos;
|
|
};
|
|
|
|
class TileMap {
|
|
public:
|
|
TileMap() = default;
|
|
~TileMap();
|
|
|
|
void LoadEntities(json *);
|
|
void LoadTileMap(const string &);
|
|
void LoadNextMap(int);
|
|
void LoadTileset(const string &);
|
|
void draw(int);
|
|
|
|
Vector2D<float> getPlayerInitPos();
|
|
|
|
int tileMapWidth, tileMapHeight;
|
|
int worldWidth, worldHeight;
|
|
|
|
vector<int> hitboxes;
|
|
|
|
private:
|
|
void m_draw(const vector<TileID> &);
|
|
|
|
vector<TileID> m_tilesLayer1;
|
|
vector<TileID> m_tilesLayer2;
|
|
vector<TileID> m_tilesLayer3;
|
|
|
|
int m_tilesetWidth, m_tilesetHeight;
|
|
SDL_Texture *m_tileset;
|
|
|
|
Vector2D<float> m_playerInitPos;
|
|
|
|
unordered_map<int, NextMap> m_nextMaps;
|
|
};
|
|
|
|
#endif
|