-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBaseCharacter.h
40 lines (37 loc) · 1.07 KB
/
BaseCharacter.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#ifndef BASE_CHARACTER_H
#define BASE_CHARACTER_H
#include "raylib.h"
class BaseCharacter
{
public:
BaseCharacter();
Vector2 getWorldPos() { return worldPos; }
virtual void tick(float deltaTime);
void undoMovement();
Rectangle getCollisionRec();
virtual Vector2 getScreenPos() = 0;
bool getAlive() {return alive;}
void setAlive(bool isAlive) {alive = isAlive;}
virtual void setScale(float newScale) {scale = newScale;}
protected:
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 worldPos{};
Vector2 worldPostLastFrame{};
// 1: facing right, -1 : facing left
float rightLeft{1.f};
// animation variables
float runningTime{};
int frame{};
int maxFrames{6};
float updateTime{1.f / 12.f};
float speed{4.f};
float width{};
float height{};
float scale{4.0f};
Vector2 velocity{};
private:
bool alive{true};
};
#endif