Advertisement
xXm0dzXx

Untitled

Apr 20th, 2012
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local scroll = 0;
  2. local jump = 0;
  3. local char = ">";
  4. local coins = 0;
  5. local x,y = term.getSize()
  6.  
  7. function newCoin(posX, posY)
  8. term.setCursorPos(posX - scroll, posY + jump)
  9. if not posX - scroll < x then
  10. if(posX - scroll == x/2 and posY + jump == y-10)then
  11. coins = coins+1
  12. else
  13. write("O")
  14. end
  15. end
  16. end
  17.  
  18. function redraw()
  19. term.clear()
  20. term.setCursorPos(1,1)
  21. write("Coins: " ..coins)
  22. term.setCursorPos(x/2, y-10)
  23. write(char)
  24. for i=1,x-1 do
  25. term.setCursorPos(i, y-9 + jump)
  26. write("A")
  27. end
  28.  
  29. newCoin(x/2, y-14)
  30. end
  31.  
  32. while true do
  33. redraw()
  34. local event, a, b = os.pullEvent();
  35. if(event == "char" and a == "a")then
  36. scroll = scroll-1
  37. char = "<"
  38. elseif(event == "char" and a == "d")then
  39. scroll = scroll+1
  40. char = ">"
  41. elseif(event == "key" and a == 57)then
  42. jump = 1
  43. for i=1,4 do
  44. sleep(0.1)
  45. jump = i
  46. redraw()
  47. end
  48. for i=1,4 do
  49. sleep(0.1)
  50. jump = jump-i
  51. redraw()
  52. end
  53. jump = 0
  54. end
  55. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement