-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathActor.h
464 lines (408 loc) · 8.98 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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
#ifndef ACTOR_H_
#define ACTOR_H_
#include "GraphObject.h"
// Students: Add code to this file, Actor.cpp, StudentWorld.h, and StudentWorld.cpp
//reference STudentWorld
class StudentWorld;
class GameObject;
#include <vector>
//Peach, Yoshi, Coin Square, Star Squares, Directional Squares, Bank Squares
//Event Squares, Dropping Squares, Boo, Bowser, Vortexes
class Actor : public GraphObject
{
//constructor
//doSomething()
//etc... as you see fit
//GraphObject(int imageID, double startX, double startY, int startDirection = right, int depth = 0, double size = 1.0);
//int getX() const; // in pixels (0-255)
//int getY() const; // in pixels (0-255)
//void moveTo(int x, int y); // in pixels (0-255)
//int getDirection() const; // sprite angle in degrees (0-359)
//void setDirection(Direction d); // sprite angle in degrees (0-359)
//void getPositionInThisDirection(int angle, int distance, int& newX, int& newY) const;
//void moveAtAngle(int angle, int distance);
//what player avatar object must do when it is created
//what player avatar must do during a tick
//what player avatar must do in other circusmtances
public:
Actor(StudentWorld* world, const int imageID, int startX, int startY, int startDirection = right, int depth = 0, double size = 1);
virtual ~Actor();
virtual void doSomething() = 0;
virtual bool isValidPos(int dir);
//, int xDir, int yDir);
//void addPCoins(int coins)
//{
// m_peachCoins += coins;
//}
//void deductPeachCoins(int coins)
//{
// m_peachCoins -= coins;
//}
//int getPeachCoins()
//{
// return m_peachCoins;
//}
////Yoshi
//void addYoshiCoins(int coins)
//{
// m_yoshiCoins += coins;
//}
//void deductYoshiCoins(int coins)
//{
// m_yoshiCoins -= coins;
//}
//int getYoshiCoins()
//{
// return m_yoshiCoins;
//}
//int getCoins()
//{
// return m_playerCoins;
//}
//Swap player info
void swap();
void swapStars();
void swapCoins();
//Overlappping
virtual bool isOverLapping(Actor* a, Actor* b)
{
if (a->getX() == b->getX() && a->getY() == b->getY())
{
return true;
}
else
{
return false;
}
}
void setPeachOn(bool state);
bool getPeachOn();
void setYoshiOn(bool state);
bool getYoshiOn();
bool atAFork();
//Impactable for nonsquares
virtual bool getIsImpactable()
{
return true;
}
//Coins
void addCoins(int coins)
{
m_playerCoins += coins;
}
void deductCoins(int coins)
{
m_playerCoins -= coins;
}
int getCoins()
{
if (m_playerCoins <= 0)
{
m_playerCoins = 0;
}
return m_playerCoins;
}
void setCoins(int coins)
{
m_playerCoins = coins;
}
//Stars
int getStars()
{
if (m_playerStars <= 0)
{
m_playerStars = 0;
}
return m_playerStars;
}
void addStars(int stars)
{
m_playerStars += stars;
}
void deductStars(int stars)
{
m_playerStars -= stars;
}
void setStars(int stars)
{
m_playerStars = stars;
}
//Ticks
int getTicks()
{
return ticks_to_move;
}
void setPlayerTicks(int ticks)
{
ticks_to_move = ticks;
}
void setTicks(int dieRoll)
{
if (dieRoll > 0)
{
ticks_to_move = dieRoll * 8;
//std::cerr << "new ticks: " << ticks_to_move << std::endl;
//return ticks_to_move;
}
else if (dieRoll == 0 && ticks_to_move > 0)
{
//std::cerr << "new decremented ticks: " << ticks_to_move << std::endl;
ticks_to_move--;
}
else
{
ticks_to_move = 0;
}
}
//Alive Status
void setAlive(bool state)
{
m_alive = state;
}
bool getAlive() const
{
return m_alive;
}
//WaitingToRoll State
bool getWaitingToRoll()
{
return waiting_to_roll;
}
void setWaitingToRoll(bool value)
{
waiting_to_roll = value;
}
//DieRoll
void setDieRoll(int die_roll)
{
if (die_roll > 0)
{
m_dieRoll = die_roll;
}
else
{
m_dieRoll--;
}
}
int getDieRoll()
{
if (m_dieRoll <= 0)
{
m_dieRoll = 0;
}
//std::cerr << m_dieRoll << std::endl;
return m_dieRoll;
}
//Just swapped on Event Square
bool getJustSwapped()
{
return justSwapped;
}
void setJustSwappedStatus(bool state)
{
justSwapped = state;
}
//On directional square
bool isOnDirectionalSquare()
{
return m_onDirectionalSquare;
}
void setOnDirectionalSquare(bool state)
{
m_onDirectionalSquare = state;
}
int getMovingDirection();
void setMovingDirection(int dir);
//int getLocation();
//void setLocation(int xNew, int yNew);
/*void setTeleportStatus(bool teleportStatus);
bool getTeleportStatus();*/
//Pointer to StudentWorld
StudentWorld* getWorld();
//make listoof common stuff
//print blue coin square first on board
private:
StudentWorld* m_world;
bool m_alive;
int ticks_to_move;
bool waiting_to_roll;
int m_dieRoll;
int m_playerCoins;
int m_playerStars;
//int m_objectX;
//int m_objectY;
bool m_goTeleport;
bool m_impactable;
bool justSwapped;
bool m_onDirectionalSquare;
bool isPeachOnSquare;
bool isYoshiOnSquare;
int movingDirection;
};
//Players //-> perhaps create another base class here - done
class Players : public Actor
{
public:
Players(StudentWorld* world, const int imageID, int startX, int startY, int ticks);
/*int getMovingDirection();
void setMovingDirection(int dir);*/
/*void setNewLocationX(int newX);
void setNewLocationY(int newY);*/
virtual void doSomething();
virtual bool getIsImpactable();
/*void shouldTeleport(bool teleportStatus);
bool getTeleportStatus();*/
//void setVortex(Vortex* vortex);
private:
//int movingDirection; //right = 0 from graphobject
//Vortex* m_vortex;
//bool goTeleport;
};
class Peach : public Players
{
public:
Peach(StudentWorld* world, int startX, int startY);
virtual void doSomething();
private:
};
class Yoshi : public Players
{
public:
Yoshi(StudentWorld* world, int startX, int startY);
virtual void doSomething();
};
//Baddies -> perhaps create another base class here
class Baddie :public Actor
{
public:
Baddie(StudentWorld* world, const int imageID, int startX, int startY, int travelDistance = 0);
bool getWalkingState();
void setWalkingState(bool state);
void setPauseCounter(int number)
{
if (number <= 0)
{
pauseCounter--;
}
else
{
pauseCounter = number;
}
}
int getPauseCounter()
{
return pauseCounter;
}
virtual void doSomething();
void doBaddieStuff(int enemyNum);
private:
bool walkingState;
int pauseCounter;
//int squares_to_move;
};
class Bowser : public Baddie
{
public:
Bowser(StudentWorld* world, int startX, int startY);
virtual void doSomething();
};
class Boo : public Baddie
{
public:
Boo(StudentWorld* world, int startX, int startY);
virtual void doSomething();
};
//Squares
class CoinSquare : public Actor ///change to squares subclass later?
{
//use good object-oriented programming style!
public:
CoinSquare(StudentWorld* world, const int imageID, int startX, int startY, std::string color);
//Hint: You may want your Coin Square, or one of its base classes, to have an
/*"alive" flag that indicates whether it's still capable of being activated (since
Bowser can convert a Coin Square into a Dropping Square, necessitating
destruction of the Coin Squareand removal from the StudentWorld's actor
container).*/
std::string getColor()
{
return color;
}
virtual bool getIsImpactable()
{
return false;
}
virtual void deactivate();
virtual void activate();
void getBlueSquare();
void getRedSquare();
virtual void doSomething();
private:
std::string color;
/*bool m_PeachOnSquare;
bool m_YoshiOnSquare;*/
};
class Squares :public Actor
{
public:
Squares(StudentWorld* world, const int imageID, int startX, int startY, int startDirection, int depth);
//bool isOverlappingPeach(int& peachX, int& peachY, int objectX, int objectY);
//bool isOverlappingYoshi(int& yoshiX, int& yoshiY, int objectX, int objectY);
/*void setPeachOn(bool state);
bool getPeachOn();
void setYoshiOn(bool state);
bool getYoshiOn();*/
virtual bool getIsImpactable();
private:
/*bool isPeachOnSquare;
bool isYoshiOnSquare;*/
};
class StarSquare : public Squares
{
public:
StarSquare(StudentWorld* world, int startX, int startY);
virtual void doSomething();
//bool isOverlapping(int& peachX, int& peachY, int x, int y);
};
class DirectionalSquares : public Squares
{
public:
DirectionalSquares(StudentWorld* world, int startX, int startY, int startdirection, int direction);
int getDirectionSquare()
{
return direction;
//1 == up, 2 == right, 3 == down, 4 == left
}
void forceDirection(int playerNum, int goDir);
virtual void doSomething();
private:
int direction;
};
class BankSquares : public Squares
{
public:
BankSquares(StudentWorld* world, int startX, int startY);
virtual void doSomething();
};
class EventSquares : public Squares
{
public:
EventSquares(StudentWorld* world, int startX, int startY);
virtual void doSomething();
};
class DroppingSquares : public Squares
{
public:
DroppingSquares(StudentWorld* world, int startX, int startY);
virtual void doSomething();
};
class Vortex : public Actor
{
public:
Vortex(StudentWorld* world, int startX, int startY); //, int directionAtatck);
//std::vector<Actor*> activate();
bool isActiveState();
void doSomething();
private:
bool activeState;
};
#endif // ACTOR_H