-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathentityline.cpp
More file actions
53 lines (41 loc) · 1001 Bytes
/
entityline.cpp
File metadata and controls
53 lines (41 loc) · 1001 Bytes
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
#include "entityline.hpp"
#include "game.hpp"
entityLine::entityLine(void)
{
mScale = 1;
mRadius = 1;
mEdgeBounce = true;
mGridBound = true;
mTimeToLive = 0;
mSpawnTime = 0;
mDestroyTime = 0;
mType = ENTITY_TYPE_LINE;
setState(ENTITY_STATE_INACTIVE);
mModel.mVertexList.resize(2);
mModel.mVertexList[0] = Point3d(0, 0);
mModel.mVertexList[1] = Point3d(0, 0);
mModel.mEdgeList.resize(1);
mModel.mEdgeList[0].from = 0;
mModel.mEdgeList[0].to = 1;
}
void entityLine::spawnTransition()
{
this->setState(entity::ENTITY_STATE_RUNNING);
mTimeToLive = 100;
run();
}
void entityLine::run()
{
mPen.a *= .9;
if (--mTimeToLive <= 0) {
mTimeToLive = 0;
this->setState(entity::ENTITY_STATE_DESTROYED);
}
mSpeed *= .985;
entity::run();
}
void entityLine::addEndpoints(const Point3d& from, const Point3d& to)
{
mModel.mVertexList[0] = Point3d(from);
mModel.mVertexList[1] = Point3d(to);
}