diff options
author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2021-02-13 20:50:21 -0500 |
---|---|---|
committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2021-02-13 20:50:21 -0500 |
commit | 470b1d43fb6f8e17624ee90f87270de5bd6ff77e (patch) | |
tree | 966f1e18d496f12c3273684be299573e4bf443ec /src/transform_system.h | |
parent | ed933607765a6e010689aaaf85184053ff6e8a2b (diff) | |
download | tanetane-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/transform_system.h')
-rw-r--r-- | src/transform_system.h | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/transform_system.h b/src/transform_system.h index 46b6877..a21b93b 100644 --- a/src/transform_system.h +++ b/src/transform_system.h | |||
@@ -8,6 +8,8 @@ | |||
8 | #include "direction.h" | 8 | #include "direction.h" |
9 | #include "system.h" | 9 | #include "system.h" |
10 | #include "vector.h" | 10 | #include "vector.h" |
11 | #include "sprite.h" | ||
12 | #include "consts.h" | ||
11 | 13 | ||
12 | class Game; | 14 | class Game; |
13 | 15 | ||
@@ -29,26 +31,28 @@ public: | |||
29 | 31 | ||
30 | TransformSystem(Game& game) : game_(game) {} | 32 | TransformSystem(Game& game) : game_(game) {} |
31 | 33 | ||
32 | void initSprite(int spriteId, vec2i loc); | 34 | void initSprite(int spriteId, vec2i loc, SpriteLayer layer = SpriteLayer::Normal); |
33 | 35 | ||
34 | void setUpCollision(int spriteId, vec2i offset, vec2i size, bool solid); | 36 | void setUpCollision(int spriteId, vec2i offset, vec2i size, bool solid); |
35 | 37 | ||
36 | void moveSprite(int spriteId, vec2i newLoc); | 38 | void moveSprite(int spriteId, vec2i newLoc); |
37 | 39 | ||
38 | auto getSpritesByY() const { | 40 | auto getSpritesByY(SpriteLayer layer) const { |
39 | return spritesByY_ | ranges::views::transform([] (const std::tuple<int, int>& val) { | 41 | return spritesByY_[static_cast<size_t>(layer)] | ranges::views::transform([] (const std::tuple<int, int>& val) { |
40 | return std::get<1>(val); | 42 | return std::get<1>(val); |
41 | }); | 43 | }); |
42 | } | 44 | } |
43 | 45 | ||
44 | CollisionResult checkCollision(int spriteId, vec2i newLoc, Direction dir); | 46 | CollisionResult checkCollision(int spriteId, vec2i newLoc, Direction dir); |
45 | 47 | ||
48 | void destroySprite(int spriteId) override; | ||
49 | |||
46 | void clearSpriteCache() override; | 50 | void clearSpriteCache() override; |
47 | 51 | ||
48 | private: | 52 | private: |
49 | 53 | ||
50 | Game& game_; | 54 | Game& game_; |
51 | std::set<std::tuple<int, int>> spritesByY_; | 55 | std::set<std::tuple<int, int>> spritesByY_[NUM_SPRITE_LAYERS]; |
52 | 56 | ||
53 | struct Collidable { | 57 | struct Collidable { |
54 | int lower; | 58 | int lower; |