Changeset 5435 in orxonox.OLD for trunk/src/world_entities/power_ups
- Timestamp:
- Oct 25, 2005, 5:31:54 PM (19 years ago)
- Location:
- trunk/src/world_entities/power_ups
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/world_entities/power_ups/turret_power_up.cc
r5434 r5435 17 17 #include "turret_power_up.h" 18 18 #include "factory.h" 19 #include "state.h" 20 #include "list.h" 19 21 20 22 using namespace std; 21 23 22 24 CREATE_FACTORY(TurretPowerUp); 25 26 GLUquadricObj* TurretPowerUp_sphereObj = NULL; 27 Material* TurretPowerUp_sphereMat = NULL; 23 28 24 29 … … 36 41 37 42 38 TurretPowerUp::~TurretPowerUp () {} 43 TurretPowerUp::~TurretPowerUp () { 44 45 } 39 46 40 47 … … 42 49 { 43 50 this->setClassID(CL_TURRET_POWER_UP, "TurretPowerUp"); 44 this->loadModel("models/guns/turret1.obj"); 51 this->loadModelWithScale("models/guns/turret1.obj", 2.0); 52 53 if (TurretPowerUp_sphereObj == NULL) 54 TurretPowerUp_sphereObj = gluNewQuadric(); 55 if(TurretPowerUp_sphereMat == NULL) 56 { 57 TurretPowerUp_sphereMat = new Material("TurretPowerUp_Sphere"); 58 TurretPowerUp_sphereMat->setTransparency(.1); 59 } 60 this->rotation = Vector(0,1,0); 61 this->cycle = 0; 45 62 } 46 63 … … 51 68 52 69 } 70 71 72 /** 73 * this function is called, when two entities collide 74 * @param entity: the world entity with whom it collides 75 * 76 * Implement behaviour like damage application or other miscellaneous collision stuff in this function 77 */ 78 void TurretPowerUp::collidesWith(WorldEntity* entity, const Vector& location) 79 { 80 // PRINTF(3)("collision %s vs %s @ (%f,%f,%f)\n", this->getClassName(), entity->getClassName(), location.x, location.y, location.z); 81 if (entity->isA(CL_PLAYER)) 82 State::getWorldEntityList()->remove(this); 83 } 84 85 /** 86 * this method is called every frame 87 * @param time: the time in seconds that has passed since the last tick 88 * 89 * Handle all stuff that should update with time inside this method (movement, animation, etc.) 90 */ 91 void TurretPowerUp::tick(float dt) 92 { 93 this->shiftDir(Quaternion(dt, this->rotation)); 94 this->cycle+=dt; 95 96 } 97 98 /** 99 * the entity is drawn onto the screen with this function 100 * 101 * This is a central function of an entity: call it to let the entity painted to the screen. 102 * Just override this function with whatever you want to be drawn. 103 */ 104 void TurretPowerUp::draw() 105 { glMatrixMode(GL_MODELVIEW); 106 glPushMatrix(); 107 /* translate */ 108 glTranslatef (this->getAbsCoor ().x, 109 this->getAbsCoor ().y + cos(this->cycle*3.0)*2.0, 110 this->getAbsCoor ().z); 111 /* rotate */ 112 Vector tmpRot = this->getAbsDir().getSpacialAxis(); 113 glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z ); 114 TurretPowerUp_sphereMat->select(); 115 // gluSphere(TurretPowerUp_sphereObj, 3, 5, 5); 116 this->model->draw(); 117 glPopMatrix(); 118 119 } 120 -
trunk/src/world_entities/power_ups/turret_power_up.h
r5434 r5435 16 16 virtual ~TurretPowerUp (); 17 17 18 virtual void TurretPowerUp::collidesWith(WorldEntity* entity, const Vector& location); 19 virtual void tick(float dt); 20 virtual void draw(); 21 18 22 private: 19 23 void init(); 20 24 void loadParams(const TiXmlElement* root); 25 26 private: 27 Vector rotation; 28 float cycle; 21 29 }; 22 30
Note: See TracChangeset
for help on using the changeset viewer.