-
Notifications
You must be signed in to change notification settings - Fork 0
/
Actor.h
167 lines (146 loc) · 5.65 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
#ifndef ACTOR_H_
#define ACTOR_H_
#include "GraphObject.h"
#include "GameConstants.h"
class StudentWorld;
class GhostRacer;
// Students: Add code to this file, Actor.cpp, StudentWorld.h, and StudentWorld.cpp
const int LEFT_EDGE = ROAD_CENTER - ROAD_WIDTH/2;
const int RIGHT_EDGE = ROAD_CENTER + ROAD_WIDTH/2;
class Actor: public GraphObject
{
public:
Actor(StudentWorld* sp, GhostRacer* playerPtr, int health, double horizSpeed, double vertSpeed, int imageID, double startX, double startY, int dir, double size, unsigned int depth);
virtual void doSomething() = 0; // What each actor will do
virtual bool isAffectedByWater() = 0; // Is actor affected by water projectile
void changeHealth(int change) {m_health += change;};
void commonMove(); // Movement pattern common to all actors, which makes them move vertically relative to GhostRacer's speed
bool isAlive() const {return m_isAlive;};
bool isOverlap(Actor* object, Actor* player) const;
bool getHitWater() const {return m_waterHit;};
void setHitWater(bool wasHit) {m_waterHit = wasHit;}; // Used to determine if an actor was hit by water and if so, do something relevant to it
virtual bool isCollisionAvoidanceActor() const {return false;}; // Used to determine if ZombieCab can be created in a specific lane
void setAlive(bool alive) {m_isAlive = alive;};
int getHealth() const {return m_health;};
double getHorizSpeed() const {return m_horizontalSpeed;};
double getVertSpeed() const {return m_verticalSpeed;};
void setHorizSpeed(double horizSpeed) {m_horizontalSpeed = horizSpeed;};
void setVertSpeed(double vertSpeed) {m_verticalSpeed = vertSpeed;};
StudentWorld* getWorld() const {return worldPtr;};
GhostRacer* getPlayer() const {return GhostRacerPtr;};
private:
StudentWorld* worldPtr;
GhostRacer* GhostRacerPtr;
bool m_isAlive;
bool m_waterHit;
double m_horizontalSpeed;
double m_verticalSpeed;
int m_health;
};
class Projectile: public Actor
{
public:
Projectile(StudentWorld* sp, GhostRacer* playerPtr, double startX, double startY, int dir);
virtual void doSomething();
virtual bool isAffectedByWater() {return false;};
private:
int m_countMoves;
};
class BorderLine: public Actor
{
public:
BorderLine(StudentWorld* sp, GhostRacer* playerPtr, int imageID, double startX, double startY);
virtual void doSomething();
virtual bool isAffectedByWater() {return false;};
private:
};
class GhostRacer: public Actor
{
public:
GhostRacer(StudentWorld* sp);
virtual void doSomething();
virtual bool isAffectedByWater() {return false;};
virtual bool isCollisionAvoidanceActor() const {return true;};
void changeSprays(int change) {m_numSprays += change;}; // Used to change number of sprays (increment or decrement)
void setHitOilSlick(bool hitOil) {m_oilHit = hitOil;};
int getSprays() {return m_numSprays;};
bool getHitOil() {return m_oilHit;};
private:
int m_numSprays; // Move this to Ghost Racer class
bool m_oilHit; // Can remove this or move to GhostRacer class
};
class ZombieCab: public Actor
{
public:
ZombieCab(StudentWorld* sp, GhostRacer* playerPtr, double vertSpeed, double startX, double startY);
virtual void doSomething();
virtual bool isCollisionAvoidanceActor() const {return true;};
virtual bool isAffectedByWater() {return true;};
void setDamagedPlayer(bool hasDamaged) {m_hasDamagedPlayer = hasDamaged;};
int getPlanLength() {return m_planLength;};
void setPlanLength(int plan) {m_planLength = plan;};
private:
bool m_hasDamagedPlayer;
int m_planLength;
};
class Pedestrian: public Actor
{
public: // Common subclass for pedestrians, based around their moveplans
Pedestrian(StudentWorld* sp, GhostRacer* playerPtr, int imageID, double startX, double startY, double size);
virtual bool isAffectedByWater() {return true;};
virtual bool isCollisionAvoidanceActor() const {return true;};
int getMovePlan() {return m_movementPlanDist;};
void setMovePlan(int setMove) {m_movementPlanDist = setMove;};
void commonMovePlan();
private:
int m_movementPlanDist;
};
class HumanPedestrian: public Pedestrian
{
public:
HumanPedestrian(StudentWorld* sp, GhostRacer* playerPtr, double startX, double startY);
// virtual void changeHealth(int change) {return;};
virtual void doSomething();
};
class ZombiePedestrian: public Pedestrian
{
public:
ZombiePedestrian(StudentWorld* sp, GhostRacer* playerPtr, double startX, double startY);
virtual void doSomething();
private:
int m_ticks;
};
class Goodie: public Actor // Common subclass for goodie, based around actors that do something to GhostRacer when they overlap
{
public:
Goodie(StudentWorld* sp, GhostRacer* playerPtr, int imageID, double startX, double startY, double size, int dir = 0);
virtual bool isAffectedByWater() {return false;};
bool commonGoodieAndOverlap();
};
class OilSlick: public Goodie
{
public:
OilSlick(StudentWorld* sp, GhostRacer* playerPtr, double startX, double startY, double size);
virtual void doSomething();
};
class HealingGoodie: public Goodie
{
public:
HealingGoodie(StudentWorld* sp, GhostRacer* playerPtr, double startX, double startY);
virtual bool isAffectedByWater() {return true;};
virtual void doSomething();
};
class HolyWaterGoodie: public Goodie
{
public:
HolyWaterGoodie(StudentWorld* sp, GhostRacer* playerPtr, double startX, double startY);
virtual bool isAffectedByWater() {return true;};
virtual void doSomething();
};
class SoulGoodie: public Goodie
{
public:
SoulGoodie(StudentWorld* sp, GhostRacer* playerPtr, double startX, double startY);
virtual void doSomething();
};
#endif // ACTOR_H_