hello, I am trying to make a bouncing ball that I want to make it bounce, and every bounce it loses speed(bounces less). This is the bounce code:
x and y are aquired useing getX() and getY() at the beggining, acc is -10, accel is the acceleration after each bounce. My main issue right now is that it bounces too high after each ground hit, and the hit itself is kind of weird. BTW, I think there is an infinite loop somewhere because sometimes it just asks me to terminate the thing.
while(moving) { checkX = getX(); checkY = getY(); speed += acc; setLocation(x, y + (speed)); acc += fric; //x += xAcc; if(xAcc > 0) { xAcc -= fric; } if(checkY > 386) { accel += fric; acc = accel; speed = 0; if(accel == 0) { moving = false; } } Greenfoot.delay(1); }