author | ekku |
Mon, 08 Dec 2008 15:59:33 +0000 | |
changeset 287 | f59c8dee7f91 |
parent 282 | e0e4dfc3e528 |
child 305 | 56799ec8d7be |
permissions | -rw-r--r-- |
212 | 1 |
#include "Weapon.hh" |
2 |
||
271
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
3 |
Weapon::Weapon(WeaponID id, TickCount expire, float velocity, float recoil, 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), |
e0e4dfc3e528
compiles cleanly with -Wall -Wextra -Wconversion, not tested, but that shouldn't break anything :)
terom
parents:
279
diff
changeset
|
8 |
explosionRadius(explosionRadius), |
e0e4dfc3e528
compiles cleanly with -Wall -Wextra -Wconversion, not tested, but that shouldn't break anything :)
terom
parents:
279
diff
changeset
|
9 |
radius(radius), |
e0e4dfc3e528
compiles cleanly with -Wall -Wextra -Wconversion, not tested, but that shouldn't break anything :)
terom
parents:
279
diff
changeset
|
10 |
reloadTime(reloadTime), |
e0e4dfc3e528
compiles cleanly with -Wall -Wextra -Wconversion, not tested, but that shouldn't break anything :)
terom
parents:
279
diff
changeset
|
11 |
recoil(recoil), |
e0e4dfc3e528
compiles cleanly with -Wall -Wextra -Wconversion, not tested, but that shouldn't break anything :)
terom
parents:
279
diff
changeset
|
12 |
expire(expire), |
e0e4dfc3e528
compiles cleanly with -Wall -Wextra -Wconversion, not tested, but that shouldn't break anything :)
terom
parents:
279
diff
changeset
|
13 |
reloadTimer(0), |
e0e4dfc3e528
compiles cleanly with -Wall -Wextra -Wconversion, not tested, but that shouldn't break anything :)
terom
parents:
279
diff
changeset
|
14 |
bounce(bounce) |
221 | 15 |
{ |
16 |
||
212 | 17 |
} |
18 |
||
221 | 19 |
void Weapon::tickReload (TimeMS dt) { |
20 |
reloadTimer -= dt; |
|
271
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
21 |
|
221 | 22 |
if (reloadTimer < 0) |
23 |
reloadTimer = 0; |
|
24 |
} |
|
25 |
||
271
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
26 |
bool Weapon::canShoot() const { |
221 | 27 |
return (reloadTimer == 0); |
28 |
} |
|
29 |
||
223 | 30 |
void Weapon::reload (void) { |
221 | 31 |
// set the reload timer |
32 |
reloadTimer = reloadTime; |
|
33 |
} |
|
34 |