Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 18, 2017, 1:24:43 PM (7 years ago)
Author:
jkindle
Message:

IMPROVED JUMP ALGORITHM OH GHAD YEES JEES

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBFigure.cc

    r11416 r11418  
    4545#include "SOBFlagstone.h"
    4646#include "SOBCastlestone.h"
     47#include <BulletCollision/NarrowPhaseCollision/btManifoldPoint.h>
    4748
    4849namespace orxonox
     
    6364        moveDownPressed_ = false;
    6465        firePressed_ = false;
    65        
     66        collDisZ_ = 0;
    6667        //Times and turning
    6768        timeSinceLastFire_ = 0.0;
     
    9091    bool SOBFigure::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) {
    9192
     93        //Inform tick fct that player is colliding and tell him how far away the collision point is from player middle point in z dir
    9294        isColliding_ = true;
     95        collDisZ_ = getPosition().z - contactPoint.getPositionWorldOnB().getZ();
     96
    9397
    9498        //Orxocast returns object with casted type if otherObject has that class, and if not a nullptr
     
    116120              setVelocity(vel);
    117121              predead_=true;
     122              SOB* SOBGame = orxonox_cast<SOB*>(getGametype());
     123              SOBGame->setDone(true);
    118124
    119125          } else {
     
    132138        reachedLvlEndState_ = 1;
    133139        SOB* SOBGame = orxonox_cast<SOB*>(getGametype());
     140        SOBGame->setDone(true);
    134141        SOBGame->addPoints(flagstone->getPoints());
     142       
    135143
    136144    }
     
    201209        if (!predead_)
    202210            velocity.y = 0;
     211        //If player falls in a hole
    203212        if (position.z < -100) {
    204213            dead_ = true;
     214            SOB* SOBGame = orxonox_cast<SOB*>(getGametype());
     215            SOBGame->setDone(true);
    205216        }
    206217
     
    233244
    234245
    235         //If player hits space and does not move in z-dir
    236         if (inputAllowed && firePressed_ && isColliding_ && std::abs(velocity.z) < 0.1 && std::abs(lastSpeed_z) < 0.1) {
     246        //If player hits space and collides against an object under him then jump
     247        if (inputAllowed && firePressed_ && isColliding_ && (collDisZ_ >= 7.75 && collDisZ_ <+ 8.25)) {
    237248            gravityAcceleration_ = 100.0;
    238             velocity.z = 110; //150
     249            velocity.z = 110;
    239250        }
    240251
     
    310321
    311322    isColliding_ = false;
     323    collDisZ_ = 0;
    312324
    313325}
Note: See TracChangeset for help on using the changeset viewer.