
-----------------------------------
Maverick
Tue Dec 09, 2003 3:53 pm

Bouncing Ball
-----------------------------------
Here is my bouncing ball program. I know it kinda sucks, but its my first year programming in grade 10 and i suck at it.


%n00bish bouncing ball
setscreen("nocursor")
setscreen("graphics:400;350")
var ballx,bally,ballxdir,ballydir:int
drawfillbox(1,1,400,350,blue)
randint(ballx,0,maxx)
randint(bally,0,maxy)

ballxdir:=1
ballydir:=1

loop 
    drawfilloval(ballx,bally,5,5,12)
    delay(1)
    drawfilloval(ballx,bally,5,5,0)
    
if ballx>maxx and ballxdir>0 then
ballxdir:=-ballxdir
elsif ballx0 then
ballydir:=-ballydir
elsif bally maxx and ballxdir > 0 then
        ballxdir := -ballxdir
    elsif ballx < 0 and ballxdir < 0 then
        ballxdir := -ballxdir
    elsif bally > maxy and ballydir > 0 then
        ballydir := -ballydir
    elsif bally < 0 and ballydir < 0 then
        ballydir := -ballydir
    end if
    ballx += ballxdir
    bally += ballydir
    View.Update
end loop


that code wont leave a trail behind the ball, unless you were going for that...and you can also slow the ball down alot more, by making the variables real instead of int..allowing you to make it as low as .1
