Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6113 in orxonox.OLD for trunk/src/world_entities


Ignore:
Timestamp:
Dec 14, 2005, 4:44:13 PM (19 years ago)
Author:
bensch
Message:

trunk: copied new power-ups

Location:
trunk/src/world_entities
Files:
4 added
4 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/world_entities/power_ups/laser_power_up.cc

    r5994 r6113  
    2727CREATE_FACTORY(LaserPowerUp, CL_LASER_POWER_UP);
    2828
    29 LaserPowerUp::LaserPowerUp ()
     29LaserPowerUp::LaserPowerUp () : PowerUp(0.0, 1.0, 0.0)
    3030{
    3131  this->init();
    3232}
    3333
    34 LaserPowerUp::LaserPowerUp(const TiXmlElement* root)
     34LaserPowerUp::LaserPowerUp(const TiXmlElement* root) : PowerUp(0.0, 1.0, 0.0)
    3535{
    3636  this->init();
  • trunk/src/world_entities/power_ups/power_up.cc

    r5439 r6113  
    1010
    1111   ### File Specific:
    12    main-programmer: Benjamin Grauer
     12   main-programmer: Manuel Leuenberger
    1313   co-programmer: ...
    1414*/
     
    1818
    1919#include "power_up.h"
    20 
     20#include "extendable.h"
     21#include "primitive_model.h"
    2122
    2223using namespace std;
    2324
     25Model* PowerUp::sphereModel = NULL;
    2426
     27PowerUp::PowerUp(float r, float g, float b)
     28{
     29  if(!PowerUp::sphereModel) {
     30    PowerUp::sphereModel = new PrimitiveModel(PRIM_SPHERE, 7, 5);
     31  }
     32  this->sphereMaterial = new Material;
     33  this->sphereMaterial->setTransparency(.1);
     34  this->sphereMaterial->setDiffuse(r, g, b);
     35}
    2536
    26 PowerUp::PowerUp ()
     37PowerUp::~PowerUp ()
    2738{
    28   this->setClassID(CL_POWER_UP, "PowerUp");
    29 
     39  delete this->sphereMaterial;
    3040}
    3141
    3242
    33 
    34 PowerUp::~PowerUp () {}
     43void PowerUp::loadParams(const TiXmlElement* root)
     44{
     45  static_cast<WorldEntity*>(this)->loadParams(root);
     46}
    3547
    3648
    37 void PowerUp::loadParam(const TiXmlElement* root)
     49void PowerUp::collidesWith (WorldEntity* entity, const Vector& location)
    3850{
    39   static_cast<WorldEntity*>(this)->loadParams(root);
    40 
     51 if(entity->isA(CL_EXTENDABLE))
     52  {
     53    if(dynamic_cast<Extendable*>(entity)->pickup(this))
     54    {
     55      this->setVisibiliy(false);
     56    }
     57  }
    4158}
    4259
     60void PowerUp::draw() const
     61{
     62  WorldEntity::draw();
     63
     64  glMatrixMode(GL_MODELVIEW);
     65  glPushMatrix();
     66  float matrix[4][4];
     67
     68  /* translate */
     69  glTranslatef (this->getAbsCoor ().x,
     70                this->getAbsCoor ().y,
     71                this->getAbsCoor ().z);
     72  /* rotate */ // FIXME: devise a new Way to rotate this
     73  this->getAbsDir ().matrix (matrix);
     74  glMultMatrixf((float*)matrix);
     75
     76  this->sphereMaterial->select();
     77  sphereModel->draw();
     78
     79  glPopMatrix();
     80}
     81
     82const char* PowerUp::respawnTypes[] = {
     83  "none",
     84  "time"
     85};
     86
     87void PowerUp::setRespawnType(const char* type)
     88{
     89  for(int i = 0; i < RESPAWN_size; ++i) {
     90    if(strcmp(type, respawnTypes[i]) == 0) {
     91      this->respawnType = (PowerUpRespawn)i;
     92      break;
     93    }
     94  }
     95}
     96
  • trunk/src/world_entities/power_ups/power_up.h

    r5434 r6113  
    99#include "world_entity.h"
    1010
     11class Material;
     12
     13typedef enum PowerUpRespawn {
     14  RESPAWN_NONE,
     15  RESPAWN_TIME,
     16  RESPAWN_size
     17} PowerUpRespawn;
     18
    1119class PowerUp : public WorldEntity {
    1220
    13  public:
    14   PowerUp ();
     21public:
     22  void loadParams(const TiXmlElement* root);
     23  void collidesWith (WorldEntity* entity, const Vector& location);
     24
     25  virtual void draw () const;
     26  void setRespawnType(const char* type);
     27
     28protected:
     29  PowerUp(float r, float g, float b);
    1530  virtual ~PowerUp ();
    16   void loadParam(const TiXmlElement* root);
     31  virtual void respawn() {};
     32
     33  static Model* sphereModel;
     34
     35private:
     36  Material* sphereMaterial;
     37  PowerUpRespawn respawnType;
     38  static const char* respawnTypes[];
    1739};
    1840
  • trunk/src/world_entities/power_ups/turret_power_up.cc

    r5994 r6113  
    2727CREATE_FACTORY(TurretPowerUp, CL_TURRET_POWER_UP);
    2828
    29 TurretPowerUp::TurretPowerUp ()
     29TurretPowerUp::TurretPowerUp () : PowerUp(0.0, 1.0, 0.0)
    3030{
    3131  this->init();
    3232}
    3333
    34 TurretPowerUp::TurretPowerUp(const TiXmlElement* root)
     34TurretPowerUp::TurretPowerUp(const TiXmlElement* root) : PowerUp(0.0, 1.0, 0.0)
    3535{
    3636  this->init();
Note: See TracChangeset for help on using the changeset viewer.