- Timestamp:
- Nov 5, 2014, 4:06:09 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/pickupsFS14/src/modules/jump/JumpFigure.cc
r10074 r10111 21 21 * 22 22 * Author: 23 * Fabi an 'x3n' Landau23 * Fabien Vultier 24 24 * Co-authors: 25 25 * ... … … 29 29 /** 30 30 @file JumpFigure.cc 31 @brief Implementation of the JumpFigure class.31 @brief This class represents your figure when you play the minigame. Here the movement of the figure, activating items, ... are handled. 32 32 */ 33 33 … … 41 41 RegisterClass(JumpFigure); 42 42 43 /**44 @brief45 Constructor. Registers and initializes the object.46 */47 43 JumpFigure::JumpFigure(Context* context) : ControllableEntity(context) 48 44 { 49 45 RegisterObject(JumpFigure); 50 46 47 // initialize variables 51 48 leftHand_ = NULL; 52 49 rightHand_ = NULL; 53 54 50 fieldHeight_ = 0; 55 51 fieldWidth_ = 0; 56 57 52 jumpSpeed_ = 0.0; 58 53 handSpeed_ = 0.0; … … 62 57 propellerPos_ = 0.0; 63 58 bootsPos_ = 0.0; 64 65 moveUpPressed = false; 66 moveDownPressed = false; 67 moveLeftPressed = false; 68 moveDownPressed = false; 69 firePressed = false; 70 fireSignal = false; 71 timeSinceLastFire = 0.0; 72 73 gravityAcceleration = 8.0; 59 moveUpPressed_ = false; 60 moveDownPressed_ = false; 61 moveLeftPressed_ = false; 62 moveDownPressed_ = false; 63 firePressed_ = false; 64 fireSignal_ = false; 65 timeSinceLastFire_ = 0.0; 66 gravityAcceleration_ = 8.0; 74 67 mouseFactor_ = 75.0; 75 maxFireRate = 0.3; 76 68 maxFireRate_ = 0.3; 77 69 handAngle_ = 0.0; 78 70 animateHands_ = false; 79 71 turnUp_ = false; 80 81 72 rocketActive_ = false; 82 73 propellerActive_ = false; … … 85 76 rocketSpeed_ = 0.0; 86 77 propellerSpeed_ = 0.0; 87 88 78 dead_ = false; 89 79 } 90 80 91 /**92 @brief93 Method to create a JumpCenterpoint through XML.94 */95 81 void JumpFigure::XMLPort(Element& xmlelement, XMLPort::Mode mode) 96 82 { … … 110 96 } 111 97 112 /**113 @brief114 Is called each tick.115 Moves the bat.116 @param dt117 The time since last tick.118 */119 98 void JumpFigure::tick(float dt) 120 99 { 121 100 SUPER(JumpFigure, tick, dt); 122 101 123 // If the bat is controlled (but not over the network).124 102 if (hasLocalController()) 125 103 { 126 timeSinceLastFire += dt;104 timeSinceLastFire_ += dt; 127 105 128 106 // Move up/down … … 138 116 else 139 117 { 140 velocity.z -= gravityAcceleration ;118 velocity.z -= gravityAcceleration_; 141 119 } 142 120 … … 174 152 if (dead_ == false) 175 153 { 176 velocity.x = -mouseFactor_*horizontalSpeed ;154 velocity.x = -mouseFactor_*horizontalSpeed_; 177 155 } 178 156 else … … 182 160 183 161 // Cheats 184 if (moveUpPressed== true)185 { 186 velocity.z = 200.0f;187 moveUpPressed = false;162 /*if (moveUpPressed_ == true) 163 { 164 velocity.z = 400.0f; 165 moveUpPressed_ = false; 188 166 dead_ = false; 189 167 } 190 if (moveDownPressed == true)191 { 192 moveDownPressed = false;193 } 168 if (moveDownPressed_ == true) 169 { 170 moveDownPressed_ = false; 171 }*/ 194 172 195 173 setVelocity(velocity); 196 174 197 175 198 if (firePressed && timeSinceLastFire >= maxFireRate) 199 { 200 firePressed = false; 201 timeSinceLastFire = 0.0; 202 fireSignal = true; 203 //orxout() << "fired signal set" << endl; 176 if (firePressed_ && timeSinceLastFire_ >= maxFireRate_) 177 { 178 firePressed_ = false; 179 timeSinceLastFire_ = 0.0; 180 fireSignal_ = true; 204 181 } 205 182 } … … 218 195 219 196 // Reset key variables 220 moveUpPressed = false;221 moveDownPressed = false;222 moveLeftPressed = false;223 moveDownPressed = false;224 firePressed = false;197 moveUpPressed_ = false; 198 moveDownPressed_ = false; 199 moveLeftPressed_ = false; 200 moveDownPressed_ = false; 201 firePressed_ = false; 225 202 } 226 203 … … 365 342 } 366 343 367 /**368 @briefhandPosition_369 Overloaded the function to steer the bat up and down.370 @param value371 A vector whose first component is the inverse direction in which we want to steer the bat.372 */373 344 void JumpFigure::moveFrontBack(const Vector2& value) 374 345 { 375 346 if (value.x > 0) 376 347 { 377 //orxout() << "up pressed" << endl; 378 moveUpPressed = true; 379 moveDownPressed = false; 348 moveUpPressed_ = true; 349 moveDownPressed_ = false; 380 350 } 381 351 else 382 352 { 383 //orxout() << "down pressed" << endl; 384 moveUpPressed = false; 385 moveDownPressed = true; 386 } 387 } 388 389 /** 390 @brief 391 Overloaded the function to steer the bat up and down. 392 @param value 393 A vector whose first component is the direction in which we wnat to steer the bat. 394 */ 353 moveUpPressed_ = false; 354 moveDownPressed_ = true; 355 } 356 } 357 395 358 void JumpFigure::moveRightLeft(const Vector2& value) 396 359 { 397 360 if (value.x > 0) 398 361 { 399 moveLeftPressed = false;400 moveRightPressed = true;362 moveLeftPressed_ = false; 363 moveRightPressed_ = true; 401 364 } 402 365 else 403 366 { 404 moveLeftPressed = true;405 moveRightPressed = false;367 moveLeftPressed_ = true; 368 moveRightPressed_ = false; 406 369 } 407 370 } … … 409 372 void JumpFigure::rotateYaw(const Vector2& value) 410 373 { 411 horizontalSpeed = value.x;374 horizontalSpeed_ = value.x; 412 375 } 413 376 … … 426 389 void JumpFigure::fire(unsigned int firemode) 427 390 { 428 //SUPER(JumpFigure, fire, firemode); 391 429 392 } 430 393 431 394 void JumpFigure::fired(unsigned int firemode) 432 395 { 433 //SUPER(JumpFigure, fired, firemode); 434 firePressed = true; 396 firePressed_ = true; 435 397 } 436 398 }
Note: See TracChangeset
for help on using the changeset viewer.