-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathActor.h
75 lines (53 loc) · 1.64 KB
/
Actor.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#pragma once
#include <vector>
#include "Math.h"
#include "Game.h"
#include <cstdint>
class Actor
{
public:
// track state of actor
enum State
{
EActive,
EPaused,
EDead
};
//default constructor/destructor
Actor(class Game* game);
virtual ~Actor();
// update function called from Game (not override)
void Update(float deltaTime);
// updates all the components attached to the actor
void UpdateComponents(float deltaTime);
// Any actor specific update code (override)
virtual void UpdateActor(float deltaTime);
// getters/setters
Vector2 GetPosition() const { return mPosition; };
void SetPosition(Vector2 position);
void SetScale(float scale);
void SetRotation(float rotation) { mRotation = rotation; }
// Add/remove components
void AddComponent(class Component* component);
void RemoveComponent(class Component* component);
Game* GetGame() const { return mGame; };
std::vector<class Component*> GetComponents() { return mComponents; };
State getState();
void SetState(State state) { mState = state; }
float GetScale() const { return mScale; };
float GetRotation() const { return mRotation; };
// returns the forward pointing vector
Vector2 GetForward() const { return Vector2(Math::Cos(mRotation), -Math::Sin(mRotation)); }
void ProcessInput(const uint8_t* keyState);
virtual void ActorInput(const uint8_t* keyState);
private:
// Actor's state
State mState;
// Transform
Vector2 mPosition; // center position of actor
float mScale; // Uiform scale of actor
float mRotation; // Rotation angle in radians
// Componenets held by this actor
std::vector<class Component*> mComponents;
class Game* mGame;
};