Tramway SDK
sprite.h
Go to the documentation of this file.
1// TRAMWAY DRIFT AND DUNGEON EXPLORATION SIMULATOR 2022
2// All rights reserved.
3
4#ifndef TRAM_SDK_RENDER_SPRITE_H
5#define TRAM_SDK_RENDER_SPRITE_H
6
7#include <render/render.h>
8
9namespace tram::Render {
10
11class Material;
12
14 uint16_t offset_x;
15 uint16_t offset_y;
16 uint16_t width;
17 uint16_t height;
18 uint16_t midpoint_x;
19 uint16_t midpoint_y;
20 uint16_t border_h;
21 uint16_t border_v;
22};
23
24class Sprite : public Resource {
25public:
27 inline Material* GetMaterial () const { return material; }
28 inline void SetMaterial (Material* mat) { material = mat; }
29
30 void LoadFromDisk();
31 void LoadFromMemory();
32
33 void Unload() {}
34
35 const std::vector<SpriteFrame>& GetFrames() { return frames; };
36
37 static Sprite* Find(name_t name);
38protected:
39 std::vector<SpriteFrame> frames;
40 Material* material = nullptr;
41};
42
43}
44
45#endif // TRAM_SDK_RENDER_SPRITE_H
Definition: material.h:32
Definition: sprite.h:24
void SetMaterial(Material *mat)
Definition: sprite.h:28
void LoadFromDisk()
Definition: sprite.cpp:41
void Unload()
Definition: sprite.h:33
void LoadFromMemory()
Definition: sprite.cpp:36
const std::vector< SpriteFrame > & GetFrames()
Definition: sprite.h:35
static Sprite * Find(name_t name)
Definition: sprite.cpp:24
Material * GetMaterial() const
Definition: sprite.h:27
Material * material
Definition: sprite.h:40
std::vector< SpriteFrame > frames
Definition: sprite.h:39
Sprite(UID name)
Definition: sprite.h:26
Definition: resource.h:12
name_t name
Definition: resource.h:38
Definition: gui.h:9
Definition: sprite.h:13
uint16_t border_v
Definition: sprite.h:21
uint16_t height
Definition: sprite.h:17
uint16_t offset_y
Definition: sprite.h:15
uint16_t midpoint_y
Definition: sprite.h:19
uint16_t offset_x
Definition: sprite.h:14
uint16_t border_h
Definition: sprite.h:20
uint16_t width
Definition: sprite.h:16
uint16_t midpoint_x
Definition: sprite.h:18
Definition: uid.h:11