From f449345e3aeb599eb497dfeeac7027cf4d1de515 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Wed, 3 Feb 2021 00:52:47 -0500 Subject: Pulled transform stuff into a system (starting to do ECS stuff) --- src/game.h | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'src/game.h') diff --git a/src/game.h b/src/game.h index a717d53..189cabb 100644 --- a/src/game.h +++ b/src/game.h @@ -8,6 +8,7 @@ #include "sprite.h" #include "map.h" #include "consts.h" +#include "transform_system.h" struct Input { bool left = false; @@ -19,14 +20,20 @@ struct Input { class Game { public: + Game() : transform_(*this) {} + int addSprite(Sprite sprite); const Sprite& getSprite(int id) const { return sprites_.at(id); } - const std::vector& getSprites() { - return sprites_; + Sprite& getSprite(int id) { + return sprites_.at(id); + } + + const std::vector& getSprites() { + return spriteIds_; } auto spriteView() const { @@ -35,13 +42,8 @@ public: }); } - auto getSpritesByY() const { - return spritesByY_ | ranges::views::transform([] (const std::tuple& val) { - return std::get<1>(val); - }); - } + TransformSystem& getTransformSystem() { return transform_; } - void moveSprite(int id, vec2i newLoc); void setSpriteState(int id, std::string state) { sprites_[id].setState(std::move(state)); @@ -77,8 +79,10 @@ public: private: + TransformSystem transform_; + + std::vector spriteIds_; std::vector sprites_; - std::set> spritesByY_; std::unique_ptr map_; // Camera -- cgit 1.4.1