Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ver = "beta 1.0 build 04"
- aF = true
- betatesting = true
- function drawMenu()
- term.setCursorPos(1,1)
- term.setBackgroundColor(colors.lightBlue)
- term.setTextColor(colors.green)
- term.clear()
- term.setBackgroundColor(colors.white)
- term.write("FlappyPixel game by Konlab")
- print(" ")
- print(" ")
- print()
- print("Begin game ")
- print()
- print("Controls ")
- print()
- print("Exit game ")
- if betatesting then
- term.setBackgroundColor(colors.lightBlue)
- term.setCursorPos(1,20)
- term.write("Beta testing")
- end
- term.setBackgroundColor(colors.lightBlue)
- end
- hmD = 0
- q = math.random(3,18)
- w = math.random(3,18)
- e = math.random(3,18)
- qp = 28
- wp = 38
- ep = 45
- --pp = 10
- function kpress()
- while true do
- event2,char2 = os.pullEvent("char")
- -- print(event2..char2)
- if char2 == "w" then
- hmD = 0
- ppos = ppos-3
- end
- end
- end
- function gener()
- term.clear()
- if qp == 1 then
- q = math.random(3,18)
- qp = 28
- end
- if wp == 1 then
- w = math.random(3,18)
- wp = 28
- end
- if ep == 1 then
- e = math.random(3,18)
- ep = 28
- end
- qp = qp - 1
- wp = wp-1
- ep = ep - 1
- term.setBackgroundColor(colors.brown)
- for j = 1,3 do
- for i=1,26 do
- if j == 1 then
- term.setCursorPos(qp,i)
- term.write(" ")
- elseif j == 2 then
- term.setCursorPos(wp,i)
- term.write(" ")
- elseif j == 3 then
- term.setCursorPos(ep,i)
- term.write(" ")
- end
- end
- end
- term.setBackgroundColor(colors.blue)
- for j=1,3 do
- for i=-2,0,1 do
- if j==1 then
- term.setCursorPos(qp,q+i)
- term.write(" ")
- elseif j == 2 then
- term.setCursorPos(wp,w+i)
- term.write(" ")
- elseif j == 3 then
- term.setCursorPos(ep,e+i)
- term.write(" ")
- end
- end
- end
- end
- function game()
- parallel.waitForAny(game2,kpress)
- end
- function lose(text)
- sleep(2)
- term.setBackgroundColor(colors.lightBlue)
- term.setTextColor(colors.yellow)
- term.setCursorPos(1,5)
- term.clear()
- print(text)
- sleep(1)
- term.setCursorPos(1,7)
- print("Click to continue")
- qp = 28
- wp = 38
- ep = 45
- os.pullEvent("mouse_click")
- return
- end
- function game2()
- term.setBackgroundColor(colors.blue)
- term.clear()
- function simu()
- ppos = 10
- while true do
- -- gener()
- -- goup()
- --ppos = ppos+2
- -- hmD = hmD+1
- if ppos < 2 then
- ppos = 1
- end
- gener()
- goup()
- if hmD == 0 then
- ppos = ppos+1
- hmD = 1
- elseif hmD < 5 then
- ppos = ppos+1
- hmD = hmD+1
- elseif hmD < 8 then
- ppos = ppos+2
- hmD = hmD + 1
- elseif hmD < 16 then
- ppos = ppos+3
- hmD = hmD - 1
- else
- ppos = ppos+4
- end
- if ppos > 20 then
- lose("You're fallen in nether")
- return
- end
- if qp == 2 then
- if q ~= ppos and q ~= ppos - 1 and q ~= ppos + 1 then
- lose("FlappyPixel hit building")
- return
- end
- end
- if w ~= ppos and w ~= ppos + 1 and w ~= ppos - 1 and wp == 2 then
- lose("FlappyPixel hit building")
- return
- end
- if e ~= ppos and e~= ppos-1 and e~= ppos+1 and ep == 2 then
- lose("FlappyPixel hit building")
- return
- end
- sleep(0.3)
- end
- end
- function goup()
- pp = 10
- -- while true do
- for i=-1,0 do
- term.setCursorPos(2,ppos+i)
- term.write(" ")
- end
- term.setCursorPos(2,ppos)
- if aF then
- term.write("x")
- aF = false
- else
- term.write("+")
- aF = true
- end
- -- pp = pp+1
- -- end
- end
- simu()
- -- parallel.waitForAny(simu,kpress)
- end
- function credits()
- term.clear()
- term.setCursorPos(1,1)
- print("FlappyPixel - Controls")
- print("W to jump")
- print()
- print("Current version:")
- print(ver)
- print()
- if betatesting then
- print("Use at your own risk!")
- print()
- end
- print("Click to continue")
- os.pullEvent("mouse_click")
- return
- end
- function main()
- while true do
- drawMenu()
- event,button,x,y = os.pullEvent("mouse_click")
- if y == 4 then
- game()
- elseif y == 6 then
- credits()
- elseif y == 8 then
- return
- end
- end
- end
- --
- local ok,err = pcall(main)
- if err == "Terminated" then
- print("Terminated")
- print("Thanks for using FlappyPixel")
- return
- end
- --if ok then
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- term.clear()
- term.setCursorPos(1,1)
- if ok then
- print("Thanks for using FlappyPixel")
- term.setCursorPos(1,3)
- else
- print("--Crash report begin--")
- print("Ohh no! Crashed:")
- print()
- print(err)
- print()
- print("Please report!")
- print("--End--")
- print("press any key")
- os.pullEvent("key")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement