src/Projectile.hh
author terom
Mon, 08 Dec 2008 12:46:37 +0000
changeset 283 7540b0859579
parent 276 87434abc1ba1
child 296 4d3ebaa29430
permissions -rw-r--r--
start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
197
d9ac888de778 Hajotetaan lis??
ekku
parents:
diff changeset
     1
#ifndef PROJECTILE_HH
d9ac888de778 Hajotetaan lis??
ekku
parents:
diff changeset
     2
#define PROJECTILE_HH
d9ac888de778 Hajotetaan lis??
ekku
parents:
diff changeset
     3
 
201
135616467a0a rename Shot -> Projectile
terom
parents: 197
diff changeset
     4
class Projectile;
197
d9ac888de778 Hajotetaan lis??
ekku
parents:
diff changeset
     5
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: 211
diff changeset
     6
#include "GameState.hh"
197
d9ac888de778 Hajotetaan lis??
ekku
parents:
diff changeset
     7
#include "PhysicsObject.hh"
208
7709571e1131 Digging now uses projectiles.
saiam
parents: 204
diff changeset
     8
#include "Timer.hh"
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: 224
diff changeset
     9
#include "GraphicsPointer.hh"
197
d9ac888de778 Hajotetaan lis??
ekku
parents:
diff changeset
    10
283
7540b0859579 start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents: 276
diff changeset
    11
/**
7540b0859579 start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents: 276
diff changeset
    12
 * A projectile is a flying PhysicsObject, created by firing a player's weapon. It has an initial velocity, is
7540b0859579 start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents: 276
diff changeset
    13
 * represented as a diamond-shape with the given "radius", can explode or bounce on collisions, expires at some point,
7540b0859579 start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents: 276
diff changeset
    14
 * and can remove ground around it upon exploding.
7540b0859579 start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents: 276
diff changeset
    15
 */
201
135616467a0a rename Shot -> Projectile
terom
parents: 197
diff changeset
    16
class Projectile : public PhysicsObject {
197
d9ac888de778 Hajotetaan lis??
ekku
parents:
diff changeset
    17
protected:
271
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    18
    /**
276
87434abc1ba1 ability to send NetworkObjectID's via packets, modify Network Projectiles to use this and fix recoil/reloading
terom
parents: 272
diff changeset
    19
     * Which player fired this projectile?
271
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    20
     */
276
87434abc1ba1 ability to send NetworkObjectID's via packets, modify Network Projectiles to use this and fix recoil/reloading
terom
parents: 272
diff changeset
    21
    Player *player;
271
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    22
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    23
    /**
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    24
     * Projectiles can be inivisble, e.g. for digging
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    25
     */
197
d9ac888de778 Hajotetaan lis??
ekku
parents:
diff changeset
    26
    bool visible;
271
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    27
    
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    28
    /**
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    29
     * The projectile is diamond-shaped, and this is the dimanond's "radius"
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    30
     */
208
7709571e1131 Digging now uses projectiles.
saiam
parents: 204
diff changeset
    31
    float radius;
271
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    32
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    33
    /**
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    34
     * The radius of earth removed by this projectile on impact
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    35
     */
263
8c999cf4c182 weapon projectile radiuses and fix network play (local_player == NULL, Rope releasing upon being hit
terom
parents: 255
diff changeset
    36
    float explosionRadius;
223
2fcaf54ed37b basic network-projectiles
terom
parents: 222
diff changeset
    37
271
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    38
    /**
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    39
     * How many ticks this projectile lasts before being expiring
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    40
     */
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    41
    TickCount expire;
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    42
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    43
    /**
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    44
     * The tick we were spawned at
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    45
     */
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    46
    TickCount birth_tick;
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    47
197
d9ac888de778 Hajotetaan lis??
ekku
parents:
diff changeset
    48
public:
271
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    49
    /**
276
87434abc1ba1 ability to send NetworkObjectID's via packets, modify Network Projectiles to use this and fix recoil/reloading
terom
parents: 272
diff changeset
    50
     * Constructs this projectile using the given position/velocity, pulling the rest of the parameter values from the
87434abc1ba1 ability to send NetworkObjectID's via packets, modify Network Projectiles to use this and fix recoil/reloading
terom
parents: 272
diff changeset
    51
     * given weapon. The given player is assigned to this projectile. 
271
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    52
     */
276
87434abc1ba1 ability to send NetworkObjectID's via packets, modify Network Projectiles to use this and fix recoil/reloading
terom
parents: 272
diff changeset
    53
    Projectile (Player *player, Vector position, Vector velocity, Weapon *weapon, bool visible = true);
271
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    54
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    55
    /**
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    56
     * Removes this from the world's list of projectiles
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    57
     */
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: 211
diff changeset
    58
    virtual ~Projectile (void);
271
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    59
    
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    60
    /**
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    61
     * Draw
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    62
     */
255
99431fdb0dc8 add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents: 252
diff changeset
    63
    virtual void draw (Graphics *g, PixelCoordinate camera) const;
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: 211
diff changeset
    64
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: 211
diff changeset
    65
protected:
252
25054ce94d07 Rope is released if the ground on the pivot point is destroyed.
ekku
parents: 248
diff changeset
    66
    /**
224
e6faefba2ec1 fixed logger, and network projectiles should work reasonably well now
terom
parents: 223
diff changeset
    67
     * Removes ground at given position if applicable, and destroys this PhysicsObject.
e6faefba2ec1 fixed logger, and network projectiles should work reasonably well now
terom
parents: 223
diff changeset
    68
     *
e6faefba2ec1 fixed logger, and network projectiles should work reasonably well now
terom
parents: 223
diff changeset
    69
     * This is overriden by Network.
e6faefba2ec1 fixed logger, and network projectiles should work reasonably well now
terom
parents: 223
diff changeset
    70
     */
e6faefba2ec1 fixed logger, and network projectiles should work reasonably well now
terom
parents: 223
diff changeset
    71
    virtual void onDestroy (Vector position, bool removeGround);
e6faefba2ec1 fixed logger, and network projectiles should work reasonably well now
terom
parents: 223
diff changeset
    72
    
252
25054ce94d07 Rope is released if the ground on the pivot point is destroyed.
ekku
parents: 248
diff changeset
    73
    /**
224
e6faefba2ec1 fixed logger, and network projectiles should work reasonably well now
terom
parents: 223
diff changeset
    74
     * Call onDestroy, removingGround
e6faefba2ec1 fixed logger, and network projectiles should work reasonably well now
terom
parents: 223
diff changeset
    75
     */
272
97de051edbcf Added PhysicsObject* attribute to onCollision
saiam
parents: 271
diff changeset
    76
    virtual void onCollision (Vector collisionPoint, PhysicsObject *other);
224
e6faefba2ec1 fixed logger, and network projectiles should work reasonably well now
terom
parents: 223
diff changeset
    77
252
25054ce94d07 Rope is released if the ground on the pivot point is destroyed.
ekku
parents: 248
diff changeset
    78
    /**
271
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    79
     * If we have expired, call onDestory and removeGround
224
e6faefba2ec1 fixed logger, and network projectiles should work reasonably well now
terom
parents: 223
diff changeset
    80
     */
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: 211
diff changeset
    81
    virtual void tick (TimeMS dt);
197
d9ac888de778 Hajotetaan lis??
ekku
parents:
diff changeset
    82
};
d9ac888de778 Hajotetaan lis??
ekku
parents:
diff changeset
    83
 
d9ac888de778 Hajotetaan lis??
ekku
parents:
diff changeset
    84
#endif