Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5435 in orxonox.OLD for trunk/src/world_entities/power_ups


Ignore:
Timestamp:
Oct 25, 2005, 5:31:54 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: power-ups implemented (simple-mode)

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  
    1717#include "turret_power_up.h"
    1818#include "factory.h"
     19#include "state.h"
     20#include "list.h"
    1921
    2022using namespace std;
    2123
    2224CREATE_FACTORY(TurretPowerUp);
     25
     26GLUquadricObj* TurretPowerUp_sphereObj = NULL;
     27Material*      TurretPowerUp_sphereMat = NULL;
    2328
    2429
     
    3641
    3742
    38 TurretPowerUp::~TurretPowerUp () {}
     43TurretPowerUp::~TurretPowerUp () {
     44
     45}
    3946
    4047
     
    4249{
    4350  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;
    4562}
    4663
     
    5168
    5269}
     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 */
     78void 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*/
     91void 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*/
     104void 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  
    1616  virtual ~TurretPowerUp ();
    1717
     18  virtual void TurretPowerUp::collidesWith(WorldEntity* entity, const Vector& location);
     19  virtual void tick(float dt);
     20  virtual void draw();
     21
    1822  private:
    1923   void init();
    2024   void loadParams(const TiXmlElement* root);
     25
     26  private:
     27   Vector              rotation;
     28   float               cycle;
    2129};
    2230
Note: See TracChangeset for help on using the changeset viewer.