Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 11418


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

IMPROVED JUMP ALGORITHM OH GHAD YEES JEES

Location:
code/branches/SuperOrxoBros_FS17
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • code/branches/SuperOrxoBros_FS17/data/overlays/SOBHUD.oxo

    r11412 r11418  
    8080
    8181    <SOBHUDInfo
    82      position = "0.5,0.5"
     82     position = "0.55,0.5"
    8383     pickpoint = "0.5, 0.5"
    8484     textposition  = "0.5, 0.5"
  • code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOB.cc

    r11416 r11418  
    6767        points_=0;
    6868        timeLeft_=400.0;
    69        
     69        done_ = true;
    7070        lvl_ = 1;
    7171
     
    144144            player->startControl(figure_); //Give the control of the instance player to the real person
    145145            players_[player].state_ = PlayerState::Alive;
     146            done_ = false;
    146147        }
    147148    }
     
    166167        if (this->figure_ != nullptr && figure_->lvlEnded_) {
    167168            std::stringstream a;
    168             a << "Nice! " << getPoints() << " Points. Press <Space> to restart";
     169            a << "Nice! " << getPoints() << " Points in " << (400-getTimeLeft())/2 <<"s.\n\nPress <Space> to restart";
    169170            info_ =a.str();
    170171
     
    179180            this->figure_->dead_ = true;
    180181        //The time on the HUD
    181         timeLeft_-=dt*2.5;
     182        if (!done_)
     183            timeLeft_-=dt*2.5;
    182184    }
    183185
  • code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOB.h

    r11416 r11418  
    8484            std::string getInfoText() {
    8585                return info_;
     86            }   
     87            void setDone(bool tr) {
     88                done_ = tr;
    8689            }
    87            
    8890
    8991
     
    100102            } 
    101103
    102 
    103104            WeakPtr<SOBCenterpoint> center_;
    104105
     
    112113            int coins_;
    113114            float timeLeft_;
    114 
     115            bool done_;
    115116            int lvl_;
    116117            std::string info_;
  • 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}
  • code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBFigure.h

    r11416 r11418  
    7070            int reachedLvlEndState_;
    7171            float timeCounter_;
    72 
     72            float collDisZ_;
    7373
    7474
Note: See TracChangeset for help on using the changeset viewer.