Computer Science Canada Ball bouncing around the screen |
Author: | lufthansa747 [ Tue Dec 01, 2009 8:51 pm ] |
Post subject: | Ball bouncing around the screen |
Here is my program that makes a ball bounce around View.Set ("graphics:max;max,offscreenonly,nobuttonbar") var x : int := maxx div 2 var y : int := maxy div 2 var radius : int := 20 var xint, yint : int := 5 var upState, sideState : int := -1 Draw.FillBox (0, 0, maxx, maxy, black) Draw.FillOval (x, y, radius, radius, white) loop if x - xint <= 0 and sideState = -1 then %Check left wall sideState := 1 end if if x + xint >= maxx and sideState = 1 then % check right wall sideState := -1 end if if y + yint >= maxy and upState = 1 then %check top wall upState := -1 end if if y - yint <= 0 and upState = -1 then % check bottom wall upState := 1 end if Draw.FillOval (x, y, radius, radius, black) x += xint * sideState y += yint * upState Draw.FillOval (x, y, radius, radius, white) View.Update delay (10) end loop |
Author: | Kharybdis [ Tue Dec 01, 2009 9:34 pm ] |
Post subject: | RE:Ball bouncing around the screen |
Congrats. Now try to make a ping pong game |
Author: | apomb [ Wed Dec 02, 2009 8:50 am ] |
Post subject: | Re: Ball bouncing around the screen |
For the love of all things holy, do not make another pong game... PLEASE think of something a little more inspired. |