GLProgramming.com

home :: about :: development guides :: irc :: forums :: search :: paste :: links :: contribute :: code dump

-> Click here to learn how to get live help <-


New Paste :: Recent Pastes:: No Line Numbers


Bounces once :( by Anonymous
1
 
    if (Timing) {
      theTime += (currentTime - lastCurrentTime);
      if (Falling) {
        if (GPE < 0) {
          GPE = 0.0f;
          Falling = false;
          //yea i'll do EPE later
        }
        Velocity += (currentTime - lastCurrentTime) * Gravity;
        Slide -= Velocity;
      } else {
        if (KE < 0) {
          KE = 0.0f;
          Falling = true;
        }
        Velocity -= (currentTime - lastCurrentTime) * Gravity;
        Slide += Velocity;
      }
    }

/*
Problem: Objects only bounce once (i.e. they begin falling, run out of GPE, hit the ground, bounce back up, run out of KE, start falling, pass the ground, keep falling)
GPE = Mass * Velocity * Gravity and KE = (Mass / 2) * Velocity * Velocity
I  have all the stats appear on the right side of the screen, when the object passes the ground, GPE is negative but for some reason:  */
        if (GPE < 0) {
// doesn't seem to work twice :( any help plz :)