DSC Engine
Loading...
Searching...
No Matches
sprite.hpp
1#pragma once
2
5#include "DSCEngine/sprites/obj_allocator.hpp"
8#include "DSCEngine/system/hardware.hpp"
9
10namespace DSC
11{
12 class Sprite : public Localizable
13 {
14 private:
15 void* oam_pool;
16 void* attr;
17
18 // internal layout
19 Hitbox hitbox;
20 Point<char> anchor={0,0}, theoretical_anchor={0,0};
21
22 Point<sf24> pos;
23
24 ObjVisual* visual;
25
26 ObjAllocator* obj_allocator = nullptr;
27 public:
28 Sprite(ObjSize size, Engine engine);
29
34
39
53
59 void move(sf24 x, sf24 y);
60
61 virtual sf24 x() const override;
62 virtual sf24 y() const override;
64 Engine get_engine() const;
71 int add_frame(ObjFrame* frame);
72
79 void set_flip_horizontal(bool is_flipped);
80
84 void set_flip_vertical(bool is_flipped);
85
86
87 bool is_flipped_horizontal() const;
88 bool is_flipped_vertical() const;
95 void set_priority(int priority);
96 // int get_priority() const;
97
98 void show();
99 void hide();
100 bool is_hidden() const;
107 void set_anchor(int anchor_x, int anchor_y);
108
109
110 ~Sprite();
111
112
113 // the following are not intended for common use outside the library:
114
115 void set_default_allocator(ObjAllocator* obj_allocator);
116 static void oam_deploy_main();
117 static void oam_deploy_sub();
118 };
119}
Rectangular hitbox for 2d entities.
Definition: hitbox.hpp:15
Abstract declaration of object dependent on its 2D position
Definition: localizable.hpp:15
Definition: obj_allocator.hpp:16
Definition: obj_frame.hpp:14
OAM Object graphics handler class
Definition: obj_visual.hpp:19
Definition: sprite.hpp:13
bool is_flipped_horizontal() const
int add_frame(ObjFrame *frame)
Adds a new sprite frame.
void set_priority(int priority)
Sets sprite priority.
Engine get_engine() const
ObjVisual * get_visual() const
gets the sprite visual information
Size< char > get_size() const
gets the sprite size
void update_visual()
virtual sf24 y() const override
void set_flip_vertical(bool is_flipped)
Sets the sprite is vertical flip state.
void set_position(sf24 x, sf24 y)
sets the sprite virtual position
void move(sf24 x, sf24 y)
moves a sprite relative to its virtual position
bool is_flipped_vertical() const
void set_flip_horizontal(bool is_flipped)
Sets the sprite is horizontal flip state.
void update_position()
void flip_horizontal()
void flip_vertical()
virtual sf24 x() const override
void set_anchor(int anchor_x, int anchor_y)
Sets sprite anchor relative to hitbox.
bool is_hidden() const
24-bit (16.8) signed fixed floating point number
Definition: sf24.hpp:13
Hitbox definitions.
Localizable object definition.
Object Visual definition.
Generic point definition.
Generic point of two coordinates.
Definition: point.hpp:15
Generic size of two coordinates.
Definition: size.hpp:10