Advertisement
sbloom85

Character.h

Jan 27th, 2023
898
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.81 KB | None | 0 0
  1. #include "raylib.h"
  2.  
  3. class Character
  4. {
  5. public:
  6.     Character();
  7.     Vector2 getWorldPos() { return worldPos; }
  8.     void setScreenPos(int winWidth, int winHeight);
  9.     void tick(float deltaTime);
  10.     void undoMovement();
  11.  
  12. private:
  13.     Texture2D texture{LoadTexture("characters/knight_idle_spritesheet.png")};
  14.     Texture2D idle{LoadTexture("characters/knight_idle_spritesheet.png")};
  15.     Texture2D run{LoadTexture("characters/knight_run_spritesheet.png")};
  16.    
  17.     Vector2 screenPos{};
  18.     Vector2 worldPos{};
  19.     Vector2 worldPosLastFrame{};
  20.    
  21.     float rightLeft{1.f};
  22.  
  23.     float runningTime{};
  24.     int frame{};
  25.     int maxFrames{6};
  26.     float updateTime{1.f / 12.f};
  27.     float speed{4.f};
  28.     float width{}, height{};
  29. };
  30.  
  31. void Character::undoMovement()
  32. {
  33.     worldPos = worldPosLastFrame;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement