ekku@197: #ifndef PROJECTILE_HH ekku@197: #define PROJECTILE_HH ekku@197: terom@201: class Projectile; ekku@197: ekku@222: #include "GameState.hh" terom@296: #include "Player.hh" ekku@197: #include "PhysicsObject.hh" saiam@208: #include "Timer.hh" terom@296: #include "Types.hh" terom@412: terom@412: #include "Graphics/Drawable.hh" ekku@197: terom@283: /** terom@283: * A projectile is a flying PhysicsObject, created by firing a player's weapon. It has an initial velocity, is terom@283: * represented as a diamond-shape with the given "radius", can explode or bounce on collisions, expires at some point, terom@283: * and can remove ground around it upon exploding. terom@283: */ terom@201: class Projectile : public PhysicsObject { ekku@197: protected: terom@271: /** terom@276: * Which player fired this projectile? terom@271: */ terom@276: Player *player; terom@271: terom@271: /** terom@271: * Projectiles can be inivisble, e.g. for digging terom@271: */ ekku@197: bool visible; terom@271: ekku@305: Weapon *weapon; terom@271: terom@271: /** terom@271: * The tick we were spawned at terom@271: */ terom@271: TickCount birth_tick; terom@271: ekku@197: public: terom@271: /** terom@276: * Constructs this projectile using the given position/velocity, pulling the rest of the parameter values from the terom@276: * given weapon. The given player is assigned to this projectile. terom@271: */ terom@276: Projectile (Player *player, Vector position, Vector velocity, Weapon *weapon, bool visible = true); terom@271: terom@271: /** terom@271: * Removes this from the world's list of projectiles terom@271: */ ekku@222: virtual ~Projectile (void); terom@271: terom@271: /** saiam@308: * Get damage inflicted by this projectile. saiam@308: * saiam@308: * @return Damage inflicted by projectile. saiam@308: */ saiam@308: Health getDamage (); saiam@308: saiam@308: /** saiam@308: * Adds one kill to projectile owner. saiam@308: */ saiam@308: void addKillToOwner (); saiam@308: saiam@309: /** saiam@309: * Return the owner of the projectile. saiam@309: */ saiam@309: const Player* getOwner (); saiam@309: ekku@222: protected: ekku@252: /** terom@224: * Removes ground at given position if applicable, and destroys this PhysicsObject. terom@224: * terom@224: * This is overriden by Network. terom@224: */ terom@224: virtual void onDestroy (Vector position, bool removeGround); terom@296: terom@296: /** terom@296: * This Projectile has hit the given player. terom@296: * terom@296: * This Projectile inflicts a certain amount of damage on the player. We are not destroyed, this can be called terom@296: * multiple times... terom@296: */ saiam@308: virtual void onHitPlayer (Player *player); terom@224: ekku@252: /** terom@224: * Call onDestroy, removingGround terom@224: */ saiam@272: virtual void onCollision (Vector collisionPoint, PhysicsObject *other); terom@224: ekku@252: /** terom@271: * If we have expired, call onDestory and removeGround terom@224: */ ekku@222: virtual void tick (TimeMS dt); terom@417: terom@417: public: terom@417: terom@417: #if GRAPHICS_ENABLED terom@417: /** terom@417: * Draw terom@417: */ terom@417: virtual void draw (graphics::Display &display, PixelCoordinate camera) const; terom@417: terom@417: #endif terom@417: terom@417: ekku@197: }; ekku@197: ekku@197: #endif