Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local scroll = 0;
- local jump = 0;
- local char = ">";
- local coins = 0;
- local x,y = term.getSize()
- local level = 1;
- function newCoin(posX, posY)
- term.setCursorPos(posX - scroll, posY + jump)
- coin = "O";
- if posX - scroll ~= x-1 then --
- if(posX - scroll == x/2 and posY + jump == y-10)then
- coins = coins+1
- coin = ""
- else
- write(coin)
- end
- end
- end
- function floor(param1)
- for i=1,x-1 do
- term.setCursorPos(i, y-9 + jump)
- write(param1)
- end
- end
- function world()
- if(level == 1)then
- floor("A")
- for i = 1,5 do
- newCoin(x/2-i, y-14)
- end
- end
- end
- function redraw()
- term.clear()
- term.setCursorPos(1,1)
- write("Coins: " ..coins.. " World: 0-" ..level)
- term.setCursorPos(x/2, y-10)
- write(char)
- world()
- end
- while true do
- redraw()
- local event, a, b = os.pullEvent();
- if(event == "char" and a == "a")then
- scroll = scroll-1
- char = "<"
- elseif(event == "char" and a == "d")then
- scroll = scroll+1
- char = ">"
- elseif(event == "key" and a == 57)then
- jump = 1
- for i=1,4 do
- sleep(0.1)
- jump = i
- redraw()
- end
- for i=1,4 do
- sleep(0.1)
- jump = jump-i
- redraw()
- end
- jump = 0
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement