Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- lives = 5
- px = 1
- py = 4
- p2x = 49
- p2y = 4
- p1p = 0
- p2p = 0
- p1b = 3
- p2b = 3
- p1ba = down
- p2ba = down
- bar = paintutils.loadImage("lbbar")
- field = paintutils.loadImage("lbback")
- char1 = paintutils.loadImage("lbc1")
- char2 = paintutils.loadImage("lbc2")
- run = true
- function p1()
- while run do
- local event, button, X, Y = os.pullEvent("key")
- if button == keys.w then
- if py ~= 2 then
- py = py - 1
- sleep(0.010)
- term.setBackgroundColor(colors.lightBlue)
- term.clear()
- term.setBackgroundColor(colors.orange)
- term.setCursorPos(1,1)
- print("P1: "..p1p.."/"..lives)
- term.setCursorPos(45,1)
- print("P2: "..p2p.."/"..lives)
- term.setBackgroundColor(colors.lightBlue)
- paintutils.drawImage(field,2,2)
- if p1ba == "up" then
- paintutils.drawImage(bar,px+1,py-1)
- end
- if p2ba == "up" then
- paintutils.drawImage(bar,p2x-1,p2y-1)
- end
- paintutils.drawImage(char1,px,py)
- paintutils.drawImage(char2,p2x,p2y)
- if p1ba == "up" then
- paintutils.drawImage(bar,px+1,py-1)
- end
- end
- end
- if button == keys.s then
- if py ~= 17 then
- py = py + 1
- sleep(0.010)
- term.setBackgroundColor(colors.lightBlue)
- term.clear()
- term.setBackgroundColor(colors.orange)
- term.setCursorPos(1,1)
- print("P1: "..p1p.."/"..lives)
- term.setCursorPos(45,1)
- print("P2: "..p2p.."/"..lives)
- term.setBackgroundColor(colors.lightBlue)
- paintutils.drawImage(field,2,2)
- if p1ba == "up" then
- paintutils.drawImage(bar,px+1,py-1)
- end
- if p2ba == "up" then
- paintutils.drawImage(bar,p2x-1,p2y-1)
- end
- paintutils.drawImage(char1,px,py)
- paintutils.drawImage(char2,p2x,p2y)
- if p1ba == "up" then
- paintutils.drawImage(bar,px+1,py-1)
- end
- end
- end
- if button == keys.leftShift then
- lx = px+1
- term.setCursorPos(lx,py)
- term.setBackgroundColor(colors.red)
- print "================================================"
- sleep(0.2)
- term.setBackgroundColor(colors.orange)
- term.setCursorPos(1,1)
- print("P1: "..p1p.."/"..lives)
- term.setCursorPos(45,1)
- print("P2: "..p2p.."/"..lives)
- if p1p == lives - 1 then
- p1p = p1p + 1
- term.setBackgroundColor(colors.orange)
- term.setCursorPos(1,1)
- term.setBackgroundColor(colors.orange)
- print("P1: "..p1p.."/"..lives)
- term.setCursorPos(45,1)
- print("P2: "..p2p.."/"..lives)
- print "PLayer 1 Wins!"
- run = false
- return
- elseif py == p2y then
- if p2ba == "up" then
- p2ba = down
- term.setCursorPos(1,1)
- term.setBackgroundColor(colors.orange)
- print("P1: "..p1p.."/"..lives)
- term.setCursorPos(45,1)
- print("P2: "..p2p.."/"..lives)
- else
- p1p = p1p + 1
- term.setCursorPos(1,1)
- term.setBackgroundColor(colors.orange)
- print("P1: "..p1p.."/"..lives)
- term.setCursorPos(45,1)
- print("P2: "..p2p.."/"..lives)
- end
- end
- sleep(0.2)
- term.setBackgroundColor(colors.lightBlue)
- term.clear()
- term.setCursorPos(1,1)
- print("P1: "..p1p.."/"..lives)
- term.setCursorPos(45,1)
- print("P2: "..p2p.."/"..lives)
- term.setBackgroundColor(colors.lightBlue)
- paintutils.drawImage(field,2,2)
- term.setBackgroundColor(colors.orange)
- if p1ba == "up" then
- paintutils.drawImage(bar,px+1,py-1)
- end
- if p2ba == "up" then
- paintutils.drawImage(bar,p2x-1,p2y-1)
- end
- paintutils.drawImage(char1,px,py)
- paintutils.drawImage(char2,p2x,p2y)
- end
- if button == keys.d then
- if p1b == 0 then
- else
- paintutils.drawImage(bar,px+1,py-1)
- p1b = p1b - 1
- p1ba = "up"
- end
- end
- end
- end
- function p2()
- while run do
- local event, button, X, Y = os.pullEvent("key")
- if button == keys.down then
- if p2y ~= 17 then
- p2y = p2y + 1
- sleep(0.010)
- term.setBackgroundColor(colors.lightBlue)
- term.clear()
- term.setBackgroundColor(colors.orange)
- term.setCursorPos(1,1)
- print("P1: "..p1p.."/"..lives)
- term.setCursorPos(45,1)
- print("P2: "..p2p.."/"..lives)
- term.setBackgroundColor(colors.lightBlue)
- paintutils.drawImage(field,2,2)
- term.setBackgroundColor(colors.orange)
- if p1ba == "up" then
- paintutils.drawImage(bar,px+1,py-1)
- end
- if p2ba == "up" then
- paintutils.drawImage(bar,p2x-1,p2y-1)
- end
- paintutils.drawImage(char1,px,py)
- paintutils.drawImage(char2,p2x,p2y)
- end
- end
- if button == keys.up then
- if p2y ~= 2 then
- p2y = p2y - 1
- sleep(0.010)
- term.setBackgroundColor(colors.lightBlue)
- term.clear()
- term.setBackgroundColor(colors.orange)
- term.setCursorPos(1,1)
- print("P1: "..p1p.."/"..lives)
- term.setCursorPos(45,1)
- print("P2: "..p2p.."/"..lives)
- term.setBackgroundColor(colors.lightBlue)
- paintutils.drawImage(field,2,2)
- term.setBackgroundColor(colors.orange)
- if p1ba == "up" then
- paintutils.drawImage(bar,px+1,py-1)
- end
- if p2ba == "up" then
- paintutils.drawImage(bar,p2x-1,p2y-1)
- end
- paintutils.drawImage(char1,px,py)
- paintutils.drawImage(char2,p2x,p2y)
- end
- end
- if button == keys.rightShift then
- l2y = p2y - 1
- term.setCursorPos(p2x,l2y)
- term.setBackgroundColor(colors.blue)
- print "================================================"
- sleep(0.2)
- term.setBackgroundColor(colors.orange)
- term.setCursorPos(1,1)
- print("P1: "..p1p.."/"..lives)
- term.setCursorPos(45,1)
- print("P2: "..p2p.."/"..lives)
- if p2p == lives - 1 then
- p2p = p2p + 1
- term.setBackgroundColor(colors.orange)
- if p1ba == "up" then
- paintutils.drawImage(bar,px+1,py-1)
- end
- if p2ba == "up" then
- paintutils.drawImage(bar,p2x-1,p2y-1)
- end
- term.setBackgroundColor(colors.orange)
- term.setCursorPos(1,1)
- print("P1: "..p1p.."/"..lives)
- term.setCursorPos(45,1)
- print("P2: "..p2p.."/"..lives)
- print "PLayer 2 Wins!"
- run = false
- return
- elseif p2y == py then
- if p1ba == "up" then
- p1ba = down
- term.setCursorPos(1,1)
- term.setBackgroundColor(colors.orange)
- print("P1: "..p1p.."/"..lives)
- term.setCursorPos(45,1)
- print("P2: "..p2p.."/"..lives)
- else
- p2p = p2p + 1
- term.setCursorPos(1,1)
- term.setBackgroundColor(colors.orange)
- print("P1: "..p1p.."/"..lives)
- term.setCursorPos(45,1)
- print("P2: "..p2p.."/"..lives)
- end
- end
- sleep(0.2)
- term.setBackgroundColor(colors.lightBlue)
- term.clear()
- term.setCursorPos(1,1)
- print("P1: "..p1p.."/"..lives)
- term.setCursorPos(45,1)
- print("P2: "..p2p.."/"..lives)
- term.setBackgroundColor(colors.lightBlue)
- paintutils.drawImage(field,2,2)
- term.setBackgroundColor(colors.orange)
- if p1ba == "up" then
- paintutils.drawImage(bar,px+1,py-1)
- end
- if p2ba == "up" then
- paintutils.drawImage(bar,p2x-1,p2y-1)
- end
- paintutils.drawImage(char1,px,py)
- paintutils.drawImage(char2,p2x,p2y)
- end
- if button == keys.l then
- if p2b == 0 then
- else
- paintutils.drawImage(bar,p2x-1,p2y-1)
- p2b = p2b - 1
- p2ba = "up"
- end
- end
- end
- end
- term.setBackgroundColor(colors.lightBlue)
- term.clear()
- term.setBackgroundColor(colors.orange)
- term.setCursorPos(1,1)
- print("P1: "..p1p.."/"..lives)
- term.setCursorPos(45,1)
- print("P2: "..p2p.."/"..lives)
- term.setBackgroundColor(colors.lightBlue)
- paintutils.drawImage(field,2,2)
- term.setBackgroundColor(colors.orange)
- if p1ba == "up" then
- paintutils.drawImage(bar,px+1,py-1)
- end
- if p2ba == "up" then
- paintutils.drawImage(bar,p2x-1,p2y-1)
- end
- paintutils.drawImage(char1,px,py)
- paintutils.drawImage(char2,p2x,p2y)
- function para()
- while run do
- parallel.waitForAny(p1,p2)
- end
- end
- para()
Advertisement
Add Comment
Please, Sign In to add comment