Changeset 5965 in orxonox.OLD for branches/powerups
- Timestamp:
- Dec 7, 2005, 3:45:26 PM (19 years ago)
- Location:
- branches/powerups/src
- Files:
-
- 7 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/powerups/src/Makefile.am
r5955 r5965 79 79 world_entities/power_ups/turret_power_up.cc \ 80 80 world_entities/power_ups/laser_power_up.cc \ 81 world_entities/power_ups/weapon_power_up.cc \ 81 82 world_entities/space_ships/space_ship.cc \ 82 83 subprojects/benchmark.cc -
branches/powerups/src/defs/class_id.h
r5955 r5965 88 88 CL_WEAPON = 0x00210000, 89 89 CL_POWER_UP = 0x00220000, 90 CL_EXTENDABLE = 0x00 140000,90 CL_EXTENDABLE = 0x00240000, 91 91 // SUPER-Modeling 92 92 CL_TEXTURE = 0x00c01000, … … 149 149 CL_TURRET_POWER_UP = 0x00000211, 150 150 CL_LASER_POWER_UP = 0x00000212, 151 CL_WEAPON_POWER_UP = 0x00000213, 152 CL_SHIELD_POWER_UP = 0x00000214, 151 153 152 154 CL_TEST_GUN = 0x00000230, -
branches/powerups/src/lib/sound/sound_engine.cc
r5955 r5965 289 289 290 290 // INITIALIZING THE DEVICE: 291 #ifndef AL_VERSION_1_1292 ALubyte deviceName[] =293 #else294 291 ALCchar deviceName[] = 295 #endif296 292 #ifdef __WIN32__ 297 293 "Direct3D"; -
branches/powerups/src/world_entities/extendable.h
r5874 r5965 7 7 #define _EXTENDABLE_H 8 8 9 #include "base_object.h" 10 9 11 // FORWARD DECLARATION 10 12 class PowerUp; 11 13 12 14 13 15 //! A class for ... 14 class Extendable : public BaseObject {16 class Extendable : virtual public BaseObject { 15 17 16 18 public: -
branches/powerups/src/world_entities/power_ups/weapon_power_up.cc
r5958 r5965 16 16 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY 17 17 18 #include " laser_power_up.h"18 #include "weapon_power_up.h" 19 19 #include "factory.h" 20 20 #include "state.h" … … 25 25 using namespace std; 26 26 27 CREATE_FACTORY( LaserPowerUp, CL_LASER_POWER_UP);27 CREATE_FACTORY(WeaponPowerUp, CL_WEAPON_POWER_UP); 28 28 29 LaserPowerUp::LaserPowerUp ()29 WeaponPowerUp::WeaponPowerUp () 30 30 { 31 31 this->init(); 32 32 } 33 33 34 LaserPowerUp::LaserPowerUp(const TiXmlElement* root)34 WeaponPowerUp::WeaponPowerUp(const TiXmlElement* root) 35 35 { 36 36 this->init(); 37 38 37 this->loadParams(root); 39 38 } 40 39 41 40 42 LaserPowerUp::~LaserPowerUp ()41 WeaponPowerUp::~WeaponPowerUp () 43 42 { 44 delete this->sphereModel;45 delete this->sphereMaterial;46 43 } 47 44 48 45 49 void LaserPowerUp::init()46 void WeaponPowerUp::init() 50 47 { 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));62 48 } 63 49 64 50 65 void LaserPowerUp::loadParams(const TiXmlElement* root)51 void WeaponPowerUp::loadParams(const TiXmlElement* root) 66 52 { 67 53 static_cast<PowerUp*>(this)->loadParams(root); … … 69 55 } 70 56 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) 57 Weapon* WeaponPowerUp::getWeapon() 79 58 { 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())); 83 60 } 84 61 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) 62 ClassID WeaponPowerUp::getWeaponID() 92 63 { 93 this->shiftDir(Quaternion(dt, this->rotation)); 94 this->cycle+=dt; 95 64 return this->weaponID; 96 65 } 97 66 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(); 67 long WeaponPowerUp::getCapsNeeded() 68 { 69 return this->capsNeeded; 119 70 } 120 -
branches/powerups/src/world_entities/power_ups/weapon_power_up.h
r5958 r5965 1 1 /*! 2 * @file laser_power_up.h3 * @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. 4 4 */ 5 5 6 #ifndef _ LASER_POWER_UP_H7 #define _ LASER_POWER_UP_H6 #ifndef _WEAPON_POWER_UP_H 7 #define _WEAPON_POWER_UP_H 8 8 9 9 #include "power_up.h" 10 #include "weapons/weapon.h" 10 11 11 12 /* FORWARD DEFINITION */ 12 class Material;13 13 14 class LaserPowerUp : public PowerUp {14 class WeaponPowerUp : public PowerUp { 15 15 16 17 LaserPowerUp();18 LaserPowerUp(const TiXmlElement* root);19 virtual ~ LaserPowerUp ();16 public: 17 WeaponPowerUp(); 18 WeaponPowerUp(const TiXmlElement* root); 19 virtual ~WeaponPowerUp (); 20 20 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(); 24 24 25 26 27 25 private: 26 void init(); 27 void loadParams(const TiXmlElement* root); 28 28 29 private: 30 Vector rotation; 31 float cycle; 32 33 Model* sphereModel; 34 Material* sphereMaterial; 29 private: 30 ClassID weaponID; 31 long capsNeeded; 35 32 }; 36 33 37 #endif /* _ LASER_POWER_UP_H */34 #endif /* _WEAPON_POWER_UP_H */ -
branches/powerups/src/world_entities/space_ships/space_ship.cc
r5955 r5965 17 17 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY 18 18 19 #include "space_ship.h" 20 19 21 #include "executor/executor.h" 20 #include "space_ship.h"21 22 22 23 #include "objModel.h" … … 30 31 #include "factory.h" 31 32 #include "key_mapper.h" 33 34 #include "power_ups/weapon_power_up.h" 32 35 33 36 using namespace std; … … 368 371 } 369 372 373 /** 374 * 375 */ 376 bool 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 370 393 #include "weapons/aiming_turret.h" 371 394 // FIXME THIS MIGHT BE CONSIDERED EITHER A FEATURE, OR A BUG -
branches/powerups/src/world_entities/space_ships/space_ship.h
r5955 r5965 8 8 9 9 #include "playable.h" 10 #include "extendable.h" 10 11 11 12 template<class T> class tList; … … 13 14 class Event; 14 15 15 class SpaceShip : public Playable 16 class SpaceShip : public Playable, public Extendable 16 17 { 17 18 … … 37 38 38 39 virtual void process(const Event &event); 40 41 bool pickup(PowerUp* powerUp); 39 42 40 43 -
branches/powerups/src/world_entities/weapons/weapon_manager.cc
r5955 r5965 408 408 409 409 /** 410 * privategets the next free slot in a certain weaponconfig410 * gets the next free slot in a certain weaponconfig 411 411 * @param the selected weaponconfig 412 412 */ 413 413 int WeaponManager::getNextFreeSlot(int configID, long capability) 414 414 { 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 //} 422 431 return -1; 423 432 }
Note: See TracChangeset
for help on using the changeset viewer.