[Orxonox-commit 6790] r11418 - in code/branches/SuperOrxoBros_FS17: data/overlays src/modules/superorxobros
jkindle at orxonox.net
jkindle at orxonox.net
Thu May 18 13:24:46 CEST 2017
Author: jkindle
Date: 2017-05-18 13:24:43 +0200 (Thu, 18 May 2017)
New Revision: 11418
Modified:
code/branches/SuperOrxoBros_FS17/data/overlays/SOBHUD.oxo
code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOB.cc
code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOB.h
code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBFigure.cc
code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBFigure.h
Log:
IMPROVED JUMP ALGORITHM OH GHAD YEES JEES
Modified: code/branches/SuperOrxoBros_FS17/data/overlays/SOBHUD.oxo
===================================================================
--- code/branches/SuperOrxoBros_FS17/data/overlays/SOBHUD.oxo 2017-05-11 14:15:10 UTC (rev 11417)
+++ code/branches/SuperOrxoBros_FS17/data/overlays/SOBHUD.oxo 2017-05-18 11:24:43 UTC (rev 11418)
@@ -79,7 +79,7 @@
<SOBHUDInfo
- position = "0.5,0.5"
+ position = "0.55,0.5"
pickpoint = "0.5, 0.5"
textposition = "0.5, 0.5"
textpickpoint = "0.5, 0.5"
Modified: code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOB.cc
===================================================================
--- code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOB.cc 2017-05-11 14:15:10 UTC (rev 11417)
+++ code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOB.cc 2017-05-18 11:24:43 UTC (rev 11418)
@@ -66,7 +66,7 @@
coins_=0;
points_=0;
timeLeft_=400.0;
-
+ done_ = true;
lvl_ = 1;
}
@@ -143,6 +143,7 @@
{
player->startControl(figure_); //Give the control of the instance player to the real person
players_[player].state_ = PlayerState::Alive;
+ done_ = false;
}
}
@@ -165,7 +166,7 @@
//If player has reached end of level
if (this->figure_ != nullptr && figure_->lvlEnded_) {
std::stringstream a;
- a << "Nice! " << getPoints() << " Points. Press <Space> to restart";
+ a << "Nice! " << getPoints() << " Points in " << (400-getTimeLeft())/2 <<"s.\n\nPress <Space> to restart";
info_ =a.str();
//If player has died
@@ -178,7 +179,8 @@
if (this->figure_ != nullptr && timeLeft_ <= 0)
this->figure_->dead_ = true;
//The time on the HUD
- timeLeft_-=dt*2.5;
+ if (!done_)
+ timeLeft_-=dt*2.5;
}
Modified: code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOB.h
===================================================================
--- code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOB.h 2017-05-11 14:15:10 UTC (rev 11417)
+++ code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOB.h 2017-05-18 11:24:43 UTC (rev 11418)
@@ -83,8 +83,10 @@
}
std::string getInfoText() {
return info_;
+ }
+ void setDone(bool tr) {
+ done_ = tr;
}
-
//Not used yet - placed if somebody wants to develop lvl 1-2 etc
@@ -99,7 +101,6 @@
Gametype::playerEntered(player);
}
-
WeakPtr<SOBCenterpoint> center_;
protected:
@@ -111,7 +112,7 @@
int points_;
int coins_;
float timeLeft_;
-
+ bool done_;
int lvl_;
std::string info_;
Modified: code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBFigure.cc
===================================================================
--- code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBFigure.cc 2017-05-11 14:15:10 UTC (rev 11417)
+++ code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBFigure.cc 2017-05-18 11:24:43 UTC (rev 11418)
@@ -44,6 +44,7 @@
#include "SOB.h"
#include "SOBFlagstone.h"
#include "SOBCastlestone.h"
+#include <BulletCollision/NarrowPhaseCollision/btManifoldPoint.h>
namespace orxonox
{
@@ -62,7 +63,7 @@
moveLeftPressed_ = false;
moveDownPressed_ = false;
firePressed_ = false;
-
+ collDisZ_ = 0;
//Times and turning
timeSinceLastFire_ = 0.0;
lastSpeed_z = 0.0;
@@ -89,8 +90,11 @@
bool SOBFigure::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) {
+ //Inform tick fct that player is colliding and tell him how far away the collision point is from player middle point in z dir
isColliding_ = true;
+ collDisZ_ = getPosition().z - contactPoint.getPositionWorldOnB().getZ();
+
//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);
@@ -115,6 +119,8 @@
vel.z = 200;
setVelocity(vel);
predead_=true;
+ SOB* SOBGame = orxonox_cast<SOB*>(getGametype());
+ SOBGame->setDone(true);
} else {
gumba->destroyLater();
@@ -131,7 +137,9 @@
flagstone->hasCollided_ = true;
reachedLvlEndState_ = 1;
SOB* SOBGame = orxonox_cast<SOB*>(getGametype());
+ SOBGame->setDone(true);
SOBGame->addPoints(flagstone->getPoints());
+
}
if (castlestone != nullptr && !(castlestone->hasCollided_)) {
@@ -200,8 +208,11 @@
if (!predead_)
velocity.y = 0;
+ //If player falls in a hole
if (position.z < -100) {
dead_ = true;
+ SOB* SOBGame = orxonox_cast<SOB*>(getGametype());
+ SOBGame->setDone(true);
}
@@ -232,10 +243,10 @@
particlespawner_->setVisible(false);
- //If player hits space and does not move in z-dir
- if (inputAllowed && firePressed_ && isColliding_ && std::abs(velocity.z) < 0.1 && std::abs(lastSpeed_z) < 0.1) {
+ //If player hits space and collides against an object under him then jump
+ if (inputAllowed && firePressed_ && isColliding_ && (collDisZ_ >= 7.75 && collDisZ_ <+ 8.25)) {
gravityAcceleration_ = 100.0;
- velocity.z = 110; //150
+ velocity.z = 110;
}
@@ -309,6 +320,7 @@
moveRightPressed_ = false;
isColliding_ = false;
+ collDisZ_ = 0;
}
Modified: code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBFigure.h
===================================================================
--- code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBFigure.h 2017-05-11 14:15:10 UTC (rev 11417)
+++ code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBFigure.h 2017-05-18 11:24:43 UTC (rev 11418)
@@ -69,9 +69,9 @@
int sgn(float x);
int reachedLvlEndState_;
float timeCounter_;
+ float collDisZ_;
-
};
More information about the Orxonox-commit
mailing list