Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- % /////////////////////
- % // Michael Yazdani //
- % /////////////////////
- % // ICS 3U ///////////
- % /////////////////////
- setscreen ("graphics:700;700")
- % VARIABLE ANS CONSTANT DECLARATIONS
- var x, y : int
- const inc := 5
- const radius := 25
- var chars : array char of boolean
- % FORWARD DECLARATIONS
- forward procedure moveleft
- % 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 moveleft % sets x to x - inc, if x is less than radius, moveright is called
- loop
- keydown
- exit when chars (KEY_ESC)
- if chars (KEY_UP_ARROW) then
- y := y + inc
- end if
- if chars (KEY_DOWN_ARROW) then
- y := y - inc
- end if
- if chars (KEY_LEFT_ARROW) then
- x := x - inc
- end if
- if chars (KEY_RIGHT_ARROW) then
- x := x + inc
- end if
- if x > maxx - radius then
- x := x - inc
- end if
- if x < radius then
- x := x + inc
- end if
- if y > maxy - radius then
- y := y - inc
- end if
- if y < radius then
- y := y + inc
- 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) or chars (KEY_RIGHT_ARROW) or chars (KEY_UP_ARROW) or chars (KEY_DOWN_ARROW) then
- moveleft
- end if
- end loop
- cls
- put "Program Terminated."
Add Comment
Please, Sign In to add comment