Wizard Engine
2D cross-platform game engine built around SDL2
 
Loading...
Searching...
No Matches
sprite.cpp
1/*
2 Wizard Engine
3 Copyright (C) 2023-2024 Zana Domán
4
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any damages
7 arising from the use of this software.
8
9 Permission is granted to anyone to use this software for any purpose,
10 including commercial applications, and to alter it and redistribute it
11 freely, subject to the following restrictions:
12
13 1. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must not be
18 misrepresented as being the original software.
19 3. This notice may not be removed or altered from any source distribution.
20*/
21
22// NOLINTNEXTLINE(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp)
23#define __WIZARD_ENGINE_INTERNAL__
24
26
27float wze::sprite::x() const {
28 return _x;
29}
30
31void wze::sprite::set_x(float x) {
32 _x = x;
33}
34
35float wze::sprite::y() const {
36 return _y;
37}
38
39void wze::sprite::set_y(float y) {
40 _y = y;
41}
42
43float wze::sprite::z() const {
44 return _z;
45}
46
47void wze::sprite::set_z(float z) {
48 _z = z;
49}
50
51float wze::sprite::angle() const {
52 return _angle;
53}
54
55void wze::sprite::set_angle(float angle) {
56 _angle = angle;
57}
58
59float wze::sprite::width() const {
60 return _width;
61}
62
63void wze::sprite::set_width(float width) {
64 _width = width;
65}
66
67float wze::sprite::height() const {
68 return _height;
69}
70
71void wze::sprite::set_height(float height) {
72 _height = height;
73}
74
75bool wze::sprite::spatial() const {
76 return _spatial;
77}
78
79void wze::sprite::set_spatial(bool spatial) {
80 _spatial = spatial;
81}
82
83std::shared_ptr<wze::texture> const& wze::sprite::texture() const {
84 return _texture;
85}
86
87void wze::sprite::set_texture(std::shared_ptr<wze::texture> const& texture) {
88 _texture = texture;
89}
90
91uint8_t wze::sprite::color_r() const {
92 return _color_r;
93}
94
95void wze::sprite::set_color_r(uint8_t color_r) {
96 _color_r = color_r;
97}
98
99uint8_t wze::sprite::color_g() const {
100 return _color_g;
101}
102
103void wze::sprite::set_color_g(uint8_t color_g) {
104 _color_g = color_g;
105}
106
107uint8_t wze::sprite::color_b() const {
108 return _color_b;
109}
110
111void wze::sprite::set_color_b(uint8_t color_b) {
112 _color_b = color_b;
113}
114
115uint8_t wze::sprite::color_a() const {
116 return _color_a;
117}
118
119void wze::sprite::set_color_a(uint8_t color_a) {
120 _color_a = color_a;
121}
122
123wze::flip wze::sprite::flip() const {
124 return _flip;
125}
126
127void wze::sprite::set_flip(enum flip flip) {
128 _flip = flip;
129}
130
131bool wze::sprite::visible() const {
132 return _visible;
133}
134
135void wze::sprite::set_visible(bool visible) {
136 _visible = visible;
137}
138
139uint8_t wze::sprite::priority() const {
140 return _priority;
141}
142
143void wze::sprite::set_priority(uint8_t priority) {
144 _priority = priority;
145}
146
148 return _animated;
149}
150
151void wze::sprite::set_animated(bool animated) {
152 _animated = animated;
153}
154
155float wze::sprite::x_offset() const {
156 return _x_offset;
157}
158
159void wze::sprite::set_x_offset(float x_offset) {
160 _x_offset = x_offset;
161}
162
163float wze::sprite::y_offset() const {
164 return _y_offset;
165}
166
167void wze::sprite::set_y_offset(float y_offset) {
168 _y_offset = y_offset;
169}
170
171float wze::sprite::angle_offset() const {
172 return _angle_offset;
173}
174
175void wze::sprite::set_angle_offset(float angle_offset) {
176 _angle_offset = angle_offset;
177}
178
179bool wze::sprite::attach_x() const {
180 return _attach_x;
181}
182
183void wze::sprite::set_attach_x(bool attach_x) {
184 _attach_x = attach_x;
185}
186
187bool wze::sprite::attach_y() const {
188 return _attach_y;
189}
190
191void wze::sprite::set_attach_y(bool attach_y) {
192 _attach_y = attach_y;
193}
194
195bool wze::sprite::attach_angle() const {
196 return _attach_angle;
197}
198
199void wze::sprite::set_attach_angle(bool attach_angle) {
200 _attach_angle = attach_angle;
201}
202
203bool wze::sprite::x_angle_lock() const {
204 return _x_angle_lock;
205}
206
207void wze::sprite::set_x_angle_lock(bool x_angle_lock) {
208 _x_angle_lock = x_angle_lock;
209}
210
211bool wze::sprite::y_angle_lock() const {
212 return _y_angle_lock;
213}
214
215void wze::sprite::set_y_angle_lock(bool y_angle_lock) {
216 _y_angle_lock = y_angle_lock;
217}
218
219wze::sprite::sprite(float x, float y, float z, float angle, float width,
220 float height, bool spatial,
221 std::shared_ptr<wze::texture> const& texture,
222 uint8_t color_r, uint8_t color_g, uint8_t color_b,
223 uint8_t color_a, enum flip flip, bool visible,
224 uint8_t priority, bool animated, float x_offset,
225 float y_offset, float angle_offset, bool attach_x,
226 bool attach_y, bool attach_angle, bool x_angle_lock,
227 bool y_angle_lock) {
228 set_x(x);
229 set_y(y);
230 set_z(z);
231 set_angle(angle);
232 set_width(width);
233 set_height(height);
234 set_spatial(spatial);
235 set_texture(texture);
236 set_color_r(color_r);
237 set_color_g(color_g);
238 set_color_b(color_b);
239 set_color_a(color_a);
240 set_flip(flip);
241 set_visible(visible);
242 set_priority(priority);
243 set_animated(animated);
244 set_x_offset(x_offset);
245 set_y_offset(y_offset);
246 set_angle_offset(angle_offset);
247 set_attach_x(attach_x);
248 set_attach_y(attach_y);
249 set_attach_angle(attach_angle);
250 set_x_angle_lock(x_angle_lock);
251 set_y_angle_lock(y_angle_lock);
252}
bool animated() const final
Gets whether the object should be animated.
Definition sprite.cpp:147
void set_texture(std::shared_ptr< wze::texture > const &texture) final
Sets the wze::texture of the object.
Definition sprite.cpp:87
flip
Flips.
Definition enums.hpp:37
Renderable animatable component.