galaxy 1.0.0
Real-Time C++23 Game Programming Framework. Built on data-driven design principles and agile software engineering.
Loading...
Searching...
No Matches
TileMap.cpp
Go to the documentation of this file.
1
7
8#include "galaxy/core/ServiceLocator.hpp"
10
11#include "TileMap.hpp"
12
13namespace galaxy
14{
15 namespace components
16 {
18 : m_texture {nullptr}
19 , m_render_layer {0}
20 {
21 }
22
24 {
25 this->m_texture = t.m_texture;
26 this->m_batch = std::move(t.m_batch);
27 this->m_render_layer = t.m_render_layer;
28 this->m_tint = std::move(t.m_tint);
29 }
30
32 {
33 if (this != &t)
34 {
35 this->m_texture = t.m_texture;
36 this->m_batch = std::move(t.m_batch);
37 this->m_render_layer = t.m_render_layer;
38 this->m_tint = std::move(t.m_tint);
39 }
40
41 return *this;
42 }
43
45 {
46 m_texture = nullptr;
47 }
48
49 void TileMap::set_texture(const std::string& texture)
50 {
51 auto& cache = core::ServiceLocator<resource::Textures>::ref();
52 auto tex = cache.get(texture);
53
54 if (tex)
55 {
56 m_texture = tex;
57 }
58 else
59 {
60 GALAXY_LOG(GALAXY_ERROR, "Failed to query texture storage for '{0}'.", texture);
61 }
62 }
63
64 graphics::Texture2D* TileMap::get_texture()
65 {
66 return m_texture;
67 }
68 } // namespace components
69} // namespace galaxy
#define GALAXY_LOG(level, msg,...)
Definition Log.hpp:29
#define GALAXY_ERROR
Definition Log.hpp:25
Rendering data for a single level/map in a LDTK world.
Definition TileMap.hpp:22
graphics::VertexBatch m_batch
Vertex data batch.
Definition TileMap.hpp:63
glm::vec4 m_tint
Opacity/tinting.
Definition TileMap.hpp:73
TileMap & operator=(TileMap &&)
Move assignment operator.
Definition TileMap.cpp:31
graphics::Texture2D * get_texture()
Get texture.
Definition TileMap.cpp:64
void set_texture(const std::string &texture)
Sets the texture and vertex data.
Definition TileMap.cpp:49
graphics::Texture2D * m_texture
Tileset.
Definition TileMap.hpp:79
int m_render_layer
Rendering layer.
Definition TileMap.hpp:68
Timer.hpp galaxy.
Definition Async.hpp:17