yazdmich

move ball

Oct 12th, 2012
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. var x, x1, y, y1, button : int
  2. const radius := 25
  3. const inc := 5
  4. var chars : array char of boolean
  5.  
  6. procedure keydown
  7. Input.KeyDown (chars)
  8. end keydown
  9.  
  10. x := radius
  11. y := radius
  12. setscreen ("graphics800:800")
  13. loop
  14. Mouse.Where (x1, y1, button)
  15. drawoval (x, y, radius, radius, 1)
  16. if button = 1 then
  17. Mouse.Where (x, y, button)
  18. drawoval (x, y, radius, radius, 1)
  19. elsif button = 0 then
  20. drawoval (x, y, radius, radius, 1)
  21. keydown
  22. delay (10)
  23. drawoval (x, y, radius, radius, white)
  24. if chars (KEY_LEFT_ARROW) then
  25. x := x - inc
  26. if x < radius then
  27. x := radius
  28. end if
  29. end if
  30. if chars (KEY_RIGHT_ARROW) then
  31. x := x + inc
  32. if x > maxx - radius then
  33. x := maxx - radius
  34. end if
  35. end if
  36. if chars (KEY_DOWN_ARROW) then
  37. y := y - inc
  38. if y < radius then
  39. y := radius
  40. end if
  41. end if
  42. if chars (KEY_UP_ARROW) then
  43. y := y + inc
  44. if y > maxy - radius then
  45. y := maxy - radius
  46. end if
  47. end if
  48. %put ""
  49. end if
  50. end loop
Advertisement
Add Comment
Please, Sign In to add comment