- Timestamp:
- Mar 30, 2017, 3:52:23 PM (8 years ago)
- Location:
- code/branches/SuperOrxoBros_FS17
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/SuperOrxoBros_FS17/data/levels/SOB.oxw
r11381 r11383 16 16 <SOBFigure> 17 17 <camerapositions> 18 <CameraPosition position="0,-150,0" absolute= false mouselook=false drag=false lookat="0,0,0"/>18 <CameraPosition position="0,-150,0" absolute=true mouselook=false drag=false lookat="0,0,0"/> 19 19 </camerapositions> 20 20 </SOBFigure> … … 82 82 <StaticEntity position="0,-1,-10" collisionType="static"> 83 83 <attached> 84 <Model mesh="cube.mesh" scale3D=" 76,76,1" />84 <Model mesh="cube.mesh" scale3D="110,76,1" /> 85 85 </attached> 86 86 87 87 <collisionShapes> 88 <BoxCollisionShape position="0,0,0" halfExtents=" 76,76,1" />88 <BoxCollisionShape position="0,0,0" halfExtents="110,76,1" /> 89 89 </collisionShapes> 90 90 </StaticEntity> -
code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOB.cc
r11381 r11383 93 93 } 94 94 95 center_->attach(figure_); //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@95 center_->attach(figure_); 96 96 figure_->setPosition(0, 0, 0); 97 97 } -
code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOB.h
r11381 r11383 66 66 67 67 68 void cleanup(); //!< Cleans up the Gametype by destroying the ball and the bats.68 void cleanup(); //!< Cleans up the Gametype 69 69 WeakPtr<SOBCenterpoint> center_; 70 70 WeakPtr<SOBFigure> figure_; -
code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBFigure.cc
r11381 r11383 37 37 #include "core/XMLPort.h" 38 38 #include "graphics/Model.h" 39 #include "graphics/Camera.h" 39 40 40 41 … … 48 49 49 50 // initialize variables 50 51 51 52 moveUpPressed_ = false; 52 53 moveDownPressed_ = false; … … 55 56 firePressed_ = false; 56 57 timeSinceLastFire_ = 0.0; 57 58 lastSpeed_z = 0.0; 59 58 60 gravityAcceleration_ = 250.0;//8.0 59 61 60 62 dead_ = false; 61 63 setAngularFactor(0.0); … … 65 67 { 66 68 SUPER(SOBFigure, XMLPort, xmlelement, mode); 67 69 68 70 } 69 71 … … 74 76 if (hasLocalController()) 75 77 { 76 timeSinceLastFire_ += dt; 77 78 // Move up/down 79 Vector3 velocity = getVelocity(); 80 81 82 83 84 85 86 87 88 // Move left/right 89 if (dead_ == false) 90 { 91 92 if (firePressed_ && std::abs(velocity.z) < 0.1) { 93 velocity.z = 200; 94 } else { 95 96 } 97 98 99 100 101 if (moveRightPressed_) 102 velocity.x = 75; 103 else if (moveLeftPressed_) 104 velocity.x = -75; 105 else 106 velocity.x = 0; 78 Vector3 velocity = getVelocity(); 79 Vector3 position = getPosition(); 80 81 if (dead_) { 82 velocity.x = 0; 83 velocity.z = 0; 84 setVelocity(velocity); 85 return; 86 } 87 88 89 int maxvelocity_x = 100; 90 int speedAddedPerTick = 5; 91 int camMaxOffset = 25; 92 93 timeSinceLastFire_ += dt; 94 lastSpeed_z = velocity.z; 95 96 97 98 //If player hits space and does not move in z-dir 99 if (firePressed_ && std::abs(velocity.z) < 0.07 && std::abs(lastSpeed_z) < 0.07) { 100 velocity.z = 150; 101 } 102 103 //Left-right movement with acceleration 104 if (moveRightPressed_) { 105 if (std::abs(velocity.x) < maxvelocity_x) { 106 velocity.x += speedAddedPerTick; 107 107 } 108 else109 {110 velocity.x = 0.0;108 } else if (moveLeftPressed_) { 109 if (std::abs(velocity.x) < maxvelocity_x) { 110 velocity.x -= speedAddedPerTick; 111 111 } 112 velocity.z -= gravityAcceleration_*dt; 113 114 115 116 setVelocity(velocity); 117 118 112 } else { 113 velocity.x /= 1.1; 114 } 119 115 120 } 116 117 velocity.z -= gravityAcceleration_*dt; 118 setVelocity(velocity); 119 120 121 //Camera operation 122 Camera* cam = getCamera(); 123 Vector3 campos = cam->getPosition(); 124 125 if (campos.x + camMaxOffset < position.x) { 126 campos.x = position.x - camMaxOffset; 127 cam->setPosition(campos); 128 } 129 if (campos.x - camMaxOffset > position.x) { 130 campos.x = position.x + camMaxOffset; 131 cam->setPosition(campos); 132 } 133 134 135 136 } 121 137 122 138 // Move through the left and right screen boundaries 123 139 124 140 //setPosition(position); 125 141 126 142 // Reset key variables 127 128 129 130 131 132 133 134 135 136 137 138 143 moveUpPressed_ = false; 144 moveDownPressed_ = false; 145 moveLeftPressed_ = false; 146 moveRightPressed_ = false; 147 moveDownPressed_ = false; 148 firePressed_ = false; 149 150 } 151 152 153 154 139 155 140 156 /* void SOBFigure::CollisionWithEnemy(SOBEnemy* enemy) … … 146 162 }*/ 147 163 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 } 164 165 166 167 168 169 void SOBFigure::moveFrontBack(const Vector2& value) 170 { 171 if (value.x > 0) 172 { 173 moveUpPressed_ = true; 174 moveDownPressed_ = false; 175 } 176 else 177 { 178 moveUpPressed_ = false; 179 moveDownPressed_ = true; 180 } 181 } 182 183 void SOBFigure::moveRightLeft(const Vector2& value) 184 { 185 if (value.x > 0) 186 { 187 moveLeftPressed_ = false; 188 moveRightPressed_ = true; 189 } 190 else 191 { 192 moveLeftPressed_ = true; 193 moveRightPressed_ = false; 194 } 195 } 196 197 198 199 200 201 void SOBFigure::boost(bool boost) 202 { 203 firePressed_ = true; 204 } 205 } -
code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBFigure.h
r11381 r11383 65 65 float gravityAcceleration_; 66 66 float timeSinceLastFire_; 67 float lastSpeed_z; 67 68 68 69
Note: See TracChangeset
for help on using the changeset viewer.