-
Notifications
You must be signed in to change notification settings - Fork 0
/
entity.h
51 lines (38 loc) · 1.09 KB
/
entity.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
#pragma once
#include <vector>
#include <QPainter>
/*********************************************
* Design Pattern: Mediator *
* Colleague *
*********************************************/
class Coordinate;
class RectCollider;
class Entity {
public:
Entity();
Entity(Coordinate* position, std::string name);
virtual ~Entity();
Coordinate* getPosition();
void setPosition(Coordinate* position);
std::string getName() {
return name;
}
std::vector<Entity*>& getChildren() {
return children;
}
// Override this if your entity has a collider.
virtual RectCollider* getCollider() {
return nullptr;
}
virtual void onCollision(Entity* /*other */) {}
virtual void update(bool paused, double time_since_last_frame) = 0;
virtual void render(QPainter& painter) = 0;
// stage 3
// virtual method for obstacle to implement
virtual void resetLevel() = 0;
protected:
std::vector<Entity*> children;
private:
Coordinate* position;
std::string name;
};