
-----------------------------------
hpdudette
Thu Jun 05, 2003 3:56 pm

bouncing ball??
-----------------------------------
i'm trying to make this ball bounce in diagonally across the screen  but i can't seem to figure out how to make it bounce back or bounce from top to bottom
for x:10..360 
    drawfilloval (x, x, 30, 30, 4)

    delay (5)

    drawfilloval (x, x, 30, 30, 0)
end for


-----------------------------------
PaddyLong
Thu Jun 05, 2003 4:08 pm


-----------------------------------
easiest way to do a bouncing ball around the screen is something like this...


const speed := 5 %the ammount the ball is moved
const radius := 25 %the radius of the ball
var xmove, ymove : int := speed %the amount it moves on the x and y axis
var x, y : int %the ball's x and y coordinates on the screen
var colr : int := 7 %the colour of the ball

%start the ball in the middle of the screen
x := maxx div 2
y := maxy div 2


loop
    %draw the ball, wait a short time, then draw a white one on top of it
    drawfilloval (x, y, radius, radius, colr)
    delay (25)
    drawfilloval (x, y, radius, radius, 0)
    %move the ball's coordinates the respective x and y amounts
    x += xmove
    y += ymove
    if x >= maxx - radius or x = maxy - radius or y 