- Timestamp:
- Nov 27, 2017, 5:00:59 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/Asteroid_HS17/src/modules/minigametest/MiniGameTestShip.cc
r11593 r11608 55 55 void MiniGameTestShip::tick(float dt) 56 56 { 57 Vector3 pos = getPosition();58 59 //Movement calculation60 lastTimeFront += dt * damping;61 lastTimeLeft += dt * damping;62 lastTime += dt;63 64 velocity.x = interpolate(clamp(lastTimeLeft, 0.0f, 1.0f), desiredVelocity.x, 0.0f);65 velocity.y = interpolate(clamp(lastTimeFront, 0.0f, 1.0f), desiredVelocity.y, 0.0f);66 67 //Execute movement68 if (this->hasLocalController())69 {70 float dist_y = velocity.y * dt;71 //float dist_x = velocity.x * dt;72 if(dist_y + posforeward > -42*3 && dist_y + posforeward < 42*6)73 posforeward += dist_y;74 else75 {76 velocity.y = 0;77 // restart if game ended78 /*79 if (getGame())80 if (getGame()->bEndGame)81 {82 getGame()->start();83 return;84 }*/85 }86 87 pos += Vector3(1000 + velocity.y, 0, velocity.x) * dt;88 }89 90 91 // Camera92 Camera* camera = this->getCamera();93 if (camera != nullptr)94 {95 // camera->setPosition(Vector3(-pos.z, -posforeward, 0));96 camera->setOrientation(Vector3::UNIT_Z, Degree(0));97 }98 99 100 101 // bring back on track!102 if(pos.y != 0)103 {104 pos.y = 0;105 }106 107 setPosition(pos);108 setOrientation(Vector3::UNIT_Y, Degree(270));109 110 // Level up!111 if (pos.x > 42000)112 {113 updateLevel();114 setPosition(Vector3(0, 0, pos.z)); // pos - Vector3(30000, 0, 0)115 }116 117 57 SUPER(MiniGameTestShip, tick, dt); 118 58 } … … 125 65 } 126 66 127 void MiniGameTestShip::moveFrontBack(const Vector2& value)67 /* void MiniGameTestShip::moveFrontBack(const Vector2& value) 128 68 { 129 69 //lastTimeFront = 0; 130 70 //desiredVelocity.y = value.y * speed * 42; 131 71 orxout() << "FrontBack" << endl; 72 SUPER(MiniGameTestShip, moveFrontBack, value); 132 73 } 133 74 134 75 void MiniGameTestShip::moveRightLeft(const Vector2& value) 135 76 { 136 lastTimeLeft = 0; 137 desiredVelocity.x = value.x * speed; 77 //lastTimeLeft = 0; 78 //desiredVelocity.x = value.x * speed; 79 orxout() << "RightLeft" << endl; 80 SUPER(MiniGameTestShip, moveFrontBack, value); 138 81 } 82 */ 139 83 void MiniGameTestShip::boost(bool bBoost) 140 84 {
Note: See TracChangeset
for help on using the changeset viewer.