Changeset 8108 for code/trunk/src/modules/pong/PongBat.cc
- Timestamp:
- Mar 23, 2011, 9:57:54 PM (13 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
/code/branches/tetris (added) merged: 8104-8107
- Property svn:mergeinfo changed
-
code/trunk/src/modules/pong/PongBat.cc
r5781 r8108 27 27 */ 28 28 29 /** 30 @file PongBat.cc 31 @brief Implementation of the PongBat class. 32 */ 33 29 34 #include "PongBat.h" 30 35 … … 36 41 CreateFactory(PongBat); 37 42 43 /** 44 @brief 45 Constructor. Registers and initializes the object. 46 */ 38 47 PongBat::PongBat(BaseObject* creator) : ControllableEntity(creator) 39 48 { … … 50 59 } 51 60 61 /** 62 @brief 63 Registers variables to be synchronized over the network. 64 */ 52 65 void PongBat::registerVariables() 53 66 { … … 57 70 } 58 71 72 /** 73 @brief 74 Is called each tick. 75 Moves the bat. 76 @param dt 77 The time since last tick. 78 */ 59 79 void PongBat::tick(float dt) 60 80 { 81 // If the bat is controlled (but not over the network). 61 82 if (this->hasLocalController()) 62 83 { 63 84 if (this->movement_ != 0) 64 85 { 86 // The absolute value of the movement is restricted to be lesser or equal than the speed of the bat. 65 87 this->movement_ = clamp(this->movement_, -1.0f, 1.0f) * this->speed_; 66 88 89 // If moveRightLeft() is used the movement is dependento on wehther it is the right or the left bat, so, it is i.e. dependent on the orientation of the bat. 67 90 if (this->bMoveLocal_) 68 91 this->setVelocity(this->getOrientation() * Vector3(this->movement_, 0, 0)); … … 73 96 this->bSteadiedPosition_ = false; 74 97 } 98 // If there is no movement but the position has not been steadied, the velocity is set to zero and the position is reaffirmed. 75 99 else if (!this->bSteadiedPosition_) 76 100 { … … 84 108 SUPER(PongBat, tick, dt); 85 109 110 // Restrict the position of the bats, for them to always be between the upper and lower delimiters. i.e. the bats stall if they reach the upper or lower boundary. 86 111 Vector3 position = this->getPosition(); 87 112 if (position.z > this->fieldHeight_ / 2 - this->fieldHeight_ * this->length_ / 2) … … 96 121 } 97 122 123 /** 124 @brief 125 Overloaded the function to steer the bat up and down. 126 @param value 127 A vector whose first component is the inverse direction in which we want to steer the bat. 128 */ 98 129 void PongBat::moveFrontBack(const Vector2& value) 99 130 { … … 102 133 } 103 134 135 /** 136 @brief 137 Overloaded the function to steer the bat up and down. 138 @param value 139 A vector whose first component is the direction in which we wnat to steer the bat. 140 */ 104 141 void PongBat::moveRightLeft(const Vector2& value) 105 142 { … … 108 145 } 109 146 147 /** 148 @brief 149 Is called when the player changed. 150 */ 110 151 void PongBat::changedPlayer() 111 152 {
Note: See TracChangeset
for help on using the changeset viewer.