[Orxonox-commit 7764] r12356 - code/branches/OrxoBlox_FS19/src/modules/OrxoBlox
pomselj at orxonox.net
pomselj at orxonox.net
Thu May 9 14:20:33 CEST 2019
Author: pomselj
Date: 2019-05-09 14:20:32 +0200 (Thu, 09 May 2019)
New Revision: 12356
Modified:
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxBall.cc
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxBall.h
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxStones.cc
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxStones.h
Log:
Bounces ok-ish, still seg fault... stones get destroyed but models stay, maybe destroy wals too
Modified: code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxBall.cc
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxBall.cc 2019-05-09 12:15:32 UTC (rev 12355)
+++ code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxBall.cc 2019-05-09 12:20:32 UTC (rev 12356)
@@ -32,6 +32,7 @@
*/
#include "OrxoBloxBall.h"
+#include "OrxoBloxStones.h"
#include "OrxoBlox.h"
#include <bullet/BulletCollision/NarrowPhaseCollision/btManifoldPoint.h>
@@ -294,10 +295,10 @@
}
- void OrxoBloxBall::Bounce(OrxoBloxStones* otherObject) {
+ void OrxoBloxBall::Bounce(OrxoBloxStones* Stone) {
Vector3 velocity = this->getVelocity();
- Vector3 positionOtherObject = otherObject->getPosition();
+ Vector3 positionStone = Stone->getPosition();
Vector3 myPosition = this->getPosition();
orxout() << "About to Bounce >D" << endl;
//if (positionOtherObject.y < 0) {
@@ -305,8 +306,8 @@
//}S
//else {
- int distance_X = myPosition.x - positionOtherObject.x;
- int distance_Z = myPosition.z - positionOtherObject.z;
+ int distance_X = myPosition.x - positionStone.x;
+ int distance_Z = myPosition.z - positionStone.z;
if (distance_X < 0)
distance_X = -distance_X;
@@ -335,14 +336,18 @@
}
- void OrxoBloxBall::Collides(OrxoBloxStones* otherObject)
+ void OrxoBloxBall::Collides(OrxoBloxStones* Stone)
{
- if(otherObject == nullptr)
+ if(Stone == nullptr)
return;
orxout() << "About to Bounce >D" << endl;
- Bounce(otherObject);
+ Bounce(Stone);
+ //if(otherObject->getHealth() <= 0) {
+ Stone->destroy();
+ //}
+ //otherObject->reduceHealth();
}
OrxoBlox* OrxoBloxBall::getOrxoBlox()
Modified: code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxBall.h
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxBall.h 2019-05-09 12:15:32 UTC (rev 12355)
+++ code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxBall.h 2019-05-09 12:20:32 UTC (rev 12356)
@@ -134,6 +134,8 @@
void setDefBoundarySound(const std::string& engineSound);
const std::string& getDefBoundarySound();
+ unsigned int getHealth();
+
private:
void registerVariables();
@@ -150,7 +152,6 @@
WorldSound* defBatSound_;
WorldSound* defBoundarySound_;
OrxoBlox* orxoblox_;
-
};
}
Modified: code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxStones.cc
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxStones.cc 2019-05-09 12:15:32 UTC (rev 12355)
+++ code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxStones.cc 2019-05-09 12:20:32 UTC (rev 12356)
@@ -20,4 +20,12 @@
this->health_ = 1 + static_cast<unsigned int>(rnd(6.0f)); //<! random number between 0 and 7;
this->delay_ = false;
}
+
+ unsigned int OrxoBloxStones::getHealth() {
+ return this->health_;
+ }
+
+ void OrxoBloxStones::reduceHealth() {
+ this->health_ -= 1;
+ }
}
\ No newline at end of file
Modified: code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxStones.h
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxStones.h 2019-05-09 12:15:32 UTC (rev 12355)
+++ code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxStones.h 2019-05-09 12:20:32 UTC (rev 12356)
@@ -62,6 +62,10 @@
void setGame(OrxoBlox* orxoblox)
{ assert(orxoblox); orxoblox_ = orxoblox; }
+
+ unsigned int getHealth();
+
+ void reduceHealth();
private:
float size_; //!< The dimensions a stone has in the game world.
More information about the Orxonox-commit
mailing list