src/Weapon.hh
author saiam
Sun, 07 Dec 2008 19:40:40 +0000
changeset 251 6a6208e5c7a1
parent 236 0048ba274152
child 253 747b1037d83e
permissions -rw-r--r--
Added recoil parameter for weapons, but it is not used yet.
212
4389c1e6b9b8 Weapon.cc&hh
nireco
parents:
diff changeset
     1
#ifndef WEAPON_HH
4389c1e6b9b8 Weapon.cc&hh
nireco
parents:
diff changeset
     2
#define WEAPON_HH
4389c1e6b9b8 Weapon.cc&hh
nireco
parents:
diff changeset
     3
221
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
     4
// forward-declare
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
     5
class Weapon;
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
     6
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
     7
#include "GameState.hh"
222
293ddf4c067d reorganize PhysicsObject/Player/Projectile lists so that PhysicsObject doesn't need to know about its subclasses anymore, and PhysicsWorld doesn't need to know about GameState
ekku
parents: 221
diff changeset
     8
#include "Projectile.hh"
212
4389c1e6b9b8 Weapon.cc&hh
nireco
parents:
diff changeset
     9
#include "Timer.hh"
4389c1e6b9b8 Weapon.cc&hh
nireco
parents:
diff changeset
    10
#include <string>
4389c1e6b9b8 Weapon.cc&hh
nireco
parents:
diff changeset
    11
4389c1e6b9b8 Weapon.cc&hh
nireco
parents:
diff changeset
    12
class Weapon {
221
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    13
protected:
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    14
    std::string name;
212
4389c1e6b9b8 Weapon.cc&hh
nireco
parents:
diff changeset
    15
    float velocity;
4389c1e6b9b8 Weapon.cc&hh
nireco
parents:
diff changeset
    16
    float explosionRadius;
4389c1e6b9b8 Weapon.cc&hh
nireco
parents:
diff changeset
    17
    int reloadTime; //in ms
251
6a6208e5c7a1 Added recoil parameter for weapons, but it is not used yet.
saiam
parents: 236
diff changeset
    18
    float recoil;
212
4389c1e6b9b8 Weapon.cc&hh
nireco
parents:
diff changeset
    19
4389c1e6b9b8 Weapon.cc&hh
nireco
parents:
diff changeset
    20
    int clipSize;
4389c1e6b9b8 Weapon.cc&hh
nireco
parents:
diff changeset
    21
221
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    22
    bool visible;
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    23
    TickCount age;
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    24
    int reloadTimer;
212
4389c1e6b9b8 Weapon.cc&hh
nireco
parents:
diff changeset
    25
221
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    26
public:
236
0048ba274152 move weapons definition out to Weapons.cc
terom
parents: 235
diff changeset
    27
    Weapon (TickCount age, float velocity, float explosionRadius, int reloadTime, std::string name);
221
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    28
    
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    29
    // advance the reload timer
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    30
    void tickReload (TimeMS dt);
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    31
    
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    32
    // can the weapon be fired (not reloading, have a clip, etc)
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    33
    bool canShoot (void);
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    34
    
223
2fcaf54ed37b basic network-projectiles
terom
parents: 222
diff changeset
    35
    // get weapon parameters
233
ff4ecea83cf5 start using CL_ResourceManager, change most draw methods to take a Graphics*, implment even better input handling, and draw weapon names
terom
parents: 223
diff changeset
    36
    std::string getName (void) { return name; }
235
0a0c729365ee code cleanup
terom
parents: 233
diff changeset
    37
    float getSpeed (void) { return velocity; }
223
2fcaf54ed37b basic network-projectiles
terom
parents: 222
diff changeset
    38
    float getExplosionRadius (void) { return explosionRadius; }
2fcaf54ed37b basic network-projectiles
terom
parents: 222
diff changeset
    39
    TickCount getExpireTicks (void) { return age; }
2fcaf54ed37b basic network-projectiles
terom
parents: 222
diff changeset
    40
    
2fcaf54ed37b basic network-projectiles
terom
parents: 222
diff changeset
    41
    // start reloading
2fcaf54ed37b basic network-projectiles
terom
parents: 222
diff changeset
    42
    void reload (void);
212
4389c1e6b9b8 Weapon.cc&hh
nireco
parents:
diff changeset
    43
};
4389c1e6b9b8 Weapon.cc&hh
nireco
parents:
diff changeset
    44
4389c1e6b9b8 Weapon.cc&hh
nireco
parents:
diff changeset
    45
#endif