Advertisement
xXm0dzXx

Untitled

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