File: CGotoEvent.h

package info (click to toggle)
blocks-of-the-undead 1.0-7
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, sid, trixie
  • size: 4,084 kB
  • sloc: cpp: 6,224; sh: 3,356; makefile: 171
file content (58 lines) | stat: -rw-r--r-- 1,090 bytes parent folder | download | duplicates (4)
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
#ifndef _CGOTOEVENT_
#define _CGOTOEVENT_

#include "CSequencedEvent.h"
#include "CVector.h"
#include "CEventData.h"
#include "CParticle.h"

class CGotoData : public CEventData
{
public:
	enum DestType
	{
		NA = 0,
		TOP = 2,
		BOTTOM = 4,
		LEFT = 8,
		RIGHT = 16
	};

	CGotoData(int dtype) : dtype(dtype) {}

	CGotoData* getCopy() { return new CGotoData(*this); }

	bool hitBottom() { return hasFlag(BOTTOM); }
	bool hitTop() { return hasFlag(TOP); }
	bool hitLeft() { return hasFlag(LEFT); }
	bool hitRight() { return hasFlag(RIGHT); }

private:
	int dtype;
	
	bool hasFlag(int f)
	{
		return ((dtype & f) == f);
	}
};

class CGotoEvent : public CSequencedEvent
{
public:
	CGotoEvent(CParticle &o, CVector dest, double speed, bool c);
	CGotoEvent* getCopy();

	void doUpdate();
	void initialize();

	CGotoData* getEventData();

private:
	CParticle &obj;    //! particle to move
	CVector dest;      //! Destination in _screen coordinates_
	CVector start;     //! Location particle started at for checking what kind of collision it was (bottom, top, left, right)
	double speed;
};


#endif