Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- % /////////////////////
- % // Michael Yazdani //
- % /////////////////////
- % // ICS 3U ///////////
- % /////////////////////
- setscreen ("graphics:700;700")
- % VARIABLE AND CONSTANT DECLARATIONS
- var x, y : int
- const inc := 8
- const radius := 25
- var chars : array char of boolean
- % FORWARD DECLARATIONS
- forward procedure moveup
- forward procedure movedown
- forward procedure moveleft
- forward procedure moveright
- % PROCEDURES
- procedure keydown % determines what keys are being pressed
- Input.KeyDown (chars)
- end keydown
- procedure circle % draws a circle at location x and y with radius "radius" then erases for next frame
- drawoval (x, y, radius, radius, 1)
- delay (16)
- drawoval (x, y, radius, radius, white)
- end circle
- body procedure moveup % sets y to y + inc (5 pixels), if y is greater than the vertical resolution of the output window - radius, movedown is called
- loop
- keydown
- exit when chars (KEY_LEFT_ARROW) or chars (KEY_RIGHT_ARROW) or chars (KEY_DOWN_ARROW) or chars (KEY_ESC)
- y := y + inc
- if y > maxy - radius then
- movedown
- end if
- circle
- end loop
- end moveup
- body procedure movedown % sets y to y - inc, if y is less than radius (in this case, 25 pixels), moveup is called
- loop
- keydown
- exit when chars (KEY_LEFT_ARROW) or chars (KEY_RIGHT_ARROW) or chars (KEY_UP_ARROW) or chars (KEY_ESC)
- y := y - inc
- if y < radius then
- moveup
- end if
- circle
- end loop
- end movedown
- body procedure moveright % sets x to x + inc, if x is greater than the horizontal resolution of the output window, moveleft is called
- loop
- keydown
- exit when chars (KEY_LEFT_ARROW) or chars (KEY_UP_ARROW) or chars (KEY_DOWN_ARROW) or chars (KEY_ESC)
- x := x + inc
- if x > maxx - radius then
- moveleft
- end if
- circle
- end loop
- end moveright
- body procedure moveleft % sets x to x - inc, if x is less than radius, moveright is called
- loop
- keydown
- exit when chars (KEY_RIGHT_ARROW) or chars (KEY_UP_ARROW) or chars (KEY_DOWN_ARROW) or chars (KEY_ESC)
- x := x - inc
- if x < radius then
- moveright
- end if
- circle
- end loop
- end moveleft
- % VARIABLE INITILIZATION
- x := maxx div 2 % initializes x to center of output window
- y := maxy div 2 % initializes y to center of output window
- % MAIN PROGRAM
- loop
- keydown
- exit when chars (KEY_ESC) % exits main loop, terminates program
- if chars (KEY_LEFT_ARROW) then
- moveleft
- elsif chars (KEY_RIGHT_ARROW) then
- moveright
- elsif chars (KEY_DOWN_ARROW) then
- movedown
- elsif chars (KEY_UP_ARROW) then
- moveup
- end if
- moveup
- end loop
- cls
- put "Program Terminated."
Advertisement
Add Comment
Please, Sign In to add comment