Changeset 12346 for code/branches/OrxoBlox_FS19/src/modules/OrxoBlox
- Timestamp:
- May 9, 2019, 11:36:28 AM (6 years ago)
- Location:
- code/branches/OrxoBlox_FS19/src/modules/OrxoBlox
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBlox.cc
r12345 r12346 147 147 148 148 // Create the first Wall. 149 this-> LevelUp();149 this->createWall(); 150 150 151 151 //Create Ship … … 213 213 this->createWall(); 214 214 this->activeWalls_.push_back(this->futureWall_); 215 for (int i = 0; i < this->futureWall_->getNumberOfStones(); i++) 216 this->stones_.push_back(this->futureWall_->getStone(i)); 215 217 //new location of ship 216 218 //new amount of balls 217 219 //create balls 218 220 //insert new wall 219 220 221 } 221 222 … … 243 244 } 244 245 245 246 OrxoBloxStones* OrxoBlox::CheckForCollision(OrxoBloxBall* Ball) { 247 248 orxout() << "Checking for Collision" << endl; 249 Vector3 BallPosition = Ball->getPosition(); 250 for(OrxoBloxStones* someStone : this->stones_) 251 { 252 orxout() << "Checking a stone" << endl; 253 const Vector3& StonePosition = someStone->getPosition(); //!< Saves the position of the currentStone 254 int size = someStone->getSize(); 255 if((BallPosition.x >= StonePosition.x - size && BallPosition.x <= StonePosition.x + size) || 256 (BallPosition.z >= StonePosition.z - size && BallPosition.z <= StonePosition.z + size)) { 257 orxout() << "FOUND ONE" << endl; 258 return someStone; 259 } 260 } 261 orxout() << "Found nothing...." << endl; 262 return nullptr; 263 } 246 264 247 265 } -
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBlox.h
r12343 r12346 87 87 OrxoBloxCenterpoint* getCenterpoint(void) 88 88 { return this->center_; } 89 OrxoBloxStones* CheckForCollision(OrxoBloxBall* Ball); 89 90 90 91 protected: -
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxBall.cc
r12344 r12346 55 55 */ 56 56 OrxoBloxBall::OrxoBloxBall(Context* context) 57 : MovableEntity(context)57 : Pawn(context) 58 58 { 59 59 RegisterObject(OrxoBloxBall); … … 63 63 this->bDeleteBats_ = false; 64 64 this->relMercyOffset_ = 0.05f; 65 this->orxoblox_ = this->getOrxoBlox(); 65 66 66 67 this->registerVariables(); … … 206 207 if (position != this->getPosition()) 207 208 this->setPosition(position); 209 this->Collides((this->orxoblox_->CheckForCollision(this))); 210 211 208 212 } 209 213 … … 287 291 288 292 289 void OrxoBloxBall::Bounce( WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) {293 void OrxoBloxBall::Bounce(OrxoBloxStones* otherObject) { 290 294 291 295 Vector3 velocity = this->getVelocity(); 292 Vector3 myPosition= otherObject->getPosition();293 btVector3 positionOtherObject = contactPoint.getPositionWorldOnA();296 Vector3 positionOtherObject = otherObject->getPosition(); 297 Vector3 myPosition = this->getPosition(); 294 298 orxout() << "About to Bounce >D" << endl; 295 299 //if (positionOtherObject.y < 0) { … … 298 302 //else { 299 303 300 int distance_X = positionOtherObject.getX() - myPosition.x;301 int distance_Z = positionOtherObject.getZ() - myPosition.z;304 int distance_X = myPosition.x - positionOtherObject.x; 305 int distance_Z = myPosition.z - positionOtherObject.z; 302 306 303 307 if (distance_X < 0) … … 325 329 } 326 330 this->setVelocity(velocity); 327 //} 328 } 329 330 331 bool OrxoBloxBall::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) 332 { 331 } 332 333 334 void OrxoBloxBall::Collides(OrxoBloxStones* otherObject) 335 { 336 337 if(otherObject == nullptr) 338 return; 339 333 340 orxout() << "About to Bounce >D" << endl; 334 bool result = MovableEntity::collidesAgainst(otherObject, ownCollisionShape, contactPoint); 335 Bounce(otherObject, ownCollisionShape, contactPoint); 336 return result; 341 Bounce(otherObject); 342 } 343 344 OrxoBlox* OrxoBloxBall::getOrxoBlox() 345 { 346 if (this->getGametype() != nullptr && this->getGametype()->isA(Class(OrxoBlox))) 347 { 348 OrxoBlox* orxobloxGametype = orxonox_cast<OrxoBlox*>(this->getGametype()); 349 return orxobloxGametype; 350 } 351 else orxout()<<"There is no Gametype for OrxoBlox! ask Anna"<< endl; 352 return nullptr; 337 353 } 338 354 -
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxBall.h
r12337 r12346 40 40 #include "util/Math.h" 41 41 42 #include "worldentities/ MovableEntity.h"42 #include "worldentities/pawns/Pawn.h" 43 43 #include <bullet/BulletCollision/NarrowPhaseCollision/btManifoldPoint.h> 44 44 … … 58 58 @ingroup OrxoBlox 59 59 */ 60 class _OrxoBloxExport OrxoBloxBall : public MovableEntity60 class _OrxoBloxExport OrxoBloxBall : public Pawn 61 61 { 62 62 public: … … 123 123 124 124 125 void Bounce(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint); 126 127 virtual bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) override; 125 void Bounce(OrxoBloxStones* otherObject); 126 void Collides(OrxoBloxStones* otherObject); 128 127 129 128 static const float MAX_REL_Z_VELOCITY; … … 139 138 void registerVariables(); 140 139 140 OrxoBlox* getOrxoBlox(); 141 141 float fieldWidth_; //!< The width of the playing field. 142 142 float fieldHeight_; //!< The height of the playing field. … … 150 150 WorldSound* defBatSound_; 151 151 WorldSound* defBoundarySound_; 152 OrxoBlox* orxoblox_; 152 153 }; 153 154 } -
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxWall.cc
r12341 r12346 89 89 return nullptr; 90 90 } 91 92 int OrxoBloxWall::getNumberOfStones() { 93 return num_Stones_; 94 } 91 95 } -
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxWall.h
r12341 r12346 42 42 void setGame(OrxoBlox* orxoblox) 43 43 { assert(orxoblox); orxoblox_ = orxoblox; } 44 int getNumberOfStones(); 44 45 private: 45 46 void createWall(void);
Note: See TracChangeset
for help on using the changeset viewer.