Sprite.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. * 2D Game Engine
  3. * Sprite.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 12/02/2021.
  8. */
  9. #ifndef GAMEENGINE_SPRITE_H
  10. #define GAMEENGINE_SPRITE_H
  11. #include <SDL.h>
  12. #include <string>
  13. struct SpriteComponent
  14. {
  15. std::string assetId;
  16. uint32_t width;
  17. uint32_t height;
  18. int32_t zIndex;
  19. SDL_Rect sourceRect;
  20. bool isFixed;
  21. explicit SpriteComponent(std::string assetId = "", int32_t zIndex = 0,
  22. uint32_t width = 0, uint32_t height = 0,
  23. bool isFixed = false,
  24. uint32_t sourceRectX = 0, uint32_t sourceRectY = 0) : assetId(assetId), width(width),
  25. height(height), zIndex(zIndex),
  26. isFixed(isFixed)
  27. {
  28. this->sourceRect = {
  29. static_cast<int>(sourceRectX),
  30. static_cast<int>(sourceRectY),
  31. static_cast<int>(width),
  32. static_cast<int>(height),
  33. };
  34. };
  35. };
  36. #endif /* GAMEENGINE_SPRITE_H */