[Orxonox-commit 7035] r11654 - code/branches/SOBv2_HS17/src/modules/superorxobros
varxth at orxonox.net
varxth at orxonox.net
Mon Dec 11 15:17:02 CET 2017
Author: varxth
Date: 2017-12-11 15:17:02 +0100 (Mon, 11 Dec 2017)
New Revision: 11654
Modified:
code/branches/SOBv2_HS17/src/modules/superorxobros/SOBGumba.cc
code/branches/SOBv2_HS17/src/modules/superorxobros/SOBGumba.h
code/branches/SOBv2_HS17/src/modules/superorxobros/SOBGumbaBoss.cc
Log:
better than evverevver
Modified: code/branches/SOBv2_HS17/src/modules/superorxobros/SOBGumba.cc
===================================================================
--- code/branches/SOBv2_HS17/src/modules/superorxobros/SOBGumba.cc 2017-12-11 14:03:56 UTC (rev 11653)
+++ code/branches/SOBv2_HS17/src/modules/superorxobros/SOBGumba.cc 2017-12-11 14:17:02 UTC (rev 11654)
@@ -105,6 +105,12 @@
}
}
+ void SOBGumba::die(){
+ Vector3 velocity = this->getVelocity();
+ velocity.y = speed_;
+ this->setVelocity(velocity);
+ }
+
void SOBGumba::tick(float dt)
{
SUPER(SOBGumba, tick, dt);
@@ -140,9 +146,11 @@
lifetime_ += dt;
if(lifetime_>maxLifetime_)
{
- this->destroyLater();
+
}
}
+ if(abs(this->getPosition().z) > 1000) delete this;
+
}
}
Modified: code/branches/SOBv2_HS17/src/modules/superorxobros/SOBGumba.h
===================================================================
--- code/branches/SOBv2_HS17/src/modules/superorxobros/SOBGumba.h 2017-12-11 14:03:56 UTC (rev 11653)
+++ code/branches/SOBv2_HS17/src/modules/superorxobros/SOBGumba.h 2017-12-11 14:17:02 UTC (rev 11654)
@@ -51,6 +51,7 @@
virtual void tick(float dt) override;
void setDirection(const bool direction);
+ void die();
bool attachedToFigure_;
Modified: code/branches/SOBv2_HS17/src/modules/superorxobros/SOBGumbaBoss.cc
===================================================================
--- code/branches/SOBv2_HS17/src/modules/superorxobros/SOBGumbaBoss.cc 2017-12-11 14:03:56 UTC (rev 11653)
+++ code/branches/SOBv2_HS17/src/modules/superorxobros/SOBGumbaBoss.cc 2017-12-11 14:17:02 UTC (rev 11654)
@@ -53,23 +53,24 @@
{
RegisterObject(SOBGumbaBoss);
- gumbaMaxTime_ = 1;
- gumbaTime_ = 0;
- maxGumbas_ = 10; //Max Gumbas spawnable by a Boss
- jumpTime_ = 0;
- jumpTimeMax_ = 5;
+ gumbaMaxTime_ = 1; // time after which a Gumba is shot
+ gumbaTime_ = 0; // time since last gumba was shot
+ maxGumbas_ = 50; // Max Gumbas spawnable by a Boss
+ jumpTimeMax_ = 5; // time after which the gumba boss jumps
+ jumpTime_ = 0; // time since last jump of gumba boss
}
-
+ // PRE: otherObject collides with this.
+ // POST: collision is handled: velocity changed, small gumbas murdered
bool SOBGumbaBoss::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) {
SOBGumba* gumba = orxonox_cast<SOBGumba*>(otherObject);
SOBGumbaBoss* gumbaBoss = orxonox_cast<SOBGumbaBoss*>(otherObject);
+ // if boss collides with small gumbas, destroy them.
if (gumba != nullptr && gumbaBoss == nullptr && !(gumba->hasCollided_)) {
- gumba->destroyLater();
- gumba->hasCollided_ = true;
+ gumba->die();
}
@@ -84,13 +85,21 @@
-
+ // POST: done what was to do in a time dt
void SOBGumbaBoss::tick(float dt)
{
SUPER(SOBGumbaBoss, tick, dt);
+
+ // increase timers:
gumbaTime_ += dt;
jumpTime_ += dt;
+ // set y-component of position of gumba boss to 0, so he doesn't fall in to the nothing
+ Vector3 position = getPosition();
+ position.y = 0;
+ setPosition(position);
+
+
if (!changeAllowed_) {
changedOn_+= dt;
// After a collision, we don't listen for collisions for 200ms - that's because one wall can cause several collisions!
@@ -124,15 +133,21 @@
if (!goesRight_)
dir = -1;
- Vector3 velocity = getVelocity(); //Jump
- if(jumpTime_ > jumpTimeMax_){
+ //
+ if(getPosition().x < 1640)
+ dir = 1;
+ else if (getPosition().x > 1750)
+ dir = -1;
+
+ //change velocity
+ Vector3 velocity = getVelocity();
+ if(jumpTime_ > jumpTimeMax_){ // jump if the time has come.
velocity.z = speed_*15;
jumpTime_ = 0;
}
- else{ //Gravity
+ else{
velocity.z -= gravityAcceleration_*dt;
}
-
velocity.x = dir*speed_;
setVelocity(velocity);
@@ -139,14 +154,16 @@
lastPos_ = getPosition();
}
+
+ // spawn gumbas
void SOBGumbaBoss::spawnGumba() {
SOBCenterpoint* center_ = ((SOB*)getGametype())->center_;
SOBGumba* gumba = new SOBGumba(center_->getContext());
Vector3 spawnpos = this->getWorldPosition();
- spawnpos.z += 0;
gumba->creator_=this;
+ // we can shoot a gumba!
if (gumba != nullptr && center_ != nullptr)
{
gumba->addTemplate("gumbaShootable");
More information about the Orxonox-commit
mailing list