blob: dd00e4f75f8ba61f815ba89d608df17ca262e266 (
plain)
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
|
#include "CParticle.h"
CParticle::CParticle(void)
{
mPos = new CVector(0, 0);
mVel = new CVector(0, 0);
mAccel = new CVector(0, 0);
}
CParticle::CParticle(float aX, float aY, float aVelX, float aVelY, float aAccelX, float aAccelY)
{
mPos = new CVector(aX, aY);
mVel = new CVector(aVelX, aVelY);
mAccel = new CVector(aAccelX, aAccelY);
}
CParticle::~CParticle(void)
{
destroy();
}
void CParticle::destroy(void)
{
if (mPos != NULL)
{
delete mPos;
mPos = NULL;
}
if (mVel != NULL)
{
delete mVel;
mVel = NULL;
}
if (mAccel != NULL)
{
delete mAccel;
mAccel = NULL;
}
}
float CParticle::getX(void)
{
return mPos->x;
}
float CParticle::getY(void)
{
return mPos->y;
}
void CParticle::setXVel(float aXVel)
{
mVel->x = aXVel;
}
void CParticle::setYVel(float aYVel)
{
mVel->y = aYVel;
}
void CParticle::update(void)
{
mVel->x += mAccel->x;
mVel->y += mAccel->y;
mPos->x += mVel->x;
mPos->y += mVel->y;
}
void CParticle::setXY(int aX, int aY)
{
mPos->x = aX;
mPos->y = aY;
}
|