Changeset 5985 in orxonox.OLD for branches/powerups/src/world_entities
- Timestamp:
- Dec 8, 2005, 1:10:27 AM (19 years ago)
- Location:
- branches/powerups/src/world_entities
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/powerups/src/world_entities/extendable.h
r5965 r5985 12 12 class PowerUp; 13 13 14 #include "power_ups/power_up.h" 14 15 15 16 //! A class for ... … … 19 20 // Extendable(); 20 21 // virtual ~Extendable(); 21 virtual bool pickup(PowerUp* powerUp) { return false; }22 virtual bool pickup(PowerUp* powerUp) { return false; }; 22 23 23 24 private: -
branches/powerups/src/world_entities/player.h
r5955 r5985 8 8 9 9 #include "event_listener.h" 10 #include "extendable.h" 10 11 11 12 /* Forward Declaration */ … … 18 19 the player.cc for debug also 19 20 */ 21 20 22 class Player : public EventListener 21 23 { -
branches/powerups/src/world_entities/space_ships/space_ship.cc
r5973 r5985 31 31 #include "factory.h" 32 32 #include "key_mapper.h" 33 #include "event_handler.h" 33 34 34 35 #include "power_ups/weapon_power_up.h" 36 37 #include "graphics_engine.h" 35 38 36 39 using namespace std; … … 88 91 Weapon* wpLeft = new TestGun(1); 89 92 wpLeft->setName("testGun Left"); 90 Weapon* cannon = dynamic_cast<Weapon*>(Factory:: getFirst()->fabricate(CL_CANNON));93 Weapon* cannon = dynamic_cast<Weapon*>(Factory::fabricate(CL_CANNON)); 91 94 92 95 cannon->setName("BFG"); … … 112 115 PRINTF(4)("SPACESHIP INIT\n"); 113 116 114 115 bUp = bDown = bLeft = bRight = bAscend = bDescend = false; 117 EventHandler::getInstance()->grabEvents(true); 118 119 bUp = bDown = bLeft = bRight = bAscend = bDescend = bRollL = bRollR = false; 116 120 bFire = false; 121 xMouse = yMouse = 0; 122 mouseSensitivity = 0.001; 123 124 cycle = 0.0; 125 117 126 118 127 travelSpeed = 15.0; … … 126 135 127 136 //add events to the eventlist 128 registerEvent(KeyMapper::PEV_UP); 129 registerEvent(KeyMapper::PEV_DOWN); 130 registerEvent(KeyMapper::PEV_LEFT); 131 registerEvent(KeyMapper::PEV_RIGHT); 137 registerEvent(SDLK_w); 138 registerEvent(SDLK_s); 139 registerEvent(SDLK_a); 140 registerEvent(SDLK_d); 141 registerEvent(SDLK_q); 142 registerEvent(SDLK_e); 132 143 registerEvent(KeyMapper::PEV_FIRE1); 133 144 registerEvent(KeyMapper::PEV_NEXT_WEAPON); … … 135 146 registerEvent(SDLK_PAGEUP); 136 147 registerEvent(SDLK_PAGEDOWN); 148 registerEvent(EV_MOUSE_MOTION); 137 149 138 150 this->getWeaponManager()->setSlotCount(7); … … 255 267 void SpaceShip::tick (float time) 256 268 { 269 cycle += time; 257 270 // spaceship controlled movement 258 271 this->calculateVelocity(time); … … 261 274 262 275 //orient the spaceship model in the direction of movement. 276 277 // this is the air friction (necessary for a smooth control) 278 if(velocity.len() != 0) velocity -= velocity*0.01; 279 280 this->shiftCoor(Vector(0,1,0)*cos(this->cycle*2.0)*0.02); 281 282 //SDL_WarpMouse(GraphicsEngine::getInstance()->getResolutionX()/2, GraphicsEngine::getInstance()->getResolutionY()/2); 263 283 264 284 this->shiftCoor (move); … … 283 303 if( this->bUp ) 284 304 { 285 this->shiftCoor(this->getAbsDirX());286 //if(travelSpeed <= 5000) travelSpeed += 10;305 //this->shiftCoor(this->getAbsDirX()); 306 accel += (this->getAbsDirX())*2; 287 307 } 288 308 289 309 if( this->bDown ) 290 310 { 291 this->shiftCoor(Vector()-this->getAbsDirX());292 //if(travelSpeed >= 10) travelSpeed -= 10;311 //this->shiftCoor((this->getAbsDirX())*-1); 312 accel -= (this->getAbsDirX())*2; 293 313 } 294 314 … … 310 330 //rotVal += .4; 311 331 } 332 333 if( this->bRollL /* > -this->getRelCoor().z*2*/) 334 { 335 this->shiftDir(Quaternion(-time, Vector(1,0,0))); 336 // accel -= rightDirection; 337 //velocityDir.normalize(); 338 //rot +=Vector(1,0,0); 339 //rotVal -= .4; 340 } 341 if( this->bRollR /* > this->getRelCoor().z*2*/) 342 { 343 this->shiftDir(Quaternion(time, Vector(1,0,0))); 344 345 // accel += rightDirection; 346 //velocityDir.normalize(); 347 //rot += Vector(1,0,0); 348 //rotVal += .4; 349 } 312 350 if (this->bAscend ) 313 351 { … … 329 367 } 330 368 331 velocity += accel *(time);369 velocity += accel; 332 370 //rot.normalize(); 333 371 //this->setRelDirSoft(Quaternion(rotVal, rot), 5); … … 350 388 void SpaceShip::process(const Event &event) 351 389 { 352 if( event.type == KeyMapper::PEV_UP) 353 this->bUp = event.bPressed; 354 else if( event.type == KeyMapper::PEV_DOWN) 355 this->bDown = event.bPressed; 356 else if( event.type == KeyMapper::PEV_RIGHT) 357 this->bRight= event.bPressed; 358 else if( event.type == KeyMapper::PEV_LEFT) 359 this->bLeft = event.bPressed; 390 391 392 if( event.type == SDLK_a) 393 this->bRollL = event.bPressed; 394 else if( event.type == SDLK_d) 395 this->bRollR = event.bPressed; 360 396 else if( event.type == KeyMapper::PEV_FIRE1) 361 397 this->bFire = event.bPressed; … … 365 401 this->getWeaponManager()->previousWeaponConfig(); 366 402 367 else if( event.type == SDLK_PAGEUP) 368 this->bAscend = event.bPressed; //this->shiftCoor(0,.1,0); 369 else if( event.type == SDLK_PAGEDOWN) 370 this->bDescend = event.bPressed; //this->shiftCoor(0,-.1,0); 403 else if( event.type == SDLK_w) 404 this->bUp = event.bPressed; //this->shiftCoor(0,.1,0); 405 else if( event.type == SDLK_s) 406 this->bDown = event.bPressed; //this->shiftCoor(0,-.1,0); 407 else if( event.type == EV_MOUSE_MOTION) 408 { 409 this->xMouse = event.xRel; 410 this->yMouse = event.yRel; 411 this->shiftDir(Quaternion(-M_PI/4*xMouse*mouseSensitivity, Vector(0,1,0))*Quaternion(-M_PI/4*yMouse*mouseSensitivity, Vector(0,0,1))); 412 } 371 413 } 372 414 -
branches/powerups/src/world_entities/space_ships/space_ship.h
r5965 r5985 58 58 bool bDescend; //!< descend button presses. 59 59 bool bFire; //!< fire button pressed. 60 bool bRollL; //!< rolling button pressed (left) 61 bool bRollR; //!< rolling button pressed (right) 62 63 float xMouse; //!< mouse moved in x-Direction 64 float yMouse; //!< mouse moved in y-Direction 65 float mouseSensitivity; //!< the mouse sensitivity 66 float cycle; //!< hovercycle 60 67 61 68 Vector velocity; //!< the velocity of the player. -
branches/powerups/src/world_entities/weapons/crosshair.cc
r5750 r5985 70 70 this->material = new Material; 71 71 72 EventHandler::getInstance()->subscribe(this, ES_GAME, EV_MOUSE_MOTION);72 //EventHandler::getInstance()->subscribe(this, ES_GAME, EV_MOUSE_MOTION); 73 73 74 74 // center the mouse on the screen, and also hide the cursors … … 122 122 if (event.type == EV_MOUSE_MOTION) 123 123 { 124 this->setAbsCoor2D(event.x, event.y);124 //this->setAbsCoor2D(event.x, event.y); 125 125 } 126 126 } … … 157 157 &objZ ); 158 158 159 this->setAbsCoor(objX, objY, objZ);159 //this->setAbsCoor(objX, objY, objZ); 160 160 } 161 161 … … 166 166 { 167 167 glPushMatrix(); 168 glTranslatef( this->getAbsCoor2D().x, this->getAbsCoor2D().y, 0);168 glTranslatef(GraphicsEngine::getInstance()->getResolutionX()/2, GraphicsEngine::getInstance()->getResolutionY()/2, 0); 169 169 170 170 glRotatef(this->getAbsDir2D(), 0,0,1); -
branches/powerups/src/world_entities/weapons/ground_turret.cc
r5955 r5985 85 85 element = root->FirstChildElement("weapon-left"); 86 86 if (element != NULL) element = element->FirstChildElement(); 87 this->left = dynamic_cast<Weapon*>( Factory:: getFirst()->fabricate( element) );87 this->left = dynamic_cast<Weapon*>( Factory::fabricate( element) ); 88 88 if (this->left) 89 89 { … … 94 94 element = root->FirstChildElement("weapon-right"); 95 95 if (element != NULL) if (element != NULL) element = element->FirstChildElement(); 96 this->right = dynamic_cast<Weapon*>( Factory:: getFirst()->fabricate( element) );96 this->right = dynamic_cast<Weapon*>( Factory::fabricate( element) ); 97 97 if (this->right) 98 98 { -
branches/powerups/src/world_entities/weapons/weapon_manager.cc
r5965 r5985 140 140 LOAD_PARAM_START_CYCLE(root, element); 141 141 142 Weapon* newWeapon = dynamic_cast<Weapon*>(Factory:: getFirst()->fabricate(element));142 Weapon* newWeapon = dynamic_cast<Weapon*>(Factory::fabricate(element)); 143 143 /// @todo implement this !! 144 144
Note: See TracChangeset
for help on using the changeset viewer.