- Timestamp:
- May 16, 2019, 11:11:39 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxBall.cc
r12366 r12368 68 68 this->relMercyOffset_ = 0.05f; 69 69 this->orxoblox_ = this->getOrxoBlox(); 70 this->radius_ = 1.5;70 this->radius_ = 3; 71 71 72 72 this->registerVariables(); … … 137 137 138 138 // If the ball has gone over the top or bottom boundary of the playing field (i.e. the ball has hit the top or bottom delimiters). 139 if (position.z > this->fieldHeight_ / 2 || position.z < -this->fieldHeight_ / 2)139 if (position.z > this->fieldHeight_ / 2 || position.z - radius_ < -this->fieldHeight_ / 2) 140 140 { 141 141 defBoundarySound_->play(); //play boundary sound 142 142 // Its velocity in z-direction is inverted (i.e. it bounces off). 143 143 velocity.z = -velocity.z; 144 // And its position is set as to not overstep the boundary it has just crossed. 144 // And its position is set as to not overstep the boundary it has just crossed. Remember z axis is reverted!!! 145 145 if (position.z > this->fieldHeight_ / 2){ 146 146 // Set the ball to be exactly at the boundary. 147 position.z = this-> fieldHeight_ / 2 ;147 position.z = this-> fieldHeight_ / 2 - radius_; 148 148 149 149 orxoblox_->LevelUp(); … … 180 180 181 181 } 182 if (position.z < -this->fieldHeight_ / 2){183 position.z = -this->fieldHeight_ / 2 ;182 if (position.z - radius_ < -this->fieldHeight_ / 2){ 183 position.z = -this->fieldHeight_ / 2 + radius_; 184 184 185 185 } … … 190 190 //Ball hits the right or left wall and should bounce back. 191 191 // If the ball has crossed the left or right boundary of the playing field. 192 if (position.x > this->fieldWidth_ / 2 || position.x< -this->fieldWidth_ / 2)192 if (position.x + radius_ > this->fieldWidth_ / 2 || position.x - radius_ < -this->fieldWidth_ / 2) 193 193 { 194 194 //Ball hits the right Wall 195 if (position.x > this->fieldWidth_ / 2)195 if (position.x + radius_ > this->fieldWidth_ / 2) 196 196 { 197 197 // Set the ball to be exactly at the boundary. 198 position.x = this->fieldWidth_ / 2 ;198 position.x = this->fieldWidth_ / 2 - radius_; 199 199 // Invert its velocity in x-direction (i.e. it bounces off). 200 200 velocity.x = -velocity.x; … … 203 203 204 204 //Ball hits the left wall 205 else if (position.x < -this->fieldWidth_ / 2)205 else if (position.x - radius_ < -this->fieldWidth_ / 2) 206 206 { 207 207 // Set the ball to be exactly at the boundary. 208 position.x = -this->fieldWidth_ / 2 ;208 position.x = -this->fieldWidth_ / 2 + radius_; 209 209 // Invert its velocity in x-direction (i.e. it bounces off). 210 210 velocity.x = -velocity.x; … … 220 220 if (position != this->getPosition()) 221 221 this->setPosition(position); 222 this->Collides((this->orxoblox_->CheckForCollision(this)));222 //this->Collides((this->orxoblox_->CheckForCollision(this))); 223 223 224 224 … … 289 289 290 290 291 void OrxoBloxBall::Bounce( OrxoBloxStones* Stone) {291 void OrxoBloxBall::Bounce(WorldEntity* Stone) { 292 292 293 293 Vector3 velocity = this->getVelocity(); … … 337 337 Bounce(Stone); 338 338 //if(otherObject->getHealth() <= 0) { 339 Stone->destroy();339 //Stone->destroy(); 340 340 341 341 //} 342 342 //otherObject->reduceHealth(); 343 } 344 345 bool OrxoBloxBall::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) 346 { 347 orxout() << "detected collision" << endl; 348 Bounce(otherObject); 349 350 return true; 343 351 } 344 352
Note: See TracChangeset
for help on using the changeset viewer.