Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --GoDeeper by Konlab
- ver = "1.0"
- prev = 5
- cur = 5
- next = 5
- pos = 5
- function set(xtt)
- term.setCursorPos(xtt,9)
- term.setBackgroundColor(colors.black)
- term.write("o")
- end
- function go()
- prev = cur
- cur = next
- next = math.random(2,25)
- level(prev,1)
- level(cur,2)
- level(next,3)
- end
- function level(xto,n)--n==1 -> old n==2 -> current n==3 -> next
- --if n == 1 then
- -- n=5
- if n > 4 then
- error("n>4")
- end
- yto = n * 5
- term.setBackgroundColor(colors.brown)
- term.setCursorPos(1,yto)
- term.setBackgroundColor(colors.lightGray)
- term.setCursorPos(xto,yto)
- term.write(" ")
- end
- function keyy()
- evvv = "char"
- chh = "a"
- evvv,chh = os.pullEvent("char")
- -- chh = read()
- if chh == "a" then
- pos = pos - 1
- elseif chh == "d" then
- pos = pos + 1
- end
- end
- function game()
- term.setBackgroundColor(colors.lightGray)
- term.clear()
- term.setCursorPos(1,1)
- while true do
- if cur == pos then
- go()
- end
- keyy()
- set()
- end
- -- print("press any key")
- os.pullEvent("key")
- end
- function drawMenu()
- term.setBackgroundColor(colors.brown)
- term.clear()
- term.setCursorPos(1,1)
- term.setBackgroundColor(colors.green)
- term.write("Go Deeper game by Konlab ")
- term.setCursorPos(1,2)
- print(" ")
- print()
- term.setBackgroundColor(colors.cyan)
- print("Begin game ")
- print()
- print("Contrlos&Credits ")
- print()
- print("Exit game ")
- end
- function credits()
- term.clear()
- term.setCursorPos(1,1)
- print("GoDeeper - Controls")
- print("A;D - go left/right")
- print()
- print("GoDeeper - Credits")
- print("GoDeeper was created by Konlab")
- print("Current version: "..ver)
- print("Click to continue")
- os.pullEvent("mouse_click")
- end
- function main()
- while true do
- drawMenu()
- event,button,x,y = os.pullEvent("mouse_click")
- if y == 8 then
- return
- elseif y == 6 then
- credits()
- elseif y == 4 then
- game()
- end
- end
- end
- ok,err = pcall(main)
- if err == "Terminated" then
- print("Terminated")
- return
- end
- if ok then
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- term.clear()
- term.setCursorPos(1,1)
- print("Thanks for using GoDeeper by Konlab")
- return
- else
- term.setBackgroundColor(colors.black)
- term.clear()
- term.setCursorPos(1,1)
- print("Crashed:"..err)
- end
Advertisement
Add Comment
Please, Sign In to add comment