Thanks,
the code is OK. On the phone the movements of the ball are really fluid. I think I'll stick with my Nokia emulator and try it on the phone from time to time to see what's the real result...
anyway...
Code:
private int calcY(){
Yseconds = (System.currentTimeMillis()-this.startTime)/1000.00;
if (!bounce){
SPEED_Y = ACCELERATION*Yseconds;
if (y>(this.getHeight()-this.ballSprite.getHeight())) {
bounce=true;
this.startTime = System.currentTimeMillis();
B_SPEED_Y = SPEED_Y*0.80;
}
y =top + ((ACCELERATION/2)*(Yseconds*Yseconds));
} else {
//distance = initial velocity * time + acceleration * time^2 / 2
y = bottom - (SPEED_Y*Yseconds) - ((ACCELERATION/2) * (Yseconds*Yseconds));
SPEED_Y = B_SPEED_Y - ACCELERATION*Yseconds;
//System.out.println(SPEED_Y+" "+Yseconds+" "+y);
if (SPEED_Y<=0) {
bounce = false;
top=y;
this.startTime = System.currentTimeMillis();
}
}
return (int)y;
}