src/Weapon.cc
author terom
Sun, 07 Dec 2008 23:10:30 +0000
changeset 271 bf6784a95b08
parent 263 8c999cf4c182
child 279 e36f5e1a1c8d
permissions -rw-r--r--
touch up weapon/projectile with comments and slight tweaking
212
4389c1e6b9b8 Weapon.cc&hh
nireco
parents:
diff changeset
     1
#include "Weapon.hh"
4389c1e6b9b8 Weapon.cc&hh
nireco
parents:
diff changeset
     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,
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
     4
        TimeMS reloadTime, std::string name) : 
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
     5
    id(id), expire(expire), velocity(velocity), recoil(recoil), explosionRadius(explosionRadius), radius(radius),
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
     6
    reloadTime(reloadTime), name(name), reloadTimer(0) 
221
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
     7
{
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
     8
212
4389c1e6b9b8 Weapon.cc&hh
nireco
parents:
diff changeset
     9
}
4389c1e6b9b8 Weapon.cc&hh
nireco
parents:
diff changeset
    10
221
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    11
void Weapon::tickReload (TimeMS dt) {
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    12
    reloadTimer -= dt;
271
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    13
221
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    14
    if (reloadTimer < 0)
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    15
        reloadTimer = 0;
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    16
}
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    17
271
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    18
bool Weapon::canShoot() const {
221
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    19
    return (reloadTimer == 0);
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    20
}
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    21
223
2fcaf54ed37b basic network-projectiles
terom
parents: 221
diff changeset
    22
void Weapon::reload (void) {
221
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    23
    // set the reload timer
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    24
    reloadTimer = reloadTime;
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    25
}
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    26