yazdmich

moving ball - getch

Oct 12th, 2012
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. var x, x1, y, y1, button : int
  2. const keyleft := chr (203)
  3. const keyright := chr (205)
  4. const keydown := chr (208)
  5. const keyup := chr (200)
  6. const inc := 5
  7. const radius := 25
  8. var chars : string (1)
  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. getch (chars)
  22. drawoval (x, y, radius, radius, white)
  23. if chars = keyleft then
  24. x := x - inc
  25. if x < radius then
  26. x := radius
  27. end if
  28. elsif chars = keyright then
  29. x := x + inc
  30. if x > maxx - radius then
  31. x := maxx - radius
  32. end if
  33. elsif chars = keydown then
  34. y := y - inc
  35. if y < radius then
  36. y := radius
  37. end if
  38. elsif chars = keyup then
  39. y := y + inc
  40. if y > maxy - radius then
  41. y := maxy - radius
  42. end if
  43. end if
  44. %put ""
  45. end if
  46. end loop
Advertisement
Add Comment
Please, Sign In to add comment