- Timestamp:
- Dec 3, 2005, 12:55:17 AM (19 years ago)
- Location:
- branches/spaceshipcontrol/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/spaceshipcontrol/src/Makefile.am
r5875 r5880 77 77 world_entities/power_ups/turret_power_up.cc \ 78 78 world_entities/power_ups/laser_power_up.cc \ 79 world_entities/space_ships/space_ship.cc \ 79 80 subprojects/benchmark.cc 80 81 -
branches/spaceshipcontrol/src/defs/class_id.h
r5844 r5880 144 144 CL_TERRAIN = 0x00000207, 145 145 CL_TEST_ENTITY = 0x00000209, 146 CL_SPACE_SHIP = 0x0000020a, 146 147 147 148 CL_TURRET_POWER_UP = 0x00000211, -
branches/spaceshipcontrol/src/world_entities/space_ships/space_ship.cc
r5878 r5880 28 28 #include "weapons/cannon.h" 29 29 30 #include "factory.h" 31 #include "key_mapper.h" 30 32 31 33 using namespace std; … … 46 48 SpaceShip::~SpaceShip () 47 49 { 48 /* do not delete the weapons, they are contained in the pnode tree49 and will be deleted there.50 this only frees the memory allocated to save the list.51 */52 delete this->weaponMan;53 50 } 54 51 … … 92 89 cannon->setName("BFG"); 93 90 94 this-> weaponMan->addWeapon(wpLeft, 1, 0);95 this-> weaponMan->addWeapon(wpRight,1 ,1);96 this-> weaponMan->addWeapon(cannon, 0, 6);97 98 //this-> weaponMan->addWeapon(turret, 3, 0);99 100 this-> weaponMan->changeWeaponConfig(1);91 this->getWeaponManager()->addWeapon(wpLeft, 1, 0); 92 this->getWeaponManager()->addWeapon(wpRight,1 ,1); 93 this->getWeaponManager()->addWeapon(cannon, 0, 6); 94 95 //this->getWeaponManager()->addWeapon(turret, 3, 0); 96 97 this->getWeaponManager()->changeWeaponConfig(1); 101 98 } 102 99 … … 121 118 // button->setBindNode(this); 122 119 123 this->weaponMan = new WeaponManager(this); 124 this->weaponMan->setSlotCount(7); 125 126 this->weaponMan->setSlotPosition(0, Vector(-2.6, .1, -3.0)); 127 this->weaponMan->setSlotCapability(0, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 128 129 this->weaponMan->setSlotPosition(1, Vector(-2.6, .1, 3.0)); 130 this->weaponMan->setSlotCapability(1, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 131 132 this->weaponMan->setSlotPosition(2, Vector(-1.5, .5, -.5)); 133 this->weaponMan->setSlotDirection(2, Quaternion(-M_PI_4*.5, Vector(1,0,0))); 134 135 this->weaponMan->setSlotPosition(3, Vector(-1.5, .5, .5)); 136 this->weaponMan->setSlotDirection(3, Quaternion(M_PI_4*.5, Vector(1,0,0))); 137 138 this->weaponMan->setSlotPosition(4, Vector(-1.5, -.5, .5)); 139 this->weaponMan->setSlotDirection(4, Quaternion(-M_PI_4*.5+M_PI, Vector(1,0,0))); 140 141 this->weaponMan->setSlotPosition(5, Vector(-1.5, -.5, -.5)); 142 this->weaponMan->setSlotDirection(5, Quaternion(+M_PI_4*.5-M_PI, Vector(1,0,0))); 120 this->getWeaponManager()->setSlotCount(7); 121 122 this->getWeaponManager()->setSlotPosition(0, Vector(-2.6, .1, -3.0)); 123 this->getWeaponManager()->setSlotCapability(0, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 124 125 this->getWeaponManager()->setSlotPosition(1, Vector(-2.6, .1, 3.0)); 126 this->getWeaponManager()->setSlotCapability(1, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 127 128 this->getWeaponManager()->setSlotPosition(2, Vector(-1.5, .5, -.5)); 129 this->getWeaponManager()->setSlotDirection(2, Quaternion(-M_PI_4*.5, Vector(1,0,0))); 130 131 this->getWeaponManager()->setSlotPosition(3, Vector(-1.5, .5, .5)); 132 this->getWeaponManager()->setSlotDirection(3, Quaternion(M_PI_4*.5, Vector(1,0,0))); 133 134 this->getWeaponManager()->setSlotPosition(4, Vector(-1.5, -.5, .5)); 135 this->getWeaponManager()->setSlotDirection(4, Quaternion(-M_PI_4*.5+M_PI, Vector(1,0,0))); 136 137 this->getWeaponManager()->setSlotPosition(5, Vector(-1.5, -.5, -.5)); 138 this->getWeaponManager()->setSlotDirection(5, Quaternion(+M_PI_4*.5-M_PI, Vector(1,0,0))); 143 139 // 144 this-> weaponMan->setSlotPosition(6, Vector(-1, 0.0, 0));145 this-> weaponMan->setSlotCapability(6, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);140 this->getWeaponManager()->setSlotPosition(6, Vector(-1, 0.0, 0)); 141 this->getWeaponManager()->setSlotCapability(6, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 146 142 // 147 // this-> weaponMan->setSlotPosition(8, Vector(-2.5, -0.3, -2.0));148 // this-> weaponMan->setSlotDirection(8, Quaternion(-M_PI, Vector(1,0,0)));143 // this->getWeaponManager()->setSlotPosition(8, Vector(-2.5, -0.3, -2.0)); 144 // this->getWeaponManager()->setSlotDirection(8, Quaternion(-M_PI, Vector(1,0,0))); 149 145 // 150 // this-> weaponMan->setSlotPosition(9, Vector(-2.5, -0.3, 2.0));151 // this-> weaponMan->setSlotDirection(9, Quaternion(+M_PI, Vector(1,0,0)));:146 // this->getWeaponManager()->setSlotPosition(9, Vector(-2.5, -0.3, 2.0)); 147 // this->getWeaponManager()->setSlotDirection(9, Quaternion(+M_PI, Vector(1,0,0)));: 152 148 153 149 } … … 169 165 void SpaceShip::addWeapon(Weapon* weapon) 170 166 { 171 this-> weaponMan->addWeapon(weapon);167 this->getWeaponManager()->addWeapon(weapon); 172 168 } 173 169 … … 179 175 void SpaceShip::removeWeapon(Weapon* weapon) 180 176 { 181 this-> weaponMan->removeWeapon(weapon);177 this->getWeaponManager()->removeWeapon(weapon); 182 178 } 183 179 … … 230 226 glPopMatrix(); 231 227 232 this-> weaponMan->draw();228 this->getWeaponManager()->draw(); 233 229 234 230 //this->debug(0); … … 244 240 this->move(time); 245 241 246 this-> weaponMan->tick(time);242 this->getWeaponManager()->tick(time); 247 243 // weapon system manipulation 248 244 this->weaponAction(); … … 270 266 accel -= direction; 271 267 272 if( this->bLeft && TrackManager::getInstance()->getWidth()> -this->getRelCoor().z*2)268 if( this->bLeft > -this->getRelCoor().z*2) 273 269 { 274 270 accel -=(orthDirection); … … 276 272 rotVal -= .4; 277 273 } 278 if( this->bRight && TrackManager::getInstance()->getWidth()> this->getRelCoor().z*2)274 if( this->bRight > this->getRelCoor().z*2) 279 275 { 280 276 accel += orthDirection; … … 314 310 if( this->bFire) 315 311 { 316 this-> weaponMan->fire();312 this->getWeaponManager()->fire(); 317 313 } 318 314 } … … 334 330 this->bFire = event.bPressed; 335 331 else if( event.type == KeyMapper::PEV_NEXT_WEAPON && event.bPressed) 336 this-> weaponMan->nextWeaponConfig();//if( !event.bPressed) this->bWeaponChange = !this->bWeaponChange;332 this->getWeaponManager()->nextWeaponConfig();//if( !event.bPressed) this->bWeaponChange = !this->bWeaponChange; 337 333 else if ( event.type == KeyMapper::PEV_PREVIOUS_WEAPON && event.bPressed) 338 this-> weaponMan->previousWeaponConfig();334 this->getWeaponManager()->previousWeaponConfig(); 339 335 340 336 else if( event.type == SDLK_PAGEUP) … … 352 348 if ((float)rand()/RAND_MAX < .1) 353 349 { 354 //if (this-> weaponMan->hasFreeSlot(2, WTYPE_TURRET))350 //if (this->getWeaponManager()->hasFreeSlot(2, WTYPE_TURRET)) 355 351 { 356 352 turret = new Turret(); 357 this-> weaponMan->addWeapon(turret, 2);358 this-> weaponMan->changeWeaponConfig(2);353 this->getWeaponManager()->addWeapon(turret, 2); 354 this->getWeaponManager()->changeWeaponConfig(2); 359 355 } 360 356 } 361 357 else 362 358 { 363 //if (this-> weaponMan->hasFreeSlot(3))359 //if (this->getWeaponManager()->hasFreeSlot(3)) 364 360 { 365 361 turret = new AimingTurret(); 366 this-> weaponMan->addWeapon(turret, 3);367 368 this-> weaponMan->changeWeaponConfig(3);362 this->getWeaponManager()->addWeapon(turret, 3); 363 364 this->getWeaponManager()->changeWeaponConfig(3); 369 365 } 370 366 } -
branches/spaceshipcontrol/src/world_entities/space_ships/space_ship.h
r5878 r5880 4 4 */ 5 5 6 #ifndef _ PLAYER_H7 #define _ PLAYER_H6 #ifndef _SPACE_SHIP_H 7 #define _SPACE_SHIP_H 8 8 9 9 #include "playable.h" … … 15 15 class SpaceShip : public Playable 16 16 { 17 17 18 18 public: 19 19 20 20 SpaceShip(); 21 21 SpaceShip(const char* fileName); 22 22 SpaceShip(const TiXmlElement* root); 23 23 virtual ~SpaceShip(); 24 24 25 25 void init(); 26 26 void loadParams(const TiXmlElement* root); 27 27 28 28 void addWeapon(Weapon* weapon ); 29 29 void removeWeapon(Weapon* weapon); 30 30 31 31 virtual void postSpawn(); 32 32 virtual void leftWorld(); 33 33 34 34 virtual void collidesWith(WorldEntity* entity, const Vector& location); 35 35 virtual void tick(float time); 36 36 virtual void draw() const; 37 37 38 v oid process(const Event &event);39 40 41 38 virtual void process(const Event &event); 39 40 41 42 42 private: 43 43 44 44 void move(float time); 45 45 void weaponAction(); … … 47 47 // !! temporary !! 48 48 void ADDWEAPON(); 49 49 50 50 bool bUp; //!< up button pressed. 51 51 bool bDown; //!< down button pressed. … … 62 62 }; 63 63 64 #endif /* _ PLAYABLE_H */64 #endif /* _SPACE_SHIPS_H */
Note: See TracChangeset
for help on using the changeset viewer.