diff options
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/main.cpp b/src/main.cpp index 94bf125..bd330fc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5,6 +5,7 @@ #include "graphics/animation.h" #include "entity.h" +#include "resourceManager.h" namespace gph = Graphics; @@ -34,8 +35,8 @@ class Unit: Entity{ sf::Vector2f speed; - Unit(){ - spritesheet_.loadFromFile("assets/img/Player/Player Angle 1 Sheet.png"); + Unit(sf::Texture& spritesheet){ + spritesheet_ = spritesheet; standing_animation = gph::Animation(spritesheet_, 6, 60, 44, 48, 0); walking_animation = gph::Animation(spritesheet_, 8, 60, 44, 48, 1); shooting_animation = gph::FlippedAnimation<gph::OneShotAnimation>(spritesheet_, 6, 60, 44, 48, 2); @@ -66,16 +67,30 @@ class Unit: Entity{ sprite.setScale(8,8); sprite.setTextureRect(current_animation->next(dt)); sprite.setPosition(position.x, position.y); + sprite = sprite; } }; + +enum class TextureId{ + Angle1, + Angle2, + Front, + Back, + Side +}; + int main() { sf::RenderWindow renderWindow(sf::VideoMode(640, 480), "Demo Game"); sf::Event event; sf::Clock clock; - Unit unit; + + ResourceManager<sf::Texture, TextureId> TextureManager; + TextureManager.load( TextureId::Angle1, "assets/img/Player/Player Angle 1 Sheet.png"); + + Unit unit = Unit(TextureManager.get(TextureId::Angle1)); renderWindow.setFramerateLimit(60); |