Changeset 5964 in orxonox.OLD
- Timestamp:
- Dec 7, 2005, 3:43:01 PM (19 years ago)
- Location:
- branches/spaceshipcontrol/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/spaceshipcontrol/src/lib/event/event_handler.cc
r5786 r5964 47 47 this->flush(ES_ALL); 48 48 this->withUNICODE(false); 49 this->grabEvents(false); 49 50 50 51 this->state = ES_GAME; … … 255 256 } 256 257 258 void EventHandler::grabEvents(bool grabEvents) 259 { 260 this->eventsGrabbed = grabEvents; 261 if(!grabEvents) 262 SDL_WM_GrabInput(SDL_GRAB_OFF); 263 else 264 SDL_WM_GrabInput(SDL_GRAB_ON); 265 } 257 266 258 267 /** -
branches/spaceshipcontrol/src/lib/event/event_handler.h
r5786 r5964 43 43 44 44 void withUNICODE(bool enableUNICODE); 45 void grabEvents(bool grabEvents); 45 46 46 47 void process(); … … 62 63 63 64 bool bUNICODE; //!< If unicode should be enabled. 65 bool eventsGrabbed; //!< If the events should be grabbed 64 66 }; 65 67 -
branches/spaceshipcontrol/src/world_entities/space_ships/space_ship.cc
r5928 r5964 31 31 #include "key_mapper.h" 32 32 #include "event_handler.h" 33 34 #include "graphics_engine.h" 33 35 34 36 using namespace std; … … 110 112 PRINTF(4)("SPACESHIP INIT\n"); 111 113 112 113 bUp = bDown = bLeft = bRight = bAscend = bDescend = false; 114 EventHandler::getInstance()->grabEvents(true); 115 116 bUp = bDown = bLeft = bRight = bAscend = bDescend = bRollL = bRollR = false; 114 117 bFire = false; 118 xMouse = yMouse = 0; 119 mouseSensitivity = 0.001; 120 121 122 115 123 116 124 travelSpeed = 15.0; … … 124 132 125 133 //add events to the eventlist 126 registerEvent(KeyMapper::PEV_UP); 127 registerEvent(KeyMapper::PEV_DOWN); 128 registerEvent(KeyMapper::PEV_LEFT); 129 registerEvent(KeyMapper::PEV_RIGHT); 134 registerEvent(SDLK_w); 135 registerEvent(SDLK_s); 136 registerEvent(SDLK_a); 137 registerEvent(SDLK_d); 138 registerEvent(SDLK_q); 139 registerEvent(SDLK_e); 130 140 registerEvent(KeyMapper::PEV_FIRE1); 131 141 registerEvent(KeyMapper::PEV_NEXT_WEAPON); … … 262 272 263 273 // this is the air friction (necessary for a smooth control) 264 if(velocity.len() != 0) velocity -= velocity*0.0 05;265 266 this->shiftDir(Quaternion(-M_PI/4*xMouse*time/5, Vector(0,1,0))*Quaternion(-M_PI/4*yMouse*time/5, Vector(0,0,1)));274 if(velocity.len() != 0) velocity -= velocity*0.01; 275 276 //SDL_WarpMouse(GraphicsEngine::getInstance()->getResolutionX()/2, GraphicsEngine::getInstance()->getResolutionY()/2); 267 277 268 278 this->shiftCoor (move); … … 288 298 { 289 299 //this->shiftCoor(this->getAbsDirX()); 290 accel += this->getAbsDirX();300 accel += (this->getAbsDirX())*2; 291 301 } 292 302 … … 294 304 { 295 305 //this->shiftCoor((this->getAbsDirX())*-1); 296 accel -= this->getAbsDirX();306 accel -= (this->getAbsDirX())*2; 297 307 } 298 308 … … 308 318 { 309 319 this->shiftDir(Quaternion(-time, Vector(0,1,0))); 320 321 // accel += rightDirection; 322 //velocityDir.normalize(); 323 //rot += Vector(1,0,0); 324 //rotVal += .4; 325 } 326 327 if( this->bRollL /* > -this->getRelCoor().z*2*/) 328 { 329 this->shiftDir(Quaternion(-time, Vector(1,0,0))); 330 // accel -= rightDirection; 331 //velocityDir.normalize(); 332 //rot +=Vector(1,0,0); 333 //rotVal -= .4; 334 } 335 if( this->bRollR /* > this->getRelCoor().z*2*/) 336 { 337 this->shiftDir(Quaternion(time, Vector(1,0,0))); 310 338 311 339 // accel += rightDirection; … … 354 382 void SpaceShip::process(const Event &event) 355 383 { 356 if( event.type == KeyMapper::PEV_UP) 357 this->bUp = event.bPressed; 358 else if( event.type == KeyMapper::PEV_DOWN) 359 this->bDown = event.bPressed; 360 else if( event.type == KeyMapper::PEV_RIGHT) 361 this->bRight= event.bPressed; 362 else if( event.type == KeyMapper::PEV_LEFT) 363 this->bLeft = event.bPressed; 384 385 386 if( event.type == SDLK_a) 387 this->bRollL = event.bPressed; 388 else if( event.type == SDLK_d) 389 this->bRollR = event.bPressed; 364 390 else if( event.type == KeyMapper::PEV_FIRE1) 365 391 this->bFire = event.bPressed; … … 369 395 this->getWeaponManager()->previousWeaponConfig(); 370 396 371 else if( event.type == SDLK_ PAGEUP)372 this->b Ascend= event.bPressed; //this->shiftCoor(0,.1,0);373 else if( event.type == SDLK_ PAGEDOWN)374 this->bD escend= event.bPressed; //this->shiftCoor(0,-.1,0);397 else if( event.type == SDLK_w) 398 this->bUp = event.bPressed; //this->shiftCoor(0,.1,0); 399 else if( event.type == SDLK_s) 400 this->bDown = event.bPressed; //this->shiftCoor(0,-.1,0); 375 401 else if( event.type == EV_MOUSE_MOTION) 376 402 { 377 403 this->xMouse = event.xRel; 378 404 this->yMouse = event.yRel; 405 this->shiftDir(Quaternion(-M_PI/4*xMouse*mouseSensitivity, Vector(0,1,0))*Quaternion(-M_PI/4*yMouse*mouseSensitivity, Vector(0,0,1))); 379 406 } 380 407 } -
branches/spaceshipcontrol/src/world_entities/space_ships/space_ship.h
r5921 r5964 55 55 bool bDescend; //!< descend button presses. 56 56 bool bFire; //!< fire button pressed. 57 bool bRollL; //!< rolling button pressed (left) 58 bool bRollR; //!< rolling button pressed (right) 57 59 58 60 float xMouse; //!< mouse moved in x-Direction 59 61 float yMouse; //!< mouse moved in y-Direction 62 float mouseSensitivity; //!< the mouse sensitivity 60 63 61 64 Vector velocity; //!< the velocity of the player. -
branches/spaceshipcontrol/src/world_entities/weapons/crosshair.cc
r5921 r5964 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
Note: See TracChangeset
for help on using the changeset viewer.