Advertisement
xXm0dzXx

Untitled

Apr 21st, 2012
94
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. 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 floor(param1)
  22. for i=1,x-1 do
  23. term.setCursorPos(i, y-9 + jump)
  24. write(param1)
  25. end
  26. end
  27.  
  28. function world()
  29. if(level == 1)then
  30. floor("A")
  31. for i = 1,5 do
  32. newCoin(x/2-i, y-14)
  33. end
  34. end
  35. end
  36.  
  37. function redraw()
  38. term.clear()
  39. term.setCursorPos(1,1)
  40. write("Coins: " ..coins.. " World: 0-" ..level)
  41. term.setCursorPos(x/2, y-10)
  42. write(char)
  43.  
  44. world()
  45. end
  46.  
  47. while true do
  48. redraw()
  49. local event, a, b = os.pullEvent();
  50. if(event == "char" and a == "a")then
  51. scroll = scroll-1
  52. char = "<"
  53. elseif(event == "char" and a == "d")then
  54. scroll = scroll+1
  55. char = ">"
  56. elseif(event == "key" and a == 57)then
  57. jump = 1
  58. for i=1,4 do
  59. sleep(0.1)
  60. jump = i
  61. redraw()
  62. end
  63. for i=1,4 do
  64. sleep(0.1)
  65. jump = jump-i
  66. redraw()
  67. end
  68. jump = 0
  69. end
  70. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement