Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- m = "1"
- local pX = 10
- local pY = 5
- local sc = 0
- run = true
- beam = math.max(math.random(1,20),0)
- local icolor = colors.white
- local pcolor = colors.blue
- local bcolor = colors.red
- local reset = colors.black
- term.setBackgroundColor(colors.brown)
- term.clear()
- term.setCursorPos(pX,pY)
- term.setBackgroundColor(pcolor)
- print(" ")
- term.setBackgroundColor(colors.brown)
- i = paintutils.loadImage("sprites/world/bworld")
- paintutils.drawImage(i,1,1)
- term.setCursorPos(1,5)
- iX = math.max(math.random(1,40),0)
- iY = math.max(math.random(5,17),0)
- term.setTextColor(colors.black)
- term.setCursorPos(iX,iY)
- term.setBackgroundColor(icolor)
- print "I"
- i2X = math.max(math.random(1,40),0)
- i2Y = math.max(math.random(5,17),0)
- term.setTextColor(colors.black)
- term.setCursorPos(i2X,i2Y)
- term.setBackgroundColor(icolor)
- print "I"
- term.setBackgroundColor(reset)
- term.setTextColor(colors.white)
- term.setBackgroundColor(colors.brown)
- term.setCursorPos(1,1)
- print "--------------------------------------------------"
- print "| Wellcome to Beams: |"
- print("| Score: " ..sc)
- print "--------------------------------------------------"
- term.setCursorPos(50,3)
- print "|"
- function db()
- i = paintutils.loadImage("sprites/world/bworld")
- paintutils.drawImage(i,1,1)
- end
- function reitem()
- term.setTextColor(colors.black)
- term.setCursorPos(iX,iY)
- term.setBackgroundColor(icolor)
- print "I"
- term.setTextColor(colors.black)
- term.setCursorPos(i2X,i2Y)
- term.setBackgroundColor(icolor)
- print "I"
- end
- function rei()
- iX = math.max(math.random(1,40),0)
- iY = math.max(math.random(5,17),0)
- term.setTextColor(colors.black)
- term.setCursorPos(iX,iY)
- term.setBackgroundColor(icolor)
- print "I"
- i2X = math.max(math.random(1,40),0)
- i2Y = math.max(math.random(5,17),0)
- term.setTextColor(colors.black)
- term.setCursorPos(i2X,i2Y)
- term.setBackgroundColor(icolor)
- print "I"
- end
- function drawLabel()
- term.setBackgroundColor(reset)
- term.setTextColor(colors.white)
- term.setBackgroundColor(colors.brown)
- term.setCursorPos(1,1)
- print "--------------------------------------------------"
- print "| Wellcome to Beams: |"
- print("| Score: " ..sc)
- print "--------------------------------------------------"
- term.setCursorPos(50,3)
- print "|"
- term.setCursorPos(1,5)
- term.setTextColor(colors.black)
- end
- function drawChar()
- term.setCursorPos(pX,pY)
- term.setBackgroundColor(pcolor)
- print(" ")
- term.setBackgroundColor(reset)
- end
- function check()
- if pX == iX and pY == iY then
- term.setCursorPos(iX,iY)
- term.setBackgroundColor(reset)
- print " "
- term.setCursorPos(pX,pY)
- term.setBackgroundColor(colors.blue)
- print " "
- sc = sc + 10
- drawLabel()
- sleep(0.5)
- rei()
- elseif pX == i2X and pY == i2Y then
- term.setCursorPos(i2X,i2Y)
- term.setBackgroundColor(reset)
- print " "
- term.setCursorPos(pX,pY)
- term.setBackgroundColor(colors.blue)
- print " "
- sc = sc + 10
- drawLabel()
- sleep(0.5)
- rei()
- end
- end
- function beeam()
- ranb = math.max(math.random(1,10),0)
- if ranb == 3 then
- beam = math.max(math.random(5,17),0)
- term.setCursorPos(54,beam)
- sleep(0.1)
- term.setCursorPos(pX,pY)
- term.setBackgroundColor(colors.blue)
- print " "
- be = beam + 1
- term.setCursorPos(1,1)
- term.setTextColor(colors.white)
- term.setBackgroundColor(colors.brown)
- print("INCOMEING Line: "..beam)
- sleep(1.2)
- term.setCursorPos(54,beam)
- term.setBackgroundColor(colors.red)
- term.setCursorPos(54,beam)
- print " "
- term.setBackgroundColor(colors.red)
- print("================================================")
- sleep(0.2)
- term.setCursorPos(pX,pY)
- term.setBackgroundColor(colors.blue)
- print " "
- if be == pY then
- term.setBackgroundColor(colors.black)
- term.clear()
- term.setCursorPos(10,5)
- term.setTextColor(colors.yellow)
- print "Game Over"
- term.setCursorPos(10,5)
- print("Score: "..sc)
- sleep(2)
- run = false
- return
- else
- term.setBackgroundColor(colors.brown)
- term.clear()
- db()
- drawLabel()
- term.setCursorPos(pX,pY)
- term.setBackgroundColor(colors.blue)
- print " "
- term.setCursorPos(iX,iY)
- term.setBackgroundColor(icolor)
- print "I"
- term.setCursorPos(i2X,i2Y)
- term.setBackgroundColor(icolor)
- print "I"
- move()
- term.setCursorPos(pX,pY)
- term.setBackgroundColor(colors.blue)
- print " "
- return move()
- end
- end
- end
- function move()
- while run == true do
- local event, button = os.pullEventRaw("key")
- term.setTextColor(colors.white)
- term.setBackgroundColor(colors.black)
- if button == 200 then --up
- if pY == 5 then
- term.setCursorPos(1,1)
- print "Cantmove"
- event = os.pullEvent("key")
- drawLabel()
- move()
- else
- sleep(0.001)
- db()
- reitem()
- drawLabel()
- pY = pY - 1
- print " "
- drawChar()
- check()
- beeam()
- move()
- end
- end
- if button == 208 then -- down
- if pY == 18 then
- term.setCursorPos(1,1)
- print "Cantmove"
- event = os.pullEvent("key")
- drawLabel()
- move()
- else
- sleep(0.001)
- db()
- reitem()
- drawLabel()
- pY = pY + 1
- check()
- beeam()
- drawChar()
- move()
- end
- end
- if button == 203 then -- left
- if pX == 1 then
- term.setCursorPos(1,1)
- print "Cantmove"
- event = os.pullEvent("key")
- drawLabel()
- move()
- else
- sleep(0.001)
- pX = pX - 1
- db()
- reitem()
- drawLabel()
- check()
- beeam()
- drawChar()
- move()
- end
- end
- if button == 205 then -- right
- if pX == 51 then
- term.setCursorPos(1,1)
- print "Cantmove"
- event = os.pullEvent("key")
- drawLabel()
- move()
- else
- sleep(0.001)
- db()
- reitem()
- drawLabel()
- pX = pX + 1
- check()
- beeam()
- drawChar()
- move()
- end
- end
- end
- end
- move()
Advertisement
Add Comment
Please, Sign In to add comment