Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

Location:
code/branches/Presentation_HS17_merge/src/modules/flappyorx
Files:
2 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    }
  • code/branches/Presentation_HS17_merge/src/modules/flappyorx/FlappyOrxShip.h

    r11758 r11761  
    8888            bool isFlapping;
    8989            bool isDead;
     90            float velocity;
    9091            float speed, upwardThrust, gravity;
    9192            float particleAge, particleLifespan;
    9293            time_t deathTime;
    93             struct Velocity
    94             {
    95                 float x;
    96                 float y;
    97             } velocity;
    9894
    9995    };
Note: See TracChangeset for help on using the changeset viewer.