-
Notifications
You must be signed in to change notification settings - Fork 1
/
entity.h
70 lines (56 loc) · 1.7 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
* entity.h
*
* Created on: 2013-07-17
* Author: Liam
*/
#ifndef ENTITY_H_
#define ENTITY_H_
#include "physics.h"
#include "shapes.h"
#include "graphics.h"
#include "entitylist.h"
#include "properties.h"
#include "serializable.h"
#include <cmath>
typedef class vec2d Vec2d;
typedef class Entity: public ISerializable {
public:
Entity():m_pos(), m_vel(), m_inputvel(), m_accel(), m_image(), m_properties(0) {}
Entity(const vec2d &pos, const vec2d &vel, const vec2d &accel, const Image &image): m_pos(pos), m_vel(vel), m_inputvel(), m_accel(accel), m_image(image), m_properties(0) {}
bool operator==(const Entity &src);
virtual ~Entity() {}
virtual Entity *clone() {return new Entity(*this);}
vec2d &getPos() {return m_pos;}
vec2d &getVel() {return m_vel;}
vec2d &getAccel() {return m_accel;}
vec2d &getInputvel() {return m_inputvel;}
Image &getImage() {return m_image;}
int &getProperties() {return m_properties;}
void setPos(vec2d pos) {m_pos = pos;}
void setImage(Image image) {m_image = image;}
void setVel(vec2d vel) {m_vel = vel;}
void setAccel(vec2d accel) {m_accel = accel;}
void setInputvel(vec2d inputvel) {m_inputvel = inputvel;}
void setProperties(int p) {m_properties = p;}
virtual void setCanjump(bool x) {}
float stepX(float dt);
float stepY(float dt);
physRect getRect();
virtual void update(float dt) {}
virtual void draw();
virtual void step(float dt);
virtual bool read(std::ifstream &file);
virtual bool write(std::ofstream &file);
virtual void fixup() {}
virtual void rotate() {}
protected:
vec2d m_pos;
vec2d m_vel;
vec2d m_inputvel;
vec2d m_accel;
Image m_image;
int m_properties;
bool resolveCollision(Entity *other);
} Entity_s;
#endif /* ENTITY_H_ */