Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Feb 18, 2018, 12:50:22 AM (6 years ago)
Author:
landauf
Message:

[FlappyOrx_HS17] bugfix: velocity was never initialized (expecially x, which wasn't necessary anyway)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/Presentation_HS17_merge/src/modules/flappyorx/FlappyOrxShip.cc

    r11759 r11761  
    5151        isFlapping = false;
    5252        isDead = true;
     53        velocity = 0;
    5354        speed = 0;
    5455        upwardThrust = 0;
     
    107108
    108109            if(not isDead){
    109                 velocity.y += gravity*dt;
     110                velocity += gravity*dt;
    110111                if(isFlapping){
    111112                    isFlapping = false;
    112113                    if(pos.z > -150)
    113                         velocity.y = -upwardThrust;
     114                        velocity = -upwardThrust;
    114115                }
    115116
    116                 pos += Vector3(speed + velocity.x, 0, velocity.y) * dt;
     117                pos += Vector3(speed, 0, velocity) * dt;
    117118            }
    118119           
     
    129130           
    130131            setPosition(pos);
    131             setOrientation(Vector3::UNIT_Y, Degree(270-velocity.y/10));
     132            setOrientation(Vector3::UNIT_Y, Degree(270-velocity/10));
    132133
    133134            if(pos.z > 150){
     
    176177        pos.z = 0;
    177178        pos.y = 0;
    178         velocity.y = 0;
     179        velocity = 0;
    179180        setPosition(pos);
    180181    }
Note: See TracChangeset for help on using the changeset viewer.