Advertisement
xXm0dzXx

Untitled

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