Computer Science Canada move a circle |
Author: | Crazya [ Thu Mar 22, 2007 11:49 am ] |
Post subject: | move a circle |
%Aaron Hazley var keys : array char of boolean var x, y,r, xSize, ySize : int r := 10 x := r + 16 y := maxy div 2 + 185 xSize := 5 ySize := 5 colourback (black) cls View.Set ("offscreenonly") loop delay (10) Draw.FillOval (x, y, r, r, black) Input.KeyDown (keys) if keys (KEY_UP_ARROW) and whatdotcolour (x, y + r + 1) ~= brightred and y < maxy - ySize then y := y + 3 end if if keys (KEY_LEFT_ARROW) and whatdotcolour (x - r - 1, y) ~= brightred and x > 0 then x := x - 3 end if if keys (KEY_RIGHT_ARROW) and whatdotcolour (x + r + 1, y) ~= brightred and x < maxx - xSize then x := x + 3 end if if keys (KEY_DOWN_ARROW) and whatdotcolour (x, y - r - 1) ~= brightred and y > ySize then y := y - 3 end if Draw.FillOval (x, y, r, r, brightgreen) View.Update end loop |