Changeset 6387 for code/branches/presentation2/src/modules/pong
- Timestamp:
- Dec 21, 2009, 1:18:36 PM (15 years ago)
- Location:
- code/branches/presentation2/src/modules/pong
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation2/src/modules/pong/Pong.cc
r5929 r6387 42 42 CreateEventName(PongCenterpoint, right); 43 43 CreateEventName(PongCenterpoint, left); 44 44 45 45 CreateUnloadableFactory(Pong); 46 46 … … 164 164 else if (player == this->getLeftPlayer()) 165 165 this->center_->fireEvent(FireEventName(PongCenterpoint, left)); 166 166 167 167 if (player) 168 168 this->gtinfo_->sendAnnounceMessage(player->getName() + " scored"); -
code/branches/presentation2/src/modules/pong/PongAI.cc
r5929 r6387 131 131 this->bOscillationAvoidanceActive_ = false; 132 132 } 133 133 134 134 // If the ball is close enough, calculate another random offset to accelerate the ball 135 135 if (!this->bChangedRandomOffset_) … … 206 206 // calculate the time until the ball reaches the other side 207 207 float totaltime = (-position.x + dimension.x / 2 * sgn(velocity.x)) / velocity.x; 208 208 209 209 // calculate wall bounce position (four possible solutions of the equation: pos.z + vel.z*t + acc.z/2*t^2 = +/- dim.z/2) 210 210 float bouncetime = totaltime; 211 211 bool bUpperWall = false; 212 212 213 213 if (acceleration.z == 0) 214 214 { … … 270 270 // ball bounces after <bouncetime> seconds, update the position and continue 271 271 velocity.z = velocity.z + acceleration.z * bouncetime; 272 272 273 273 if (bUpperWall) 274 274 { … … 281 281 velocity.z = fabs(velocity.z) - fabs(randomErrorZ); 282 282 } 283 283 284 284 position.x = position.x + velocity.x * bouncetime + randomErrorX; 285 285 this->ballEndPosition_ = position.z; -
code/branches/presentation2/src/modules/pong/PongBall.cc
r5929 r6387 105 105 velocity.z = distance * distance * sgn(distance) * PongBall::MAX_REL_Z_VELOCITY * this->speed_; 106 106 acceleration = this->bat_[1]->getVelocity() * this->accelerationFactor_ * -1; 107 107 108 108 this->fireEvent(); 109 109 }
Note: See TracChangeset
for help on using the changeset viewer.