Motor de sprites/animacions/surfaces i jugador centrat (v0.2.0)

This commit is contained in:
JailDesigner committed 2026-04-18 21:02:55 +02:00
1 parent 7bb1edd08a
commit de5a670fdb
34 files changed
+16137 -81

No files matched your search

+18 -6
View File
@@ -3,26 +3,38 @@
#include <SDL3/SDL.h>
#include <cstdint>
#include <vector>
class Screen {
public:
static void init();
static void destroy();
static auto get() -> Screen*;
// Meyers singleton: la destrucció ocorre durant la termianció estàtica
// (LIFO respecte a Resource::Cache). El SDL_Quit s'ha de registrar via
// std::atexit ABANS de la primera crida a get(); així Screen::~Screen
// (que crida SDL_Destroy*/SDL_QuitSubSystem) s'executa amb SDL encara viu.
static auto get() -> Screen&;
Screen(const Screen&) = delete;
Screen(Screen&&) = delete;
auto operator=(const Screen&) -> Screen& = delete;
auto operator=(Screen&&) -> Screen& = delete;
void clear(std::uint8_t r = 0, std::uint8_t g = 0, std::uint8_t b = 0);
void present();
[[nodiscard]] auto getRenderer() const -> SDL_Renderer* { return renderer_; }
[[nodiscard]] auto getTarget() const -> SDL_Texture* { return game_texture_; }
[[nodiscard]] auto getCanvasArgb() -> std::uint32_t* { return canvas_.data(); }
[[nodiscard]] auto getCanvasWidth() const -> int { return canvas_width_; }
[[nodiscard]] auto getCanvasHeight() const -> int { return canvas_height_; }
private:
Screen();
~Screen();
static Screen* instance;
SDL_Window* window_{nullptr};
SDL_Renderer* renderer_{nullptr};
SDL_Texture* game_texture_{nullptr};
int canvas_width_{0};
int canvas_height_{0};
std::vector<std::uint32_t> canvas_;
};