Changeset 10017 for code/branches/pickupsFS14/src
- Timestamp:
- Apr 3, 2014, 2:35:54 PM (11 years ago)
- Location:
- code/branches/pickupsFS14/src
- Files:
-
- 2 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/pickupsFS14/src/Orxonox.cc
r8858 r10017 27 27 * 28 28 */ 29 30 29 31 30 32 /** -
code/branches/pickupsFS14/src/modules/jump/CMakeLists.txt
r10005 r10017 4 4 JumpCenterPoint.cc 5 5 JumpShip.cc 6 JumpPlatform.cc 6 7 END_BUILD_UNIT 7 8 ) -
code/branches/pickupsFS14/src/modules/jump/Jump.cc
r10005 r10017 46 46 #include "JumpCenterPoint.h" 47 47 #include "JumpShip.h" 48 #include "JumpPlatform.h" 48 49 /* 49 50 #include "JumpEnemy.h" -
code/branches/pickupsFS14/src/modules/jump/JumpCenterPoint.cc
r10005 r10017 70 70 } 71 71 } 72 73 72 74 } -
code/branches/pickupsFS14/src/modules/jump/JumpShip.cc
r10005 r10017 49 49 //isFireing = false; 50 50 //damping = 10; 51 left = false; 52 right = false; 53 51 leftPressed = false; 52 rightPressed = false; 53 upPressed = false; 54 downPressed = false; 55 56 yScreenPosition = 0; 57 yVelocity = 0; 54 58 } 55 59 56 60 void JumpShip::tick(float dt) 57 61 { 58 59 Vector3 pos= getPosition();62 Vector3 movement(0,0,0); 63 Vector3 shipPosition = getPosition(); 60 64 61 65 /* … … 95 99 if (isFireing) 96 100 ControllableEntity::fire(0); 97 101 */ 98 102 // Camera 99 WeakPtr<Camera> camera = this->getCamera(); 100 if (camera != NULL) 101 { 102 camera->setPosition(Vector3(-pos.z, -posforeward, 0)); 103 camera->setOrientation(Vector3::UNIT_Z, Degree(90)); 104 } 105 106 107 103 104 105 106 107 /* 108 108 // bring back on track! 109 109 if(pos.y != 0) … … 121 121 */ 122 122 123 if (left == true) 124 { 125 pos += Vector3(100 + pos.y, 0, 0) * dt; 126 left = false; 127 } 128 else if (right == true) 129 { 130 right = false; 131 } 132 133 setPosition(pos); 134 123 // Berechne Bewegung anhand der Eingabe 124 if (leftPressed == true) 125 { 126 movement -= Vector3(xVelocity, 0, 0); 127 leftPressed = false; 128 } 129 else if (rightPressed == true) 130 { 131 movement += Vector3(xVelocity, 0, 0); 132 rightPressed = false; 133 } 134 135 if (upPressed == true) 136 { 137 //movement += Vector3(0, xVelocity, 0); 138 yVelocity = ySpeedAfterJump; 139 upPressed = false; 140 } 141 else if (downPressed == true) 142 { 143 movement -= Vector3(0, 0, 0); 144 downPressed = false; 145 } 146 147 movement += Vector3(0, yVelocity, 0); 148 yVelocity -= yAcceleration; 149 150 // Skalierung der Bewegung je nach vergangener Zeit 151 movement *= dt; 152 153 // Verschiebe das Schiff um den berechneten Vektor movement und verhindere Verlassen des Bildschrims 154 shipPosition.x = clamp(shipPosition.x + movement.x, -xBoundary, xBoundary); 155 shipPosition.y += movement.y; 156 157 setPosition(shipPosition); 158 159 // Bildschirmposition kann nur nach oben verschoben werden 160 if (shipPosition.y > yScreenPosition) 161 { 162 yScreenPosition = shipPosition.y; 163 } 164 165 // Kameraposition nachfuehren 166 if (camera == NULL) 167 { 168 camera = getCamera(); 169 } 170 if (camera != NULL) 171 { 172 173 camera->setPosition(Vector3(-shipPosition.x, yScreenPosition-shipPosition.y, 100)); 174 //camera->setOrientation(Vector3::UNIT_Z, Degree(180)); 175 } 135 176 136 177 SUPER(JumpShip, tick, dt); … … 146 187 void JumpShip::moveFrontBack(const Vector2& value) 147 188 { 189 if (value.y < 0) 190 { 191 downPressed = true; 192 } 193 else if (value.y > 0) 194 { 195 upPressed = true; 196 } 148 197 //lastTimeLeft = 0; 149 198 //desiredVelocity.x = -value.x * speed; … … 152 201 void JumpShip::moveRightLeft(const Vector2& value) 153 202 { 154 if (value. y< 0)155 { 156 left = true;157 } 158 else if (value. y> 0)159 { 160 right = true;203 if (value.x < 0) 204 { 205 leftPressed = true; 206 } 207 else if (value.x > 0) 208 { 209 rightPressed = true; 161 210 } 162 211 //lastTimeFront = 0; -
code/branches/pickupsFS14/src/modules/jump/JumpShip.h
r10005 r10017 56 56 // Starts or stops fireing 57 57 virtual void boost(bool bBoost); 58 58 */ 59 59 //no rotation! 60 60 virtual void rotateYaw(const Vector2& value){}; 61 61 virtual void rotatePitch(const Vector2& value){}; 62 62 //return to main menu if game has ended. 63 virtual void rotateRoll(const Vector2& value){ if (getGame()) if (getGame()->bEndGame) getGame()->end();};63 virtual void rotateRoll(const Vector2& value){}; 64 64 65 virtual void updateLevel();65 /*virtual void updateLevel(); 66 66 67 67 virtual inline bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint); … … 72 72 WeakPtr<Jump> getGame(); 73 73 WeakPtr<Jump> game; 74 //Camera* camera; 74 WeakPtr<Camera> camera; 75 const float xVelocity = 150.0f; 76 const float xBoundary = 200.0f; 77 78 75 79 //bool isFireing; 76 80 //float speed; … … 90 94 } velocity, desiredVelocity;*/ 91 95 92 bool left; 93 bool right; 96 bool leftPressed; 97 bool rightPressed; 98 bool upPressed; 99 bool downPressed; 94 100 95 96 101 float yScreenPosition; 102 float yVelocity; 103 const float yAcceleration = 10.0f; 104 const float ySpeedAfterJump = 300.0f; 97 105 }; 98 106 }
Note: See TracChangeset
for help on using the changeset viewer.