-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplayer.cpp
158 lines (144 loc) · 4.28 KB
/
player.cpp
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
// -----------------------------------------------------------------
// Learning Team B
// Members:
// Adam LeMmon
// Faith Satterthwaite
// Tom Fletcher
// Justin Ball
// CS 4280 – 11:30 am
// Final Project
// Dr. Rague
// Due: 12/06/12
// Version: 2.4
// -----------------------------------------------------------------
// We made five major improvements to this game
// 1) New controls
// 2) Enemy attack
// 3) HUD (heads up display)
// 4) Enemy health bars
// 5) New Weapon
// -----------------------------------------------------------------
#include "player.h"
// Phase 14 - Take out until Rocket is introduced
// Phase 16 - Uncomment
void CPlayer::FireWeapon()
{
///// -- Adam
if(ammo > 0)
{
///// -- Adam
// use camera->lookAt vector and multiply
// this lookAt vector by the ammo's speed
// to get the ammo velocity vector.
// create the new ammo and attach it to
// the world. fire the ammo
CRocket *newRocket = new CRocket;
newRocket->pitch = camera->pitch;
newRocket->direction = direction;
newRocket->position = position;
newRocket->forward = camera->lookAt.UnitVector();
// Phase 19 - Uncomment the following
newRocket->SetAudioSystem(audioSys);
newRocket->LoadAudio(audioSys->iExplode);
newRocket->AttachTo(terrain);
//// -- Adam
ammo -= 1;
}
///// -- Adam
}
///// -- Adam
void CPlayer::FireWeapon2()
{
// use camera->lookAt vector and multiply
// this lookAt vector by the ammo's speed
// to get the ammo velocity vector.
// create the new ammo and attach it to
// the world. fire the ammo
CRocket *newRocket = new CRocket(1000.0); //It can't be faster than this or it goes through the enemies
newRocket->pitch = camera->pitch;
newRocket->direction = direction;
newRocket->position = position;
newRocket->forward = camera->lookAt.UnitVector();
// Phase 19 - Uncomment the following
newRocket->SetAudioSystem(audioSys);
newRocket->LoadAudio(audioSys->iExplode);
newRocket->AttachTo(terrain);
}
//get a pointer to the sod // The array is used to keep track of all sods on the map in the radar screen
void CPlayer::setSod(CEnemy* s)
{
sod[sodIndex] = s;
sodIndex++;
//ammo -- we want half as many rockets as total enemeies
ammo++;
}
//get a pointer to the ogro // The array is used to keep track of all ogros on the map in the radar screen
void CPlayer::setOgro(CEnemy* o)
{
ogro[ogroIndex] = o;
ogroIndex++;
}
void CPlayer::killSod(CEnemy* s)
{
for(int i = 0; i < MAX_ENEMIES; i++)
{
if (sod[i] == s)
{
sod[i] = 0;
break;
}
}
}
void CPlayer::killOgro(CEnemy* o)
{
for(int i = 0; i < MAX_ENEMIES; i++)
{
if (ogro[i] == o)
{
ogro[i] = 0;
break;
}
}
}
///// -- Adam
/*********************************Faith Satterthwaite 11/27/2012*********************************/
void CPlayer::OnCollision(CObject *collisionObject)
{
// if Sod enemy collides with the player
if (typeid(*collisionObject) == typeid(CSodEnemy))
{
///// -- Adam
if (recoveryTime == 0) // make the player invicible for a moment after being hit
{
recoveryTime = .4;
///// - Adam
if(hp > 0)
hp -= 10; //minus 10 health
///// - Adam
}
velocity = CVector(0.0, 0.0, 0.0);//stop when you hit an enemy
acceleration = CVector(0.0, 0.0, 0.0);
camera->acceleration = CVector(0.0, 0.0, 0.0);
camera->velocity = CVector(0.0, 0.0, 0.0);
///// - Adam
}
// if Ogro enemy collides with the player
if (typeid(*collisionObject) == typeid(COgroEnemy))
{
///// -- Adam
if (recoveryTime == 0) // make the player invicible for a moment after being hit
{
recoveryTime = .4;
///// - Adam
if(hp > 0)
hp -= 20; //minus 20 health
///// - Adam
}
velocity = CVector(0.0, 0.0, 0.0);//stop when you hit an enemy
acceleration = CVector(0.0, 0.0, 0.0);
camera->acceleration = CVector(0.0, 0.0, 0.0);
camera->velocity = CVector(0.0, 0.0, 0.0);
///// - Adam
}
}
/***********************************************************************************************/