Thanks , Chennes and Peverbian!

(I forgot my pw, so have to post a new)
Thank you so much for your reply, Chennes and Peverbian!

Peverbian, I tried your suggestion, Yes it works!!

And also I find my problem comes from the abs function

if I change it to
if(x>1.5 | | x<-1.5 | | y>1.5 | | y<-1.5)…

instead of
if(abs(x)>1.5 | | abs(y)>1.5)

It also works, the ball won’t go beyond the rectangle border.

I think abs return a integer instead of a float–which I thought it should be.

Anyway thank you so much

that’s why there’s a function called fabs()…

fabs can’t work either

Originally posted by Michael Steinberg:
that’s why there’s a function called fabs()…