src/Weapon.cc
author terom
Sat, 06 Dec 2008 23:47:13 +0000
changeset 236 0048ba274152
parent 223 2fcaf54ed37b
child 253 747b1037d83e
permissions -rw-r--r--
move weapons definition out to Weapons.cc
212
4389c1e6b9b8 Weapon.cc&hh
nireco
parents:
diff changeset
     1
#include "Weapon.hh"
4389c1e6b9b8 Weapon.cc&hh
nireco
parents:
diff changeset
     2
236
0048ba274152 move weapons definition out to Weapons.cc
terom
parents: 223
diff changeset
     3
Weapon::Weapon(TickCount age, float velocity, float explosionRadius, int reloadTime, std::string name) : 
0048ba274152 move weapons definition out to Weapons.cc
terom
parents: 223
diff changeset
     4
    age(age), velocity(velocity), explosionRadius(explosionRadius), reloadTime(reloadTime), name(name), reloadTimer(0) 
221
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
     5
{
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
     6
212
4389c1e6b9b8 Weapon.cc&hh
nireco
parents:
diff changeset
     7
}
4389c1e6b9b8 Weapon.cc&hh
nireco
parents:
diff changeset
     8
221
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
     9
void Weapon::tickReload (TimeMS dt) {
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    10
    reloadTimer -= dt;
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    11
    if (reloadTimer < 0)
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    12
        reloadTimer = 0;
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    13
}
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    14
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    15
bool Weapon::canShoot() {
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    16
    return (reloadTimer == 0);
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    17
}
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    18
223
2fcaf54ed37b basic network-projectiles
terom
parents: 221
diff changeset
    19
void Weapon::reload (void) {
221
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    20
    // set the reload timer
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    21
    reloadTimer = reloadTime;
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    22
}
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    23