#pragma once #include #include // Para shared_ptr #include // Para vector #include "utils/defines.hpp" class Surface; class Sprite; class TilemapRenderer { public: TilemapRenderer(std::vector tile_map, int tile_set_width, std::shared_ptr tileset_surface, Uint8 bg_color, int conveyor_belt_direction); ~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& collision_tile_map); void update(float delta_time); void render(); #ifdef _DEBUG void redrawMap(const std::vector& collision_tile_map); void setBgColor(Uint8 color) { bg_color_ = color; } void setTile(int index, int tile_value); #endif void setPaused(bool paused) { is_paused_ = paused; } [[nodiscard]] auto getMapSurface() const -> std::shared_ptr { return map_surface_; } private: struct AnimatedTile { std::shared_ptr sprite{nullptr}; int x_orig{0}; }; 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; static constexpr float CONVEYOR_FRAME_DURATION = 0.05F; static constexpr int COLLISION_ANIMATED = 6; // Valor del tile de conveyor en el collision tilemap std::vector tile_map_; int tile_set_width_; std::shared_ptr tileset_surface_; Uint8 bg_color_{0}; int conveyor_belt_direction_; std::shared_ptr map_surface_; std::vector animated_tiles_; float time_accumulator_{0.0F}; bool is_paused_{false}; void fillMapTexture(const std::vector& collision_tile_map); void setAnimatedTiles(const std::vector& collision_tile_map); void updateAnimatedTiles(); void renderAnimatedTiles(); };