Guest User

Untitled

a guest
Jan 16th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1. % /////////////////////
  2. % // Michael Yazdani //
  3. % /////////////////////
  4. % // ICS 3U ///////////
  5. % /////////////////////
  6.  
  7. setscreen ("graphics:700;700")
  8.  
  9. % VARIABLE ANS CONSTANT DECLARATIONS
  10.  
  11. var x, y : int
  12. const inc := 5
  13. const radius := 25
  14. var chars : array char of boolean
  15.  
  16. % FORWARD DECLARATIONS
  17. forward procedure moveleft
  18.  
  19.  
  20. % PROCEDURES
  21.  
  22. procedure keydown % determines what keys are being pressed
  23. Input.KeyDown (chars)
  24. end keydown
  25.  
  26. procedure circle % draws a circle at location x and y with radius "radius" then erases for next frame
  27. drawoval (x, y, radius, radius, 1)
  28. delay (16)
  29. drawoval (x, y, radius, radius, white)
  30. end circle
  31.  
  32. body procedure moveleft % sets x to x - inc, if x is less than radius, moveright is called
  33. loop
  34. keydown
  35. exit when chars (KEY_ESC)
  36. if chars (KEY_UP_ARROW) then
  37. y := y + inc
  38. end if
  39. if chars (KEY_DOWN_ARROW) then
  40. y := y - inc
  41. end if
  42. if chars (KEY_LEFT_ARROW) then
  43. x := x - inc
  44. end if
  45. if chars (KEY_RIGHT_ARROW) then
  46. x := x + inc
  47. end if
  48. if x > maxx - radius then
  49. x := x - inc
  50. end if
  51. if x < radius then
  52. x := x + inc
  53. end if
  54. if y > maxy - radius then
  55. y := y - inc
  56. end if
  57. if y < radius then
  58. y := y + inc
  59. end if
  60. circle
  61. end loop
  62. end moveleft
  63.  
  64. % VARIABLE INITILIZATION
  65.  
  66. x := maxx div 2 % initializes x to center of output window
  67. y := maxy div 2 % initializes y to center of output window
  68.  
  69. % MAIN PROGRAM
  70.  
  71. loop
  72. keydown
  73. exit when chars (KEY_ESC) % exits main loop, terminates program
  74. if chars (KEY_LEFT_ARROW) or chars (KEY_RIGHT_ARROW) or chars (KEY_UP_ARROW) or chars (KEY_DOWN_ARROW) then
  75. moveleft
  76. end if
  77. end loop
  78.  
  79. cls
  80. put "Program Terminated."
Add Comment
Please, Sign In to add comment