Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 4, 2017, 3:17:59 PM (7 years ago)
Author:
jkindle
Message:

Fixed turning, added and finished Gumbas, added turnOnCollide for all NPC and items, added Flagstone - todo: add points on flagstone hit and go into a between lvl mode, then warp to lvl 2. AAH, and added onDeath fcts…

File:
1 edited

Legend:

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

    r11405 r11412  
    4141
    4242#include "SOBMushroom.h"
     43#include "SOBGumba.h"
    4344#include "SOB.h"
     45#include "SOBFlagstone.h"
    4446
    4547namespace orxonox
     
    6668        pitch_ = 0.0;
    6769
     70        predead_ = false;
    6871        dead_ = false;
    6972        gotPowerUp_ = false;
     
    7982        isColliding_ = true;
    8083        SOBMushroom* mush = orxonox_cast<SOBMushroom*>(otherObject);
    81         // ADD ANOTHER OBJECT FOR BAD GUMBAS AND REMOVE POWERUP OR KILL PLAYER ON COLLISION WITHOUT Z-ACCELERATION
     84        SOBGumba* gumba = orxonox_cast<SOBGumba*>(otherObject);
     85        SOBFlagstone* flagstone = orxonox_cast<SOBFlagstone*>(otherObject);
     86
    8287        if (mush != nullptr && !(mush->hasCollided_)) {
    8388            otherObject->destroyLater();
     
    8792            mush->hasCollided_ = true;
    8893
    89         }
    90 
    91         return true;
    92     }
    93 
    94 
    95 
    96     void SOBFigure::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    97     {
    98         SUPER(SOBFigure, XMLPort, xmlelement, mode);
    99 
    100     }
    101 
    102 
    103 
    104     void SOBFigure::tick(float dt)
    105     {
    106         SUPER(SOBFigure, tick, dt);
    107 
    108         if (particlespawner_ == NULL) {
    109             for (WorldEntity* object : this->getAttachedObjects())
    110             {
    111                if (object->isA(Class(ParticleSpawner)))
    112                 particlespawner_ = object;
    113 
    114         }
    115 
    116     }
    117 
    118 
    119 
    120 
    121 
    122 
    123     if (firePressed_ == false) {
    124        gravityAcceleration_ = 350.0;
    125 
    126    }
    127 
    128    if (hasLocalController())
    129    {
    130       Vector3 velocity = getVelocity();
    131       Vector3 position = getPosition();
    132 
    133 
    134       if (position.z < -100)
    135         dead_ = true;
    136 
    137     if (dead_) {
    138         velocity.x = 0;
    139         velocity.z = 0;
    140         setVelocity(velocity);
    141         return;
    142     }
    143 
    144 
    145     int maxvelocity_x = 100;
    146     int speedAddedPerTick = 5;
    147     int camMaxOffset = 25;
    148 
    149     timeSinceLastFire_ += dt;
    150     lastSpeed_z = velocity.z;
     94        } else if (gumba != nullptr && !(gumba->hasCollided_)) {
     95
     96            if (getVelocity().z >= -20) {
     97              Vector3 vel = getVelocity();
     98              vel.y = -80;
     99              vel.z = 200;
     100              setVelocity(vel);
     101              predead_=true;
     102          } else {
     103            gumba->destroyLater();
     104            gumba->hasCollided_ = true;
     105            SOB* SOBGame = orxonox_cast<SOB*>(getGametype());
     106            SOBGame->addGumba();
     107
     108
     109        }
     110    }
     111
     112     if (flagstone != nullptr && !(flagstone->hasCollided_)) {
     113            flagstone->hasCollided_ = true;
     114
     115     }
     116
     117    return true;
     118}
     119
     120
     121
     122void SOBFigure::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     123{
     124    SUPER(SOBFigure, XMLPort, xmlelement, mode);
     125
     126}
     127
     128
     129int SOBFigure::sgn(float x) {
     130
     131    if (x < 0.0) return -1;
     132    return 1;
     133}
     134
     135void SOBFigure::tick(float dt)
     136{
     137    SUPER(SOBFigure, tick, dt);
     138
     139    if (particlespawner_ == NULL) {
     140        for (WorldEntity* object : this->getAttachedObjects())
     141        {
     142         if (object->isA(Class(ParticleSpawner)))
     143            particlespawner_ = object;
     144
     145    }
     146
     147}
     148
     149
     150
     151
     152
     153
     154if (firePressed_ == false) {
     155 gravityAcceleration_ = 350.0;
     156
     157}
     158
     159if (hasLocalController())
     160{
     161  Vector3 velocity = getVelocity();
     162  Vector3 position = getPosition();
     163
     164  if (!predead_)
     165    velocity.y = 0;
     166if (position.z < -100) {
     167    dead_ = true;
     168
     169}
     170
     171if (dead_) {
     172    velocity.x = 0;
     173    velocity.z = 0;
     174    setVelocity(velocity);
     175    SOB* SOBGame = orxonox_cast<SOB*>(getGametype());
     176    if (firePressed_)
     177        SOBGame->restart();
     178    return;
     179}
     180
     181
     182int maxvelocity_x = 100;
     183int speedAddedPerTick = 5;
     184int camMaxOffset = 25;
     185
     186timeSinceLastFire_ += dt;
     187lastSpeed_z = velocity.z;
    151188
    152189
    153190
    154191        //Handle the rocket fire from the jetpack
    155     if (velocity.z > 40)
    156         particlespawner_->setVisible(true);
    157     else
    158         particlespawner_->setVisible(false);
     192if (velocity.z > 40)
     193    particlespawner_->setVisible(true);
     194else
     195    particlespawner_->setVisible(false);
    159196
    160197        //If player hits space and does not move in z-dir
    161     if (firePressed_ && isColliding_ && std::abs(velocity.z) < 0.1 && std::abs(lastSpeed_z) < 0.1) {
    162         gravityAcceleration_ = 100.0;
     198if (firePressed_ && isColliding_ && std::abs(velocity.z) < 0.1 && std::abs(lastSpeed_z) < 0.1) {
     199    gravityAcceleration_ = 100.0;
    163200            velocity.z = 110; //150
    164201        }
     
    169206        //Left-right movement with acceleration
    170207        float rot = getOrientation().getRoll().valueDegrees();
     208        orxout() << rot << endl;
    171209        if (moveRightPressed_) {
    172             if (rot < 0.0)
    173                 setOrientation(Vector3::UNIT_Z, getOrientation().getRoll() + dt*Radian(6));
     210            if (!(rot < 5.0 && -5.0 < rot))
     211                setOrientation(Vector3::UNIT_Z, getOrientation().getRoll() - sgn(rot)*dt*Radian(6));
     212
    174213
    175214            if (std::abs(velocity.x) < maxvelocity_x) {
    176215                velocity.x += speedAddedPerTick;
    177216
    178                
    179 
    180                
    181 
    182                 // if (pitch_ > 0.0) {
    183                 //     pitch -= turn_fac*dt);
    184                 // }
    185217            }
    186218        } else if (moveLeftPressed_) {
    187             if (rot >= 0.0)
    188                 setOrientation(Vector3::UNIT_Z, getOrientation().getRoll() + dt*Radian(6));
     219            if (!(abs(rot) > 175.0 ))
     220                setOrientation(Vector3::UNIT_Z, getOrientation().getRoll() + sgn(rot)*dt*Radian(6));
     221
     222
    189223
    190224            if (std::abs(velocity.x) < maxvelocity_x) {
Note: See TracChangeset for help on using the changeset viewer.