- Timestamp:
- Dec 7, 2005, 5:51:54 PM (19 years ago)
- Location:
- trunk/src
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/defs/globals.h
r5956 r5978 72 72 #define CONFIG_NAME_PLAYER_LEFT "Left" 73 73 #define CONFIG_NAME_PLAYER_RIGHT "Right" 74 #define CONFIG_NAME_PLAYER_ROLL_RIGHT "RollR" 75 #define CONFIG_NAME_PLAYER_ROLL_LEFT "RollL" 76 74 77 #define CONFIG_NAME_PLAYER_FIRE "Fire" 75 78 #define CONFIG_NAME_PLAYER_NEXT_WEAPON "Next" -
trunk/src/lib/event/event_handler.cc
r5786 r5978 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 /** -
trunk/src/lib/event/event_handler.h
r5786 r5978 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 -
trunk/src/lib/event/key_mapper.cc
r5944 r5978 37 37 int KeyMapper::PEV_LEFT = EV_UNKNOWN; 38 38 int KeyMapper::PEV_RIGHT = EV_UNKNOWN; 39 int KeyMapper::PEV_ROLL_LEFT = EV_UNKNOWN; 40 int KeyMapper::PEV_ROLL_RIGHT = EV_UNKNOWN; 39 41 int KeyMapper::PEV_STRAFE_LEFT = EV_UNKNOWN; 40 42 int KeyMapper::PEV_STRAFE_RIGHT = EV_UNKNOWN; … … 69 71 {&KeyMapper::PEV_LEFT, CONFIG_NAME_PLAYER_LEFT}, 70 72 {&KeyMapper::PEV_RIGHT, CONFIG_NAME_PLAYER_RIGHT}, 73 {&KeyMapper::PEV_ROLL_LEFT, CONFIG_NAME_PLAYER_ROLL_RIGHT}, 74 {&KeyMapper::PEV_ROLL_RIGHT, CONFIG_NAME_PLAYER_ROLL_LEFT}, 71 75 {&KeyMapper::PEV_STRAFE_LEFT, "StrafeLeft"}, 72 76 {&KeyMapper::PEV_STRAFE_RIGHT, "StrafeRight"}, -
trunk/src/lib/event/key_mapper.h
r5915 r5978 44 44 static int PEV_RIGHT; //!< right button 45 45 46 static int PEV_ROLL_LEFT; //!< rolls left 47 static int PEV_ROLL_RIGHT; //!< rolls right 48 46 49 static int PEV_STRAFE_LEFT; //!< strafe left button 47 50 static int PEV_STRAFE_RIGHT; //!< strafe right button -
trunk/src/lib/gui/gtk_gui/gui_keys.cc
r5945 r5978 115 115 116 116 pKeysBox->setGroupName(player); 117 pKeysBox->fill(addKey(CONFIG_NAME_PLAYER_UP, "UP")); 118 pKeysBox->fill(addKey(CONFIG_NAME_PLAYER_DOWN, "DOWN")); 119 pKeysBox->fill(addKey(CONFIG_NAME_PLAYER_LEFT, "LEFT")); 120 pKeysBox->fill(addKey(CONFIG_NAME_PLAYER_RIGHT, "RIGHT")); 117 pKeysBox->fill(addKey(CONFIG_NAME_PLAYER_UP, "w")); 118 pKeysBox->fill(addKey(CONFIG_NAME_PLAYER_DOWN, "s")); 119 pKeysBox->fill(addKey(CONFIG_NAME_PLAYER_LEFT, "a")); 120 pKeysBox->fill(addKey(CONFIG_NAME_PLAYER_RIGHT, "d")); 121 pKeysBox->fill(addKey(CONFIG_NAME_PLAYER_ROLL_LEFT, "q")); 122 pKeysBox->fill(addKey(CONFIG_NAME_PLAYER_ROLL_RIGHT, "e")); 121 123 pKeysBox->fill(addKey(CONFIG_NAME_PLAYER_FIRE, "BUTTON_LEFT")); 122 124 pKeysBox->fill(addKey(CONFIG_NAME_PLAYER_NEXT_WEAPON, "m")); -
trunk/src/world_entities/space_ships/space_ship.cc
r5915 r5978 30 30 #include "factory.h" 31 31 #include "key_mapper.h" 32 #include "event_handler.h" 33 34 #include "graphics_engine.h" 32 35 33 36 using namespace std; … … 109 112 PRINTF(4)("SPACESHIP INIT\n"); 110 113 111 112 bUp = bDown = bLeft = bRight = bAscend = bDescend = false; 114 EventHandler::getInstance()->grabEvents(true); 115 116 bUp = bDown = bLeft = bRight = bAscend = bDescend = bRollL = bRollR = false; 113 117 bFire = false; 118 xMouse = yMouse = 0; 119 mouseSensitivity = 0.001; 120 121 cycle = 0.0; 122 114 123 115 124 travelSpeed = 15.0; … … 123 132 124 133 //add events to the eventlist 125 registerEvent(KeyMapper::PEV_UP); 126 registerEvent(KeyMapper::PEV_DOWN); 127 registerEvent(KeyMapper::PEV_LEFT); 128 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); 129 140 registerEvent(KeyMapper::PEV_FIRE1); 130 141 registerEvent(KeyMapper::PEV_NEXT_WEAPON); … … 132 143 registerEvent(SDLK_PAGEUP); 133 144 registerEvent(SDLK_PAGEDOWN); 145 registerEvent(EV_MOUSE_MOTION); 134 146 135 147 this->getWeaponManager()->setSlotCount(7); … … 252 264 void SpaceShip::tick (float time) 253 265 { 266 cycle += time; 254 267 // spaceship controlled movement 255 268 this->calculateVelocity(time); … … 258 271 259 272 //orient the spaceship model in the direction of movement. 273 274 // this is the air friction (necessary for a smooth control) 275 if(velocity.len() != 0) velocity -= velocity*0.01; 276 277 this->shiftCoor(Vector(0,1,0)*cos(this->cycle*2.0)*0.02); 278 279 //SDL_WarpMouse(GraphicsEngine::getInstance()->getResolutionX()/2, GraphicsEngine::getInstance()->getResolutionY()/2); 260 280 261 281 this->shiftCoor (move); … … 280 300 if( this->bUp ) 281 301 { 282 this->shiftCoor(this->getAbsDirX());283 //if(travelSpeed <= 5000) travelSpeed += 10;302 //this->shiftCoor(this->getAbsDirX()); 303 accel += (this->getAbsDirX())*2; 284 304 } 285 305 286 306 if( this->bDown ) 287 307 { 288 this->shiftCoor(Vector()-this->getAbsDirX());289 //if(travelSpeed >= 10) travelSpeed -= 10;308 //this->shiftCoor((this->getAbsDirX())*-1); 309 accel -= (this->getAbsDirX())*2; 290 310 } 291 311 … … 307 327 //rotVal += .4; 308 328 } 329 330 if( this->bRollL /* > -this->getRelCoor().z*2*/) 331 { 332 this->shiftDir(Quaternion(-time, Vector(1,0,0))); 333 // accel -= rightDirection; 334 //velocityDir.normalize(); 335 //rot +=Vector(1,0,0); 336 //rotVal -= .4; 337 } 338 if( this->bRollR /* > this->getRelCoor().z*2*/) 339 { 340 this->shiftDir(Quaternion(time, Vector(1,0,0))); 341 342 // accel += rightDirection; 343 //velocityDir.normalize(); 344 //rot += Vector(1,0,0); 345 //rotVal += .4; 346 } 309 347 if (this->bAscend ) 310 348 { … … 326 364 } 327 365 328 velocity += accel *(time);366 velocity += accel; 329 367 //rot.normalize(); 330 368 //this->setRelDirSoft(Quaternion(rotVal, rot), 5); … … 347 385 void SpaceShip::process(const Event &event) 348 386 { 349 if( event.type == KeyMapper::PEV_UP) 350 this->bUp = event.bPressed; 351 else if( event.type == KeyMapper::PEV_DOWN) 352 this->bDown = event.bPressed; 353 else if( event.type == KeyMapper::PEV_RIGHT) 354 this->bRight= event.bPressed; 355 else if( event.type == KeyMapper::PEV_LEFT) 356 this->bLeft = event.bPressed; 387 388 389 if( event.type == SDLK_a) 390 this->bRollL = event.bPressed; 391 else if( event.type == SDLK_d) 392 this->bRollR = event.bPressed; 357 393 else if( event.type == KeyMapper::PEV_FIRE1) 358 394 this->bFire = event.bPressed; … … 362 398 this->getWeaponManager()->previousWeaponConfig(); 363 399 364 else if( event.type == SDLK_PAGEUP) 365 this->bAscend = event.bPressed; //this->shiftCoor(0,.1,0); 366 else if( event.type == SDLK_PAGEDOWN) 367 this->bDescend = event.bPressed; //this->shiftCoor(0,-.1,0); 400 else if( event.type == SDLK_w) 401 this->bUp = event.bPressed; //this->shiftCoor(0,.1,0); 402 else if( event.type == SDLK_s) 403 this->bDown = event.bPressed; //this->shiftCoor(0,-.1,0); 404 else if( event.type == EV_MOUSE_MOTION) 405 { 406 this->xMouse = event.xRel; 407 this->yMouse = event.yRel; 408 this->shiftDir(Quaternion(-M_PI/4*xMouse*mouseSensitivity, Vector(0,1,0))*Quaternion(-M_PI/4*yMouse*mouseSensitivity, Vector(0,0,1))); 409 } 368 410 } 369 411 -
trunk/src/world_entities/space_ships/space_ship.h
r5915 r5978 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) 59 60 float xMouse; //!< mouse moved in x-Direction 61 float yMouse; //!< mouse moved in y-Direction 62 float mouseSensitivity; //!< the mouse sensitivity 63 float cycle; //!< hovercycle 57 64 58 65 Vector velocity; //!< the velocity of the player. -
trunk/src/world_entities/weapons/crosshair.cc
r5750 r5978 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);
Note: See TracChangeset
for help on using the changeset viewer.