Tower Defence 2
object.h
1 #ifndef TOWER_DEFENCE_2_OBJECT_H
2 #define TOWER_DEFENCE_2_OBJECT_H
3 
4 #include <vector>
5 
6 
7 //TODO: target multiple enemies (AOE)
8 
9 
11 enum TargetingPolicy {
12  target_first,
13  target_last,
14  target_least_health
15 };
16 
19 class Object {
20 public:
21  Object(double x, double y, double radius, double speed, int health,
22  int damage, double attack_range, double attack_speed);
23 
24  ~Object();
25 
26  double x() const;
27  double y() const;
28  double radius() const;
29  double speed() const;
30  double distance_travelled() const;
31  int health() const;
32  int max_health() const;
33  int damage() const;
34  double attack_speed() const;
35  double attack_range() const;
36  TargetingPolicy targeting_policy() const;
37  double time_since_last_attack() const;
38 
39  void position(double x, double y);
40 
42  void speed(double amount);
43 
45  bool is_dead();
46 
49  void health(int amount);
50 
52  void damage(int new_dmg);
53 
55  void attack_speed(int new_speed);
56 
58  void change_policy(TargetingPolicy new_policy);
59 
61  void distace_travelled(double d);
62 
64  double distance(Object &other);
65 
67  bool attack(Object &other, double timestep);
68 
69 protected:
71  double m_x;
73  double m_y;
75  const double m_radius;
77  double m_speed;
79  const double m_max_speed;
83  int m_health;
85  const int m_max_health;
87  int m_damage;
93  TargetingPolicy m_targeting_policy;
96 };
97 
98 
99 #endif //TOWER_DEFENCE_2_OBJECT_H
100 
101 
102 
103 
Definition: object.h:19
int m_health
Current health of the object.
Definition: object.h:83
double m_x
x coordinate of the object
Definition: object.h:71
double distance(Object &other)
Distance from other object.
Definition: object.cpp:115
double m_distance_travelled
Distance travelled by object.
Definition: object.h:81
const int m_max_health
Maximum health of the object.
Definition: object.h:85
double m_time_since_last_attack
Time since last time tower attacked. Used for attack speed.
Definition: object.h:95
double m_y
u coordinate of the object
Definition: object.h:73
bool attack(Object &other, double timestep)
Attack to another object. Takes account the attack speed of the object.
Definition: object.cpp:119
int m_damage
Amount of damage each hit deals.
Definition: object.h:87
bool is_dead()
Object is regarded dead if it has health below of equal to zero.
Definition: object.cpp:78
const double m_max_speed
Maximum speed of the object.
Definition: object.h:79
double m_attack_speed
Attack speed, how fast does the object deal damage.
Definition: object.h:89
double m_attack_range
Attack range, how far can the object deal damage.
Definition: object.h:91
const double m_radius
Physical radius of the object.
Definition: object.h:75
void change_policy(TargetingPolicy new_policy)
Change target policy.
Definition: object.cpp:74
double m_speed
Current speed of the object.
Definition: object.h:77
void distace_travelled(double d)
Change distace travelled.
Definition: object.cpp:111
TargetingPolicy m_targeting_policy
Targeting policy, how will the object choose its target.
Definition: object.h:93