SpriteComponent.h 1021 B

12345678910111213141516171819202122232425262728293031323334
  1. // ----------------------------------------------------------------
  2. // From Game Programming in C++ by Sanjay Madhav
  3. // Copyright (C) 2017 Sanjay Madhav. All rights reserved.
  4. //
  5. // Released under the BSD License
  6. // See LICENSE in root directory for full details.
  7. // ----------------------------------------------------------------
  8. #pragma once
  9. #include "Component.h"
  10. #include "SDL/SDL.h"
  11. class SpriteComponent : public Component
  12. {
  13. public:
  14. // (Lower draw order corresponds with further back)
  15. SpriteComponent(class Actor* owner, int drawOrder = 100);
  16. ~SpriteComponent();
  17. virtual void Draw(class Shader* shader);
  18. virtual void SetTexture(class Texture* texture);
  19. int GetDrawOrder() const { return mDrawOrder; }
  20. int GetTexHeight() const { return mTexHeight; }
  21. int GetTexWidth() const { return mTexWidth; }
  22. void SetVisible(bool visible) { mVisible = visible; }
  23. bool GetVisible() const { return mVisible; }
  24. protected:
  25. class Texture* mTexture;
  26. int mDrawOrder;
  27. int mTexWidth;
  28. int mTexHeight;
  29. bool mVisible;
  30. };