- Timestamp:
- Apr 26, 2018, 3:22:59 PM (7 years ago)
- Location:
- code/branches/OrxyRoad_FS18/src/modules/orxyroad
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/OrxyRoad_FS18/src/modules/orxyroad/OrxyRoadShip.cc
r11899 r11908 51 51 lastTimeLeft = 0; 52 52 lastTime = 0; 53 steeredLeft = false; 54 steeredRight = false; 55 forward = false; 56 backward = false; 53 57 } 54 58 55 59 void OrxyRoadShip::tick(float dt) 56 60 { 57 orxout(user_info) << "This is some cool output!" << endl;61 //orxout(user_info) << "This is some cool output!" << endl; 58 62 59 63 Vector3 pos = getPosition(); 64 Vector3 pos1 = getPosition(); 60 65 61 66 //Movement calculation … … 64 69 lastTime += dt; 65 70 66 velocity.x = interpolate(clamp(lastTimeLeft, 0.0f, 1.0f), desiredVelocity.x, 0.0f); 67 velocity.y = interpolate(clamp(lastTimeFront, 0.0f, 1.0f), desiredVelocity.y, 0.0f); 71 72 //velocity.x = interpolate(clamp(lastTimeLeft, 0.0f, 1.0f), desiredVelocity.x, 0.0f); 73 //velocity.y = interpolate(clamp(lastTimeFront, 0.0f, 1.0f), desiredVelocity.y, 0.0f); 68 74 69 75 //Execute movement 76 70 77 if (this->hasLocalController()) 71 78 { 72 79 float dist_y = velocity.y * dt; 80 //forward backwards movement 81 if(forward){ 82 if(velocity.y < 200){// Limit for max velocity 83 velocity.y += 10; 84 } 85 86 87 }else if(backward){ 88 if(velocity.y > 10){ 89 velocity.y -= 10; 90 }else { 91 velocity.y = 0; // Prevent players from going backwards 92 } 93 94 }else { 95 velocity.y = 0.9 * velocity.y;//reduce speed 96 } 97 98 99 100 73 101 //float dist_x = velocity.x * dt; 74 if(dist_y + posforeward > -42*3 && dist_y + posforeward < 42*6)75 posforeward += dist_y;76 else77 {78 velocity.y = 0;102 //if(dist_y + posforeward > -42*3 && dist_y + posforeward < 42*6) 103 // posforeward += dist_y; 104 //else 105 //{ 106 //velocity.y = 0; 79 107 // restart if game ended 80 108 /* … … 85 113 return; 86 114 }*/ 115 //} 116 117 //Left right steering 118 119 120 if(steeredLeft){ 121 velocity.x += 100; 122 steeredLeft = false; 123 124 }else if(steeredRight) { 125 velocity.x += -100; 126 steeredRight = false; 127 }else { 128 if(velocity.x < -2 || velocity.x > 2 ){ 129 velocity.x = velocity.x *0.9; 130 }else{ 131 velocity.x += 0; 132 } 133 87 134 } 88 135 89 pos += Vector3(1000 + velocity.y, 0, velocity.x) * dt; 90 } 136 pos += Vector3(velocity.y, 0, velocity.x) * dt; 137 138 } 139 91 140 92 141 … … 95 144 if (camera != nullptr) 96 145 { 97 // camera->setPosition(Vector3(-pos.z, -posforeward, 0)); 98 camera->setOrientation(Vector3::UNIT_Z, Degree(0)); 146 //camera->setPosition(Vector3(pos1.x - 10 ,50,0)); 147 //camera->setOrientation(Vector3(-1,-1,0), Degree(45)); 148 //camera->setOrientation(Vector3(-1,-1,-1), Degree(0)); 149 camera->setOrientation(Vector3::UNIT_Z, Degree(0)); 99 150 } 100 151 … … 129 180 void OrxyRoadShip::moveFrontBack(const Vector2& value) 130 181 { 182 this->steering_.z -= value.x ; 183 if(value.x > 0){ 184 forward = true; 185 backward = false; 186 }else if(value.x < 0){ 187 forward = false; 188 backward = true; 189 } 190 131 191 //lastTimeFront = 0; 132 192 //desiredVelocity.y = value.y * speed * 42; … … 136 196 void OrxyRoadShip::moveRightLeft(const Vector2& value) 137 197 { 138 lastTimeLeft = 0; 139 desiredVelocity.x = value.x * speed; 198 this->steering_.x += value.x; 199 if(value.x==-1){ 200 steeredLeft = false; 201 steeredRight = true; 202 orxout(user_info) << "Steering RIGHT "<<steering_.x << endl; 203 }else { 204 steeredRight = false; 205 steeredLeft = true; 206 orxout(user_info) << "Steering LEFT "<<steering_.x << endl; 207 208 } 209 210 211 //lastTimeLeft = 0; 212 //desiredVelocity.x = value.x * speed; 140 213 } 141 214 void OrxyRoadShip::boost(bool bBoost) 142 215 { 143 // getGame()->bEndGame= bBoost;216 //bool boosting = bBoost; 144 217 } 145 218 -
code/branches/OrxyRoad_FS18/src/modules/orxyroad/OrxyRoadShip.h
r11891 r11908 74 74 float speed, damping, posforeward; 75 75 bool isFireing; 76 bool steeredLeft, steeredRight, forward, backward; 76 77 77 78 protected:
Note: See TracChangeset
for help on using the changeset viewer.