Files
projecte_2026/source/game/gameplay/tilemap_renderer.hpp

51 lines
1.5 KiB
C++

#pragma once
#include <SDL3/SDL.h>
#include <memory> // Para shared_ptr
#include <vector> // Para vector
#include "utils/defines.hpp"
class Surface;
class TilemapRenderer {
public:
TilemapRenderer(std::vector<int> tile_map, int tile_set_width, std::shared_ptr<Surface> tileset_surface, Uint8 bg_color);
~TilemapRenderer() = default;
TilemapRenderer(const TilemapRenderer&) = delete;
auto operator=(const TilemapRenderer&) -> TilemapRenderer& = delete;
TilemapRenderer(TilemapRenderer&&) = delete;
auto operator=(TilemapRenderer&&) -> TilemapRenderer& = delete;
void initialize(const std::vector<int>& collision_tile_map);
void update(float delta_time);
void render();
#ifdef _DEBUG
void redrawMap(const std::vector<int>& collision_tile_map);
void setTile(int index, int tile_value);
#endif
void setPaused(bool paused) { is_paused_ = paused; }
[[nodiscard]] auto getMapSurface() const -> std::shared_ptr<Surface> { return map_surface_; }
private:
static constexpr int TILE_SIZE = Tile::SIZE;
static constexpr int MAP_WIDTH = Map::WIDTH;
static constexpr int MAP_HEIGHT = Map::HEIGHT;
static constexpr int PLAY_AREA_WIDTH = PlayArea::WIDTH;
static constexpr int PLAY_AREA_HEIGHT = PlayArea::HEIGHT;
std::vector<int> tile_map_;
int tile_set_width_;
std::shared_ptr<Surface> tileset_surface_;
Uint8 bg_color_{0};
std::shared_ptr<Surface> map_surface_;
bool is_paused_{false};
void fillMapTexture(const std::vector<int>& collision_tile_map);
};