- Timestamp:
- Nov 27, 2017, 5:00:59 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DShip.cc
r11593 r11608 55 55 void Asteroids2DShip::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 // bring back on track!91 if(pos.y != 0)92 {93 pos.y = 0;94 }95 96 setPosition(pos);97 setOrientation(Vector3::UNIT_Y, Degree(270));98 99 57 SUPER(Asteroids2DShip, tick, dt); 100 58 } 101 59 102 void Asteroids2DShip::moveFrontBack(const Vector2& value) 60 void Asteroids2DShip::updateLevel() 61 { 62 lastTime = 0; 63 if (getGame()) 64 getGame()->levelUp(); 65 } 66 67 /* void Asteroids2DShip::moveFrontBack(const Vector2& value) 103 68 { 104 69 //lastTimeFront = 0; 105 70 //desiredVelocity.y = value.y * speed * 42; 106 71 orxout() << "FrontBack" << endl; 72 SUPER(Asteroids2DShip, moveFrontBack, value); 107 73 } 108 74 109 75 void Asteroids2DShip::moveRightLeft(const Vector2& value) 110 76 { 111 lastTimeLeft = 0; 112 desiredVelocity.x = value.x * speed; 77 //lastTimeLeft = 0; 78 //desiredVelocity.x = value.x * speed; 79 orxout() << "RightLeft" << endl; 80 SUPER(Asteroids2DShip, moveFrontBack, value); 113 81 } 82 */ 114 83 void Asteroids2DShip::boost(bool bBoost) 115 84 { … … 139 108 void Asteroids2DShip::death() 140 109 { 141 //getGame()->costLife();110 getGame()->costLife(); 142 111 SpaceShip::death(); 143 112 }
Note: See TracChangeset
for help on using the changeset viewer.