Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields

projectile.h

00001 /***************************************************************************
00002                           projectile.h  -  description
00003                              -------------------
00004     begin                : Sat May 3 2003
00005     copyright            : (C) 2003 by Gabor Torok
00006     email                : cctorok@yahoo.com
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #ifndef PROJECTILE_H
00019 #define PROJECTILE_H
00020 
00021 #include <map>
00022 #include <vector>
00023 #include "creature.h"
00024 #include "item.h"
00025 #include "rpg/character.h"
00026 #include "rpg/monster.h"
00027 #include "rpg/spell.h"
00028 #include "effect.h"
00029 #include "shape.h"
00030 
00031 class Creature;
00032 class Item;
00033 class Spell;
00034 
00035 using namespace std;
00036 
00041 class Projectile {
00042  private:
00043   Creature *creature, *target;
00044   float tx, ty;
00045   int tw, td;
00046   Item *item;
00047   Spell *spell;
00048   float sx, sy, ex, ey; 
00049   float angle;
00050   float parabolic;
00051   int q;
00052   int cx, cy;
00053   int steps;
00054   Shape *shape;
00055   float maxDist;
00056   float startX, startY, distToTarget;
00057   bool stopOnImpact;
00058   bool seeker;
00059 
00060   static map<Creature*, vector<Projectile*>*> projectiles;
00061   static Uint32 lastProjectileTick;
00062   
00063  public:
00064   Projectile(Creature *creature, Creature *target, Item *item, Shape *shape, float parabolic=0.0f, bool stopOnImpact=true, bool seeker=false);
00065   Projectile(Creature *creature, Creature *target, Spell *spell, Shape *shape, float parabolic=0.0f, bool stopOnImpact=true, bool seeker=false);
00066   Projectile(Creature *creature, int x, int y, int w, int d, Spell *spell, Shape *shape, float parabolic=0.0f, bool stopOnImpact=true);
00067   virtual ~Projectile();
00068 
00069   inline bool doesStopOnImpact() { return stopOnImpact; }
00070 
00071   // return true when out of moves
00072   bool move();
00073 
00074   inline float getX() { return sx; }
00075   inline float getY() { return sy; }
00076   inline float getAngle() { return angle; }
00077   inline Shape *getShape() { return shape; }
00078   inline Creature *getCreature() { return creature; }
00079   inline Item *getItem() { return item; }
00080   inline Spell *getSpell() { return spell; }
00081 
00082   static Projectile *addProjectile(Creature *creature, Creature *target, 
00083                                                                    Item *item, Shape *shape, 
00084                                                                    int maxProjectiles, bool stopOnImpact=true);
00085   static Projectile *addProjectile(Creature *creature, Creature *target, 
00086                                                                    Spell *spell, Shape *shape, 
00087                                                                    int maxProjectiles, bool stopOnImpact=true);
00088   static Projectile *addProjectile(Creature *creature, int x, int y, int w, int d, 
00089                                                                    Spell *spell, Shape *shape, 
00090                                                                    int maxProjectiles, bool stopOnImpact=true);
00091   static void removeProjectile(Projectile *p);
00092   static void moveProjectiles(Scourge *scourge);
00093   inline static map<Creature *, vector<Projectile*>*> *getProjectileMap() { return &projectiles; }
00094   static void resetProjectiles();
00095   bool atTargetLocation();
00096   void debug();
00097 
00098  protected:
00099   void commonInit();
00100   void calculateAngle();
00101 };
00102 
00103 #endif

Generated on Thu Jun 16 21:50:43 2005 for scourge by  doxygen 1.4.0