-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPhysicalObject.h
executable file
·80 lines (72 loc) · 2 KB
/
PhysicalObject.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
struct PhysObject
{
double mGravity;
double mXAccel;
double mYAccel;
double mXSpeed;
double mYSpeed;
PhysObject() : mGravity(0.0), mXAccel(0.0), mYAccel(0.0), mXSpeed(0.0), mYSpeed(0.0) {}
void PhysicsUpdate(int timediff);
// virtual void UpdatePhysics(int timediff);
// virtual void Update(int timediff);
};
class GameObject : public PhysObject
{
Sprite* Spr;
int Index;
static int NextIndex;
int TimeToLive;
public:
GameObject() : Index(NextIndex), TimeToLive(5000) {NextIndex++; Spr = new Sprite;}
GameObject(const GameObject& ref)
{
*this = ref;
Spr = new Sprite;
Spr->InitializeSpriteCopy(ref.Spr);
}
~GameObject() {delete Spr;}
bool operator == (const GameObject& ref) {return (ref.Index == Index);}
void SetTimeToLive(int ttl) {TimeToLive = ttl;}
void PositionUpdate(int timediff);
Sprite* GetSprite(){return Spr;}
virtual void Update(int timediff);
virtual bool IsDead();
};
class BounceObject : public GameObject
{
ASound* BounceSound;
bool PhysicsAffected;
int LowerBound;
int LeftBound;
int RightBound;
int TopBound;
int NumBounces;
public:
BounceObject(const ASound& ref) : PhysicsAffected(false), LowerBound(0), LeftBound(0), RightBound(0), TopBound(0), NumBounces(0)
{
BounceSound = new ASound(ref);
}
BounceObject(const BounceObject& ref) : GameObject(ref)
{
PhysicsAffected = ref.PhysicsAffected;
LowerBound = ref.LowerBound;
LeftBound = ref.LeftBound;
RightBound = ref.RightBound;
TopBound = ref.TopBound;
NumBounces = ref.NumBounces;
BounceSound = new ASound(*ref.BounceSound);
}
bool BounceUpdate(int timediff);
virtual void Update(int timediff);
void SetBounds(RECT& BoundRect);
~BounceObject()
{
if(BounceSound)
delete BounceSound;
}
void SetPhysics(bool switchedon) {PhysicsAffected = switchedon;}
};
void UpdateBounceObjects(int timediff);
void SpawnShellCasing(POINT spawn, Weapon* Weap);
void ChangeShellCasingUpdateSpeed(int Speed);
int GetShellCasingUpdateSpeed();