Changeset 12344 for code/branches/OrxoBlox_FS19/src
- Timestamp:
- May 9, 2019, 11:14:44 AM (6 years ago)
- Location:
- code/branches/OrxoBlox_FS19/src/modules/OrxoBlox
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBlox.cc
r12343 r12344 138 138 this->center_->attach(this->ball_); 139 139 //Startposition Ball 140 this->ball_->setPosition(0, 0, 50);140 this->ball_->setPosition(0, 0, 40); 141 141 this->ball_->setFieldDimension(this->center_->getFieldDimension()); 142 142 this->ball_->setSpeed(0); -
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxBall.cc
r12340 r12344 43 43 #include "sound/WorldSound.h" 44 44 #include "core/XMLPort.h" 45 46 #include "OrxoBloxStones.h"47 45 48 46 namespace orxonox … … 149 147 position.z = this-> fieldHeight_ / 2; 150 148 // Set the velocity to zero 151 this->setSpeed(0); // doesn't work here, why??; 152 //velocity.x = 0; 153 //velocity.y = 0; 154 //velocity.z = 0; 155 orxout() << "Output" << endl; 156 ChatManager::message("Waiting"); 149 150 //this->setSpeed(0); // doesn't work here, why??; 151 //Stopping ball 152 orxout() << "Ball stopped" << endl; 153 velocity.x = 0; 154 velocity.y = 0; 155 velocity.z = 0; 156 157 ChatManager::message("Waiting for your input"); 158 //Input new speed here: 159 ChatManager::message("Setting new speed"); 160 161 //Set new speed here!! 162 velocity.x = rnd(-100,100); 163 velocity.z = rnd(-10,-100); 164 165 166 157 167 } 158 168 if (position.z < -this->fieldHeight_ / 2){ … … 205 215 */ 206 216 void OrxoBloxBall::setSpeed(float speed) 207 { 217 { 218 208 219 if (speed != this->speed_) // If the speed changes 209 220 { 210 221 this->speed_ = speed; 211 212 222 // Set the speed in the direction of the balls current velocity. 213 223 Vector3 velocity = this->getVelocity(); 214 //if (velocity.x != 0) 215 velocity.x = sgn(velocity.x) * this->speed_; 216 //else // If the balls current velocity is zero, the speed is set in a random direction. 217 // velocity.x = this->speed_ * sgn(rnd(-1,1)); 224 if (velocity.x != 0) 225 velocity.x = speed; 226 //velocity.x = sgn(velocity.x) * speed; 227 else // If the balls current velocity is zero, the speed is set in a random direction. 228 velocity.x = speed * sgn(rnd(-1,1)); 218 229 //velocity.y = this->speed_; 219 velocity.z = this->speed_;230 velocity.z = speed; 220 231 221 232 this->setVelocity(velocity); … … 279 290 280 291 Vector3 velocity = this->getVelocity(); 281 Vector3 positionOtherObject= otherObject->getPosition();282 btVector3 myPosition= contactPoint.getPositionWorldOnA();292 Vector3 myPosition = otherObject->getPosition(); 293 btVector3 positionOtherObject = contactPoint.getPositionWorldOnA(); 283 294 orxout() << "About to Bounce >D" << endl; 295 //if (positionOtherObject.y < 0) { 296 //this.destroy() 297 //}S 298 //else { 284 299 285 int distance_X = myPosition.getX() - positionOtherObject.x;286 int distance_Z = myPosition.getZ() - positionOtherObject.z;300 int distance_X = positionOtherObject.getX() - myPosition.x; 301 int distance_Z = positionOtherObject.getZ() - myPosition.z; 287 302 288 303 if (distance_X < 0) … … 319 334 bool result = MovableEntity::collidesAgainst(otherObject, ownCollisionShape, contactPoint); 320 335 Bounce(otherObject, ownCollisionShape, contactPoint); 321 OrxoBloxStones* stone = orxonox_cast<OrxoBloxStones*>(otherObject);322 if(stone != nullptr)323 {324 delete stone;325 }326 336 return result; 327 337 }
Note: See TracChangeset
for help on using the changeset viewer.