[Orxonox-commit 6954] r11575 - code/branches/SOBv2_HS17/src/modules/superorxobros
varxth at orxonox.net
varxth at orxonox.net
Mon Nov 20 15:21:35 CET 2017
Author: varxth
Date: 2017-11-20 15:21:35 +0100 (Mon, 20 Nov 2017)
New Revision: 11575
Modified:
code/branches/SOBv2_HS17/src/modules/superorxobros/SOBFigure.cc
code/branches/SOBv2_HS17/src/modules/superorxobros/SOBFigure.h
code/branches/SOBv2_HS17/src/modules/superorxobros/SOBFireball.cc
code/branches/SOBv2_HS17/src/modules/superorxobros/SOBFireball.h
Log:
merged Fireball and player
Modified: code/branches/SOBv2_HS17/src/modules/superorxobros/SOBFigure.cc
===================================================================
--- code/branches/SOBv2_HS17/src/modules/superorxobros/SOBFigure.cc 2017-11-20 14:15:13 UTC (rev 11574)
+++ code/branches/SOBv2_HS17/src/modules/superorxobros/SOBFigure.cc 2017-11-20 14:21:35 UTC (rev 11575)
@@ -41,6 +41,7 @@
#include "SOBMushroom.h"
#include "SOBGumba.h"
+#include "SOBFireball.h"
#include "SOB.h"
#include "SOBFlagstone.h"
#include "SOBCastlestone.h"
@@ -102,10 +103,11 @@
//Orxocast returns object with casted type if otherObject has that class, and if not a nullptr
- SOBMushroom* mush = orxonox_cast<SOBMushroom*>(otherObject);
- SOBGumba* gumba = orxonox_cast<SOBGumba*>(otherObject);
- SOBFlagstone* flagstone = orxonox_cast<SOBFlagstone*>(otherObject);
- SOBCastlestone* castlestone = orxonox_cast<SOBCastlestone*>(otherObject);
+ SOBMushroom* mush = orxonox_cast<SOBMushroom*> (otherObject);
+ SOBGumba* gumba = orxonox_cast<SOBGumba*> (otherObject);
+ SOBFlagstone* flagstone = orxonox_cast<SOBFlagstone*> (otherObject);
+ SOBCastlestone* castlestone = orxonox_cast<SOBCastlestone*> (otherObject);
+ SOBFireball* fireball = orxonox_cast<SOBFireball*> (otherObject);
//Check if otherObject is a powerup
if (mush != nullptr && !(mush->hasCollided_)) {
@@ -121,6 +123,7 @@
}
+
//Check if otherObject is a Gumba (that walking enemies)
else if (gumba != nullptr && !(gumba->hasCollided_)) {
@@ -129,13 +132,7 @@
if (getVelocity().z >= -20) {
// If player hasn't a power up, he dies. Else he shrinks and the gumba dies.
if(!gotPowerUp_){
- Vector3 vel = getVelocity();
- vel.y = -80;
- vel.z = 200;
- setVelocity(vel);
- predead_=true;
- SOB* SOBGame = orxonox_cast<SOB*>(getGametype());
- SOBGame->setDone(true);
+ this->die();
} else{
gotPowerUp_ = false;
@@ -157,6 +154,10 @@
}
}
+ else if (fireball != nullptr && !(fireball->hasCollided_)){
+ this-> die();
+ }
+
//Purpose is that if player hits the flag, he should walk into the castle at the end of the level. For that we use SOBCastlestone
if (reachedLvlEndState_ == 0 && flagstone != nullptr && !(flagstone->hasCollided_)) {
flagstone->hasCollided_ = true;
@@ -439,4 +440,14 @@
}
}
+void SOBFigure::die(){
+ Vector3 vel = getVelocity();
+ vel.y = -80;
+ vel.z = 200;
+ setVelocity(vel);
+ predead_=true;
+ SOB* SOBGame = orxonox_cast<SOB*>(getGametype());
+ SOBGame->setDone(true);
+}
+
}
\ No newline at end of file
Modified: code/branches/SOBv2_HS17/src/modules/superorxobros/SOBFigure.h
===================================================================
--- code/branches/SOBv2_HS17/src/modules/superorxobros/SOBFigure.h 2017-11-20 14:15:13 UTC (rev 11574)
+++ code/branches/SOBv2_HS17/src/modules/superorxobros/SOBFigure.h 2017-11-20 14:21:35 UTC (rev 11575)
@@ -47,6 +47,7 @@
virtual bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) override;
void changeClothes(std::string& name);
void spawnFireball();
+ void die();
bool dead_;
bool predead_;
Modified: code/branches/SOBv2_HS17/src/modules/superorxobros/SOBFireball.cc
===================================================================
--- code/branches/SOBv2_HS17/src/modules/superorxobros/SOBFireball.cc 2017-11-20 14:15:13 UTC (rev 11574)
+++ code/branches/SOBv2_HS17/src/modules/superorxobros/SOBFireball.cc 2017-11-20 14:21:35 UTC (rev 11575)
@@ -66,9 +66,7 @@
goesRight_ = true;
collDisX_ = 0;
collDisZ_ = 0;
-
- orxout() << "fireball existed" << endl;
-
+ hitCounter_ = 0;
}
@@ -89,6 +87,7 @@
SOBGumba* gumba = orxonox_cast<SOBGumba*>(otherObject);
+
if(gumba!=nullptr && !(gumba->hasCollided_)) //if other object is a Gumba, kill the Gumba and add score and destroy the fireball
{
gumba->destroyLater();
@@ -98,14 +97,15 @@
this->destroyLater();
this->hasCollided_ = true;
}
+
+
//collision with either top or bottom of a block
else if(changeAllowed_ && (abs(collDisX_)<=abs(collDisZ_)))
{
changeAllowed_ = false;
Vector3 velocity = getVelocity();
- orxout() << "before: velocity in z = " << velocity.z << endl;
velocity.z = -velocity.z;
- orxout() << "after: velocity in z = " << velocity.z << endl;
+
setVelocity(velocity);
}
@@ -113,12 +113,11 @@
//collision with the vertical side of a block
else if(changeAllowed_ && (abs(collDisX_)>abs(collDisZ_)))
{
- orxout() << "collision with the vertical side of a block " << endl;
-
changeAllowed_ = false;
goesRight_=!goesRight_;
}
+ hitCounter_++;
return true;
}
@@ -153,9 +152,12 @@
velocity.z -= gravityAcceleration_*dt;
velocity.x = dir*speed_;
velocity.y = 0;
+ if(hitCounter_ >= 3) velocity.y = 50;
setVelocity(velocity);
lastPos_ = getPosition();
+
+ if(abs(this->getPosition().z) > 1000) delete this;
}
Modified: code/branches/SOBv2_HS17/src/modules/superorxobros/SOBFireball.h
===================================================================
--- code/branches/SOBv2_HS17/src/modules/superorxobros/SOBFireball.h 2017-11-20 14:15:13 UTC (rev 11574)
+++ code/branches/SOBv2_HS17/src/modules/superorxobros/SOBFireball.h 2017-11-20 14:21:35 UTC (rev 11575)
@@ -71,6 +71,7 @@
bool changeAllowed_;
float changedOn_;
int hitCounter_;
+
float collDisX_;
More information about the Orxonox-commit
mailing list