Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5965 in orxonox.OLD for branches/powerups


Ignore:
Timestamp:
Dec 7, 2005, 3:45:26 PM (19 years ago)
Author:
manuel
Message:

many changes:
created generic weapon_power_up that can contain any kind of weapon
space_ship is now extendable and can pickup weapon_power_ups

Location:
branches/powerups/src
Files:
7 edited
2 copied

Legend:

Unmodified
Added
Removed
  • branches/powerups/src/Makefile.am

    r5955 r5965  
    7979                  world_entities/power_ups/turret_power_up.cc \
    8080                  world_entities/power_ups/laser_power_up.cc \
     81                  world_entities/power_ups/weapon_power_up.cc \
    8182                  world_entities/space_ships/space_ship.cc \
    8283                  subprojects/benchmark.cc
  • branches/powerups/src/defs/class_id.h

    r5955 r5965  
    8888  CL_WEAPON                     =    0x00210000,
    8989  CL_POWER_UP                   =    0x00220000,
    90   CL_EXTENDABLE                 =    0x00140000,
     90  CL_EXTENDABLE                 =    0x00240000,
    9191  // SUPER-Modeling
    9292  CL_TEXTURE                    =    0x00c01000,
     
    149149  CL_TURRET_POWER_UP            =    0x00000211,
    150150  CL_LASER_POWER_UP             =    0x00000212,
     151  CL_WEAPON_POWER_UP            =    0x00000213,
     152  CL_SHIELD_POWER_UP            =    0x00000214,
    151153
    152154  CL_TEST_GUN                   =    0x00000230,
  • branches/powerups/src/lib/sound/sound_engine.cc

    r5955 r5965  
    289289
    290290  // INITIALIZING THE DEVICE:
    291 #ifndef AL_VERSION_1_1
    292   ALubyte deviceName[] =
    293 #else
    294291  ALCchar deviceName[] =
    295 #endif
    296292#ifdef __WIN32__
    297293      "Direct3D";
  • branches/powerups/src/world_entities/extendable.h

    r5874 r5965  
    77#define _EXTENDABLE_H
    88
     9#include "base_object.h"
     10
    911// FORWARD DECLARATION
    10 
     12class PowerUp;
    1113
    1214
    1315//! A class for ...
    14 class Extendable : public BaseObject {
     16class Extendable : virtual public BaseObject {
    1517
    1618 public:
  • branches/powerups/src/world_entities/power_ups/weapon_power_up.cc

    r5958 r5965  
    1616#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY
    1717
    18 #include "laser_power_up.h"
     18#include "weapon_power_up.h"
    1919#include "factory.h"
    2020#include "state.h"
     
    2525using namespace std;
    2626
    27 CREATE_FACTORY(LaserPowerUp, CL_LASER_POWER_UP);
     27CREATE_FACTORY(WeaponPowerUp, CL_WEAPON_POWER_UP);
    2828
    29 LaserPowerUp::LaserPowerUp ()
     29WeaponPowerUp::WeaponPowerUp ()
    3030{
    3131  this->init();
    3232}
    3333
    34 LaserPowerUp::LaserPowerUp(const TiXmlElement* root)
     34WeaponPowerUp::WeaponPowerUp(const TiXmlElement* root)
    3535{
    3636  this->init();
    37 
    3837  this->loadParams(root);
    3938}
    4039
    4140
    42 LaserPowerUp::~LaserPowerUp ()
     41WeaponPowerUp::~WeaponPowerUp ()
    4342{
    44   delete this->sphereModel;
    45   delete this->sphereMaterial;
    4643}
    4744
    4845
    49 void LaserPowerUp::init()
     46void WeaponPowerUp::init()
    5047{
    51   this->setClassID(CL_LASER_POWER_UP, "LaserPowerUp");
    52   this->loadModel("models/guns/test_gun.obj", 2.0);
    53 
    54   this->sphereModel = new PrimitiveModel(PRIM_SPHERE, 7, 5);
    55   this->sphereMaterial = new Material;
    56   this->sphereMaterial->setTransparency(.1);
    57   this->sphereMaterial->setDiffuse(.7, .7, .1);
    58 
    59   this->rotation = Vector(0,1,0);
    60   this->cycle    = (float)rand()/RAND_MAX*M_2_PI;
    61   this->shiftDir(Quaternion((float)rand()/RAND_MAX*M_2_PI, this->rotation));
    6248}
    6349
    6450
    65 void LaserPowerUp::loadParams(const TiXmlElement* root)
     51void WeaponPowerUp::loadParams(const TiXmlElement* root)
    6652{
    6753  static_cast<PowerUp*>(this)->loadParams(root);
     
    6955}
    7056
    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 LaserPowerUp::collidesWith(WorldEntity* entity, const Vector& location)
     57Weapon* WeaponPowerUp::getWeapon()
    7958{
    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_PLAYABLE))
    82   State::getWorldEntityList()->remove(this);
     59  return dynamic_cast<Weapon*>(Factory::getFirst()->fabricate(this->getWeaponID()));
    8360}
    8461
    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 LaserPowerUp::tick(float dt)
     62ClassID WeaponPowerUp::getWeaponID()
    9263{
    93   this->shiftDir(Quaternion(dt, this->rotation));
    94   this->cycle+=dt;
    95 
     64  return this->weaponID;
    9665}
    9766
    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 LaserPowerUp::draw() const
    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   this->model->draw();
    115 
    116   this->sphereMaterial->select();
    117   this->sphereModel->draw();
    118   glPopMatrix();
     67long WeaponPowerUp::getCapsNeeded()
     68{
     69  return this->capsNeeded;
    11970}
    120 
  • branches/powerups/src/world_entities/power_ups/weapon_power_up.h

    r5958 r5965  
    11/*!
    2  * @file laser_power_up.h
    3  * @brief A class representing a PowerUp in the world.
     2 * @file weapon_power_up.h
     3 * @brief A class representing a PowerUp containing a weapon.
    44*/
    55
    6 #ifndef _LASER_POWER_UP_H
    7 #define _LASER_POWER_UP_H
     6#ifndef _WEAPON_POWER_UP_H
     7#define _WEAPON_POWER_UP_H
    88
    99#include "power_up.h"
     10#include "weapons/weapon.h"
    1011
    1112/* FORWARD DEFINITION */
    12 class Material;
    1313
    14 class LaserPowerUp : public PowerUp {
     14class WeaponPowerUp : public PowerUp {
    1515
    16  public:
    17   LaserPowerUp();
    18   LaserPowerUp(const TiXmlElement* root);
    19   virtual ~LaserPowerUp ();
     16public:
     17  WeaponPowerUp();
     18  WeaponPowerUp(const TiXmlElement* root);
     19  virtual ~WeaponPowerUp ();
    2020
    21   virtual void LaserPowerUp::collidesWith(WorldEntity* entity, const Vector& location);
    22   virtual void tick(float dt);
    23   virtual void draw() const;
     21  Weapon* getWeapon();
     22  ClassID getWeaponID();
     23  long getCapsNeeded();
    2424
    25   private:
    26    void init();
    27    void loadParams(const TiXmlElement* root);
     25private:
     26  void init();
     27  void loadParams(const TiXmlElement* root);
    2828
    29   private:
    30    Vector              rotation;
    31    float               cycle;
    32 
    33    Model*              sphereModel;
    34    Material*           sphereMaterial;
     29private:
     30  ClassID weaponID;
     31  long capsNeeded;
    3532};
    3633
    37 #endif /* _LASER_POWER_UP_H */
     34#endif /* _WEAPON_POWER_UP_H */
  • branches/powerups/src/world_entities/space_ships/space_ship.cc

    r5955 r5965  
    1717#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY
    1818
     19#include "space_ship.h"
     20
    1921#include "executor/executor.h"
    20 #include "space_ship.h"
    2122
    2223#include "objModel.h"
     
    3031#include "factory.h"
    3132#include "key_mapper.h"
     33
     34#include "power_ups/weapon_power_up.h"
    3235
    3336using namespace std;
     
    368371}
    369372
     373/**
     374 *
     375 */
     376bool SpaceShip::pickup(PowerUp* powerUp)
     377{
     378  if(powerUp->isA(CL_WEAPON_POWER_UP)) {
     379    WeaponPowerUp* wpu = dynamic_cast<WeaponPowerUp*>(powerUp);
     380    WeaponManager* manager = this->getWeaponManager();
     381    int slot = manager->getNextFreeSlot(0, wpu->getCapsNeeded());
     382    if(slot >= 0) {
     383      manager->addWeapon(wpu->getWeapon(), 0, slot);
     384      return true;
     385    }
     386  }
     387  else if(powerUp->isA(CL_SHIELD_POWER_UP)) {
     388
     389  }
     390  return false;
     391}
     392
    370393#include "weapons/aiming_turret.h"
    371394// FIXME THIS MIGHT BE CONSIDERED EITHER A FEATURE, OR A BUG
  • branches/powerups/src/world_entities/space_ships/space_ship.h

    r5955 r5965  
    88
    99#include "playable.h"
     10#include "extendable.h"
    1011
    1112template<class T> class tList;
     
    1314class Event;
    1415
    15 class SpaceShip : public Playable
     16class SpaceShip : public Playable, public Extendable
    1617{
    1718
     
    3738
    3839    virtual void process(const Event &event);
     40
     41    bool pickup(PowerUp* powerUp);
    3942
    4043
  • branches/powerups/src/world_entities/weapons/weapon_manager.cc

    r5955 r5965  
    408408
    409409/**
    410  * private gets the next free slot in a certain weaponconfig
     410 * gets the next free slot in a certain weaponconfig
    411411 * @param the selected weaponconfig
    412412 */
    413413int WeaponManager::getNextFreeSlot(int configID, long capability)
    414414{
    415   for( int i = 0; i < this->slotCount; ++i)
    416   {
    417     if( this->configs[configID][i] == NULL &&
    418         (this->currentSlotConfig[i].capability & capability & WTYPE_ALLKINDS) &&
    419         (this->currentSlotConfig[i].capability & capability & WTYPE_ALLDIRS))
    420       return i;
    421   }
     415  /*if(configID == -1) {
     416    for(int i = 0; i < WM_MAX_CONFIGS; ++i)
     417    {
     418      int slot = this->getNextFreeSlot(i, capability);
     419      if(slot >= 0) return slot;
     420    }
     421  }
     422  else {*/
     423    for( int i = 0; i < this->slotCount; ++i)
     424    {
     425      if( this->configs[configID][i] == NULL &&
     426          (this->currentSlotConfig[i].capability & capability & WTYPE_ALLKINDS) &&
     427          (this->currentSlotConfig[i].capability & capability & WTYPE_ALLDIRS))
     428        return i;
     429    }
     430  //}
    422431  return -1;
    423432}
Note: See TracChangeset for help on using the changeset viewer.