- Timestamp:
- Nov 5, 2014, 4:06:09 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/pickupsFS14/src/modules/jump/JumpPlatformHMove.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 JumpPlatformHMove.cc 31 @brief Implementation of the JumpPlatform class.31 @brief This platform can move horizontally. 32 32 */ 33 33 34 34 #include "JumpPlatformHMove.h" 35 36 35 #include "core/CoreIncludes.h" 37 36 #include "core/GameMode.h" 38 39 37 #include "gametypes/Gametype.h" 40 41 38 #include "JumpFigure.h" 42 43 39 #include "sound/WorldSound.h" 44 40 #include "core/XMLPort.h" 45 46 #include "graphics/Backlight.h"47 41 48 42 namespace orxonox … … 50 44 RegisterClass(JumpPlatformHMove); 51 45 52 /**53 @brief54 Constructor. Registers and initializes the object.55 */56 46 JumpPlatformHMove::JumpPlatformHMove(Context* context) : JumpPlatform(context) 57 47 { … … 61 51 } 62 52 63 /**64 @brief65 Destructor.66 */67 53 JumpPlatformHMove::~JumpPlatformHMove() 68 54 { … … 70 56 } 71 57 72 //xml port for loading sounds73 58 void JumpPlatformHMove::XMLPort(Element& xmlelement, XMLPort::Mode mode) 74 59 { … … 76 61 } 77 62 78 /**79 @brief80 Is called every tick.81 Handles the movement of the ball and its interaction with the boundaries and bats.82 @param dt83 The time since the last tick.84 */85 63 void JumpPlatformHMove::tick(float dt) 86 64 { … … 88 66 89 67 // Get the current position, velocity and acceleration of the ball. 90 Vector3 position = this->getPosition();91 Vector3 velocity = this->getVelocity();68 Vector3 position = getPosition(); 69 Vector3 velocity = getVelocity(); 92 70 93 71 if ((position.x < leftBoundary_ && velocity.x < 0) || (position.x > rightBoundary_ && velocity.x > 0)) 94 72 95 73 { 96 //orxout() << "refelected platformHMove at " << position.x << endl;97 74 velocity.x = -velocity.x; 98 75 } 99 76 100 77 // Set the position, velocity and acceleration of the ball, if they have changed. 101 if (velocity != this->getVelocity()) 102 this->setVelocity(velocity); 78 if (velocity != getVelocity()) 79 { 80 setVelocity(velocity); 81 } 103 82 if (position != this->getPosition()) 104 this->setPosition(position); 83 { 84 setPosition(position); 85 } 105 86 } 106 87 … … 109 90 leftBoundary_ = leftBoundary; 110 91 rightBoundary_ = rightBoundary; 111 112 this->setVelocity(Vector3(speed,0,0)); 113 92 setVelocity(Vector3(speed,0,0)); 114 93 } 115 94
Note: See TracChangeset
for help on using the changeset viewer.