Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "raylib.h"
- class Character
- {
- public:
- Character();
- Vector2 getWorldPos() { return worldPos; }
- void setScreenPos(int winWidth, int winHeight);
- void tick(float deltaTime);
- void undoMovement();
- private:
- Texture2D texture{LoadTexture("characters/knight_idle_spritesheet.png")};
- Texture2D idle{LoadTexture("characters/knight_idle_spritesheet.png")};
- Texture2D run{LoadTexture("characters/knight_run_spritesheet.png")};
- Vector2 screenPos{};
- Vector2 worldPos{};
- Vector2 worldPosLastFrame{};
- float rightLeft{1.f};
- float runningTime{};
- int frame{};
- int maxFrames{6};
- float updateTime{1.f / 12.f};
- float speed{4.f};
- float width{}, height{};
- };
- void Character::undoMovement()
- {
- worldPos = worldPosLastFrame;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement