Motor de sprites/animacions/surfaces i jugador centrat (v0.2.0)
This commit is contained in:
1 parent
7bb1edd08a
commit
de5a670fdb
34 files changed
+16137
-81
No files matched your search
@@ -0,0 +1,40 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "core/resources/resource_types.hpp"
|
||||
|
||||
namespace Resource {
|
||||
|
||||
// Cache mínim per a la fase 2: només surfaces i animacions, càrrega
|
||||
// explícita per nom + path. Per ara la cerca és lineal sobre vector.
|
||||
// Meyers singleton: la destrucció estàtica només toca smart pointers, no
|
||||
// depén d'SDL ni de Screen, així que és segura sense ordenació explícita.
|
||||
class Cache {
|
||||
public:
|
||||
static auto get() -> Cache&;
|
||||
|
||||
Cache(const Cache&) = delete;
|
||||
Cache(Cache&&) = delete;
|
||||
auto operator=(const Cache&) -> Cache& = delete;
|
||||
auto operator=(Cache&&) -> Cache& = delete;
|
||||
|
||||
// Carrega una surface des de fitxer i la registra amb el nom donat.
|
||||
void loadSurface(const std::string& name, const std::string& file_path);
|
||||
// Llig el YAML d'animació en cru i el registra amb el nom donat.
|
||||
void loadAnimation(const std::string& name, const std::string& file_path);
|
||||
|
||||
auto getSurface(const std::string& name) -> std::shared_ptr<Surface>;
|
||||
auto getAnimationData(const std::string& name) -> const AnimationResource&;
|
||||
|
||||
private:
|
||||
Cache() = default;
|
||||
~Cache() = default;
|
||||
|
||||
std::vector<SurfaceResource> surfaces_;
|
||||
std::vector<AnimationResource> animations_;
|
||||
};
|
||||
|
||||
} // namespace Resource
|
||||
Reference in new issue
Block a user