| 1 |
#ifndef _CGOTOEVENT_ |
| 2 |
#define _CGOTOEVENT_ |
| 3 |
|
| 4 |
#include "CSequencedEvent.h" |
| 5 |
#include "CVector.h" |
| 6 |
#include "CEventData.h" |
| 7 |
#include "CParticle.h" |
| 8 |
|
| 9 |
class CGotoData : public CEventData |
| 10 |
{ |
| 11 |
public: |
| 12 |
enum DestType |
| 13 |
{ |
| 14 |
NA = 0, |
| 15 |
TOP = 2, |
| 16 |
BOTTOM = 4, |
| 17 |
LEFT = 8, |
| 18 |
RIGHT = 16 |
| 19 |
}; |
| 20 |
|
| 21 |
CGotoData(int dtype) : dtype(dtype) {} |
| 22 |
|
| 23 |
CGotoData* getCopy() { return new CGotoData(*this); } |
| 24 |
|
| 25 |
bool hitBottom() { return hasFlag(BOTTOM); } |
| 26 |
bool hitTop() { return hasFlag(TOP); } |
| 27 |
bool hitLeft() { return hasFlag(LEFT); } |
| 28 |
bool hitRight() { return hasFlag(RIGHT); } |
| 29 |
|
| 30 |
private: |
| 31 |
int dtype; |
| 32 |
|
| 33 |
bool hasFlag(int f) |
| 34 |
{ |
| 35 |
return ((dtype & f) == f); |
| 36 |
} |
| 37 |
}; |
| 38 |
|
| 39 |
class CGotoEvent : public CSequencedEvent |
| 40 |
{ |
| 41 |
public: |
| 42 |
CGotoEvent(CParticle &o, CVector dest, double speed, bool c); |
| 43 |
CGotoEvent* getCopy(); |
| 44 |
|
| 45 |
void doUpdate(); |
| 46 |
void initialize(); |
| 47 |
|
| 48 |
CGotoData* getEventData(); |
| 49 |
|
| 50 |
private: |
| 51 |
CParticle &obj; //! particle to move |
| 52 |
CVector dest; //! Destination in _screen coordinates_ |
| 53 |
CVector start; //! Location particle started at for checking what kind of collision it was (bottom, top, left, right) |
| 54 |
double speed; |
| 55 |
}; |
| 56 |
|
| 57 |
|
| 58 |
#endif |