- Timestamp:
- Dec 31, 2005, 5:06:56 PM (19 years ago)
- Location:
- branches/spaceshipcontrol/src/world_entities/space_ships
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/spaceshipcontrol/src/world_entities/space_ships/helicopter.cc
r6242 r6378 117 117 xMouse = yMouse = 0; 118 118 mouseSensitivity = 0.001; 119 rotorspeed = 1; 120 tailrotorspeed = 0; 119 121 120 122 cycle = 0.0; … … 258 260 */ 259 261 void Helicopter::tick (float time) 260 { 262 { 263 tailrotorspeed += xMouse/20; 264 if (tailrotorspeed >= 0.07) tailrotorspeed = 0.07; 265 else if (tailrotorspeed <= -0.07) tailrotorspeed = -0.07; 266 267 if (tailrotorspeed > 0.0008) tailrotorspeed -= 0.001; 268 else if (tailrotorspeed < -0.0008) tailrotorspeed += 0.001; 269 if (tailrotorspeed <= 0.001 && tailrotorspeed >= -0.001) tailrotorspeed = 0; 270 261 271 // spaceship controlled movement 262 272 this->calculateVelocity(time); 263 273 264 Vector move = (velocity) *time;274 Vector move = (velocity); 265 275 266 276 // this is the air friction (necessary for a smooth control) … … 268 278 269 279 //physics: Gravity 270 this->shiftCoor(Vector(0,-0.05,0)); 280 this->shiftCoor(Vector(0,-1,0)); 281 282 this->shiftCoor(getAbsDirY()*rotorspeed); 271 283 272 284 //hoover effect … … 281 293 282 294 this->shiftCoor (move); 295 this->shiftDir(Quaternion(-M_PI/4*tailrotorspeed, Vector(0,1,0))); 283 296 284 297 this->getWeaponManager()->tick(time); … … 302 315 { 303 316 //this->shiftCoor(this->getAbsDirX()); 304 305 accel += this->getAbsDirX()*2; 317 //accel -= this->getAbsDirY(); 306 318 rot += Vector (0,0,1); 307 rotVal -= time/ 8;319 rotVal -= time/5; 308 320 } 309 321 else … … 315 327 { 316 328 //this->shiftCoor((this->getAbsDirX())*-1); 317 accel -= this->getAbsDirX()*2;329 //accel -= this->getAbsDirY(); 318 330 rot += Vector (0,0,1); 319 rotVal += time/ 8;331 rotVal += time/5; 320 332 } 321 333 else … … 327 339 { 328 340 //this->shiftDir(Quaternion(time, Vector(0,1,0))); 329 accel -= this->getAbsDirZ()*2;341 //accel -= this->getAbsDirY(); 330 342 //velocityDir.normalize(); 331 343 rot += Vector(1,0,0); 332 rotVal -= time/ 8;344 rotVal -= time/5; 333 345 } 334 346 else … … 340 352 { 341 353 //this->shiftDir(Quaternion(-time, Vector(0,1,0))); 342 accel += this->getAbsDir Z()*2;354 accel += this->getAbsDirY(); 343 355 //velocityDir.normalize(); 344 356 rot += Vector(1,0,0); … … 371 383 //this->shiftDir(Quaternion(time, Vector(0,0,1))); 372 384 373 accel += (this->getAbsDirY())*3; 385 rotorspeed += 0.05; 386 if (rotorspeed >= 2) rotorspeed = 2; 374 387 //velocityDir.normalize(); 375 388 //rot += Vector(0,0,1); 376 389 //rotVal += .4; 377 390 } 391 else 392 { 393 if(rotorspeed >= 1.05) rotorspeed -= 0.05; 394 } 395 378 396 if (this->bDescend ) 379 397 { 380 398 //this->shiftDir(Quaternion(-time, Vector(0,0,1))); 381 399 382 accel -= (this->getAbsDirY())*3; 400 rotorspeed -= 0.05; 401 if (rotorspeed <= 0) rotorspeed = 0; 383 402 //velocityDir.normalize(); 384 403 //rot += Vector(0,0,1); 385 404 //rotVal -= .4; 386 405 } 387 388 velocity += accel; 406 else 407 { 408 if(rotorspeed <= 0.05) rotorspeed += 0.05; 409 } 410 411 //velocity += accel; 389 412 rot.normalize(); 390 413 this->shiftDir(Quaternion(rotVal, rot)); … … 438 461 else if( event.type == EV_MOUSE_MOTION) 439 462 { 440 this->xMouse = event.xRel ;441 this->yMouse = event.yRel ;442 if(((this->getAbsDirX().y) <= .2 && yMouse > 0) || ((this->getAbsDirX().y) >= -.2 && yMouse < 0)) yMouse = 0;443 this->shiftDir(Quaternion(-M_PI/4*xMouse*mouseSensitivity, Vector(0,1,0))*Quaternion(-M_PI/4*yMouse*mouseSensitivity, Vector(0,0,1)));463 this->xMouse = event.xRel*mouseSensitivity; 464 this->yMouse = event.yRel*mouseSensitivity; 465 466 //this->shiftDir(Quaternion(-M_PI/4*xMouse*mouseSensitivity, Vector(0,1,0))*Quaternion(-M_PI/4*yMouse*mouseSensitivity, Vector(0,0,1))); 444 467 } 445 468 } -
branches/spaceshipcontrol/src/world_entities/space_ships/helicopter.h
r6222 r6378 67 67 float travelSpeed; //!< the current speed of the player (to make soft movement) 68 68 float acceleration; //!< the acceleration of the player. 69 float rotorspeed; //!< the speed of the rotor. 70 float tailrotorspeed; //!< the relativ speed ot the tail rotor 69 71 70 72 float airViscosity;
Note: See TracChangeset
for help on using the changeset viewer.