author | terom |
Mon, 08 Dec 2008 22:28:51 +0000 | |
changeset 319 | 9f6a838d58c4 |
parent 305 | 56799ec8d7be |
child 338 | fe2b3c6fff54 |
permissions | -rw-r--r-- |
212 | 1 |
#include "Weapon.hh" |
2 |
||
305 | 3 |
Weapon::Weapon(WeaponID id, TickCount expire, float velocity, float recoil, int damage, float explosionRadius, float radius, |
279
e36f5e1a1c8d
let projectiles bounce, the new BounceBounce weapon puts the Physics engine into an infinite loop
terom
parents:
271
diff
changeset
|
4 |
TimeMS reloadTime, std::string name, float bounce) : |
282
e0e4dfc3e528
compiles cleanly with -Wall -Wextra -Wconversion, not tested, but that shouldn't break anything :)
terom
parents:
279
diff
changeset
|
5 |
id(id), |
e0e4dfc3e528
compiles cleanly with -Wall -Wextra -Wconversion, not tested, but that shouldn't break anything :)
terom
parents:
279
diff
changeset
|
6 |
name(name), |
e0e4dfc3e528
compiles cleanly with -Wall -Wextra -Wconversion, not tested, but that shouldn't break anything :)
terom
parents:
279
diff
changeset
|
7 |
velocity(velocity), |
305 | 8 |
damage(damage), |
282
e0e4dfc3e528
compiles cleanly with -Wall -Wextra -Wconversion, not tested, but that shouldn't break anything :)
terom
parents:
279
diff
changeset
|
9 |
explosionRadius(explosionRadius), |
e0e4dfc3e528
compiles cleanly with -Wall -Wextra -Wconversion, not tested, but that shouldn't break anything :)
terom
parents:
279
diff
changeset
|
10 |
radius(radius), |
e0e4dfc3e528
compiles cleanly with -Wall -Wextra -Wconversion, not tested, but that shouldn't break anything :)
terom
parents:
279
diff
changeset
|
11 |
reloadTime(reloadTime), |
e0e4dfc3e528
compiles cleanly with -Wall -Wextra -Wconversion, not tested, but that shouldn't break anything :)
terom
parents:
279
diff
changeset
|
12 |
recoil(recoil), |
e0e4dfc3e528
compiles cleanly with -Wall -Wextra -Wconversion, not tested, but that shouldn't break anything :)
terom
parents:
279
diff
changeset
|
13 |
expire(expire), |
e0e4dfc3e528
compiles cleanly with -Wall -Wextra -Wconversion, not tested, but that shouldn't break anything :)
terom
parents:
279
diff
changeset
|
14 |
reloadTimer(0), |
e0e4dfc3e528
compiles cleanly with -Wall -Wextra -Wconversion, not tested, but that shouldn't break anything :)
terom
parents:
279
diff
changeset
|
15 |
bounce(bounce) |
221 | 16 |
{ |
17 |
||
212 | 18 |
} |
19 |
||
221 | 20 |
void Weapon::tickReload (TimeMS dt) { |
21 |
reloadTimer -= dt; |
|
271
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
22 |
|
221 | 23 |
if (reloadTimer < 0) |
24 |
reloadTimer = 0; |
|
25 |
} |
|
26 |
||
271
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
27 |
bool Weapon::canShoot() const { |
221 | 28 |
return (reloadTimer == 0); |
29 |
} |
|
30 |
||
223 | 31 |
void Weapon::reload (void) { |
221 | 32 |
// set the reload timer |
33 |
reloadTimer = reloadTime; |
|
34 |
} |
|
35 |