summary refs log tree commit diff stats
path: root/src/sprite.h
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2021-02-13 20:50:21 -0500
committerKelly Rauchenberger <fefferburbia@gmail.com>2021-02-13 20:50:21 -0500
commit470b1d43fb6f8e17624ee90f87270de5bd6ff77e (patch)
tree966f1e18d496f12c3273684be299573e4bf443ec /src/sprite.h
parented933607765a6e010689aaaf85184053ff6e8a2b (diff)
downloadtanetane-470b1d43fb6f8e17624ee90f87270de5bd6ff77e.tar.gz
tanetane-470b1d43fb6f8e17624ee90f87270de5bd6ff77e.tar.bz2
tanetane-470b1d43fb6f8e17624ee90f87270de5bd6ff77e.zip
Added lightning sprite to mailbox event
Sprites can be destroyed now, which really just means that their index is removed from the list of active sprites. The actual memory is not freed until all sprites are deleted on map change.

Sprite layers are introduced. All sprites by default are on layer 0 (Normal) which renders them in between the lower and upper map layers. There is also a layer 1 (Above) that renders above the upper map layer, and the sprite for the lightning strike uses this layer in order to not be hidden by the trees.

Fixed a bug where waiting for the end of a non-looping animation would trip the flag immediately upon the final frame activating, instead of waiting the length of the last frame.
Diffstat (limited to 'src/sprite.h')
-rw-r--r--src/sprite.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/sprite.h b/src/sprite.h index fcf7e1d..84b161f 100644 --- a/src/sprite.h +++ b/src/sprite.h
@@ -10,6 +10,11 @@
10#include "vector.h" 10#include "vector.h"
11#include "step_type.h" 11#include "step_type.h"
12 12
13enum class SpriteLayer {
14 Normal,
15 Above
16};
17
13struct SpriteFrame { 18struct SpriteFrame {
14 SDL_Rect srcRect; 19 SDL_Rect srcRect;
15 vec2i center; 20 vec2i center;
@@ -36,8 +41,11 @@ struct Movement {
36class Sprite { 41class Sprite {
37public: 42public:
38 43
44 std::string alias;
45
39 // Transform 46 // Transform
40 vec2i loc { 0, 0 }; 47 vec2i loc { 0, 0 };
48 SpriteLayer layer = SpriteLayer::Normal;
41 bool collidable = false; 49 bool collidable = false;
42 bool solid = false; 50 bool solid = false;
43 vec2i collisionOffset; 51 vec2i collisionOffset;