Changeset 9124 in orxonox.OLD for branches/presentation
- Timestamp:
- Jul 4, 2006, 2:17:17 PM (18 years ago)
- Location:
- branches/presentation/src/world_entities/space_ships
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/presentation/src/world_entities/space_ships/spacecraft_2d.cc
r9120 r9124 35 35 #include "debug.h" 36 36 37 #include "script_class.h" 38 39 37 40 CREATE_FACTORY(Spacecraft2D, CL_SPACECRAFT_2D); 41 42 43 CREATE_SCRIPTABLE_CLASS(Spacecraft2D, CL_SPACECRAFT_2D, 44 addMethod("hasPlayer", ExecutorLua0ret<Playable,bool>(&Playable::hasPlayer)) 45 //Coordinates 46 ->addMethod("setAbsCoor", ExecutorLua3<PNode,float,float,float>(&PNode::setAbsCoor)) 47 ->addMethod("getAbsCoorX", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorX)) 48 ->addMethod("getAbsCoorY", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorY)) 49 ->addMethod("getAbsCoorZ", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorZ)) 50 ->addMethod("setAirFriction", ExecutorLua1<Spacecraft2D, float>(&Spacecraft2D::setAirFriction)) 51 ); 38 52 39 53 /** … … 110 124 this->rotation = 0.0f; 111 125 this->acceleration = 10.0f; 112 this->airFriction = 2.0f;126 this->airFriction = 0.0f; 113 127 114 128 … … 416 430 417 431 accel.y = 0.0; 432 433 418 434 Vector accelerationDir = this->getAbsDir().apply(accel * this->acceleration); 419 435 accelerationDir.y = 0.0; 420 436 437 438 /* 439 if (this->getRelCoor().z > this->travelDistance.y && accel.z > 0.0) 440 accel.z = 0.0f; 441 if (this->getRelCoor().z < -this->travelDistance.y && accel.z < 0.0) 442 accel.z = 0.0f; 443 444 if (this->getRelCoor().x > this->travelDistance.x && accel.x > 0.0) 445 accel.x = 0.0f; 446 if (this->getRelCoor().x < -this->travelDistance.x && accel.x < 0.0) 447 accel.x = 0.0f;*/ 448 449 421 450 // this is the air friction (necessary for a smooth control) 422 451 Vector damping = (this->velocity * this->airFriction); … … 424 453 425 454 this->velocity += (accelerationDir - damping)* dt; 455 456 if (this->getRelCoor().z > this->travelDistance.y && accel.z > 0.0) 457 this->velocity.z = 0.0f; 458 if (this->getRelCoor().z < -this->travelDistance.y && accel.z < 0.0) 459 this->velocity.z = 0.0f; 460 461 if (this->getRelCoor().x > this->travelDistance.x && accel.x > 0.0) 462 this->velocity.x = 0.0f; 463 if (this->getRelCoor().x < -this->travelDistance.x && accel.x < 0.0) 464 this->velocity.x = 0.0f; 465 466 426 467 this->shiftCoor (this->velocity * dt); 427 this->setRelDirSoft(Quaternion(0, Vector(0,0,0)) * Quaternion(this->velocity.z * .01, Vector(1,0,0)), 2.0f); 468 if (accel.z == 0) 469 this->setRelDirSoft(Quaternion(0, Vector(0,0,0)), 3.0f); 470 else 471 this->setRelDirSoft(Quaternion(this->velocity.z * .01, Vector(1,0,0)), 2.0f); 428 472 } 429 473 break; -
branches/presentation/src/world_entities/space_ships/spacecraft_2d.h
r9110 r9124 27 27 void setTravelDistance(const Vector2D& distance); 28 28 void setTravelDistance(float x, float y); 29 30 void setAirFriction(float friction) { this->airFriction = friction; }; 29 31 30 32
Note: See TracChangeset
for help on using the changeset viewer.