Animation.h 788 B

123456789101112131415161718192021222324252627282930313233
  1. /*
  2. * 2D Game Engine
  3. * Animation.h:
  4. * Based on pikuma.com 2D game engine in C++ and Lua course
  5. * Copyright (c) 2021 986-Studio. All rights reserved.
  6. *
  7. * Created by Manoël Trapier on 15/02/2021.
  8. */
  9. #ifndef GAMEENGINE_ANIMATION_H
  10. #define GAMEENGINE_ANIMATION_H
  11. #include <stdint.h>
  12. #include <SDL.h>
  13. struct AnimationComponent
  14. {
  15. uint32_t numFrames;
  16. uint32_t currentFrame;
  17. uint32_t frameSpeedRate;
  18. bool isLoop;
  19. uint32_t startTime;
  20. explicit AnimationComponent(uint32_t numFrames = 1, int frameSpeedRate = 1,
  21. bool isLoop = true) :numFrames(numFrames), frameSpeedRate(frameSpeedRate), isLoop(isLoop)
  22. {
  23. this->currentFrame = 1;
  24. this->startTime = SDL_GetTicks();
  25. };
  26. };
  27. #endif /* GAMEENGINE_ANIMATION_H */