Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mon = peripheral.wrap("back")
- mon.clear()
- rs.setOutput("bottom", true)
- local xMax,yMax = mon.getSize()
- function hintergrund()
- mon.setBackgroundColor(colors.cyan)
- for b = 0,xMax,1 do
- for i = 0,yMax,1 do
- mon.setCursorPos(b,i)
- mon.write(" ")
- end
- end
- end
- momPosx = 10
- momPosy = 10
- xMitte = 10
- yMitte = 10
- positionenX = {xMitte-10,xMitte-9,xMitte-8,xMitte-7,xMitte-6,xMitte-5,xMitte-4,xMitte-3,xMitte-2,xMitte-1,xMitte}
- positionenY = {yMitte-10,yMitte-9,yMitte-8,yMitte-7,yMitte-6,yMitte-5,yMitte-4,yMitte-3,yMitte-2,yMitte-1,yMitte}
- function drawSnake(newPosX, newPosY, length)
- mon.setBackgroundColor(colors.cyan)
- for i=1,#positionenX do
- mon.setCursorPos(positionenX[i],positionenY[i])
- mon.write(" ")
- end
- for i=2,11 do
- positionenX[i] = positionenX[i-1]
- positionenY[i] = positionenY[i-1]
- end
- positionenX[1] = newPosX
- positionenY[1] = newPosY
- mon.setBackgroundColor(colors.white)
- for i=1,#positionenX do
- mon.setCursorPos(positionenX[i],positionenY[i])
- mon.write(" ")
- end
- end
- function steuerung()
- mon.setBackgroundColor(colors.cyan)
- mon.setTextColor(colors.white)
- mon.setCursorPos(60,15)
- mon.write("W")
- mon.setCursorPos(57,17)
- mon.write("A")
- mon.setCursorPos(60,17)
- mon.write("+")
- mon.setCursorPos(63,17)
- mon.write("S")
- mon.setCursorPos(60,19)
- mon.write("D")
- end
- steuerung()
- sleep(0.1)
- os.loadAPI("ocs/apis/sensor")
- proximity = sensor.wrap("top")
- while true do
- player = "warte auf Spieler..."
- sleep(0.1)
- targets = proximity.getTargets()
- for k,v in pairs(targets) do
- if v.Name == "Player"
- and v.Position.X<=3 and v.Position.X>=-3
- and v.Position.Z<=9 and v.Position.Z>=3
- and v.Position.Y>=-3 and v.Position.Y<=4
- then
- player = k
- H = " "
- --Springen
- if v.Name == "Player" and
- v.Position.X>=-0.5 and v.Position.X <=0.5 and
- v.Position.Z>=5.5 and v.Position.Z<=6.5 and
- v.Position.Y>=-0.5 and v.Position.Y<=2 then
- mon.setBackgroundColor(colors.cyan)
- mon.setTextColor(colors.black)
- mon.setCursorPos(60,17)
- mon.write("+")
- H = "+"
- print("+")
- else
- mon.setBackgroundColor(colors.cyan)
- mon.setTextColor(colors.white)
- mon.setCursorPos(60,17)
- mon.write("+")
- end
- --W
- if v.Name == "Player" and
- v.Position.X>=-0.5 and v.Position.X <=0.5 and
- v.Position.Z>=4.5 and v.Position.Z<=5.5 and
- v.Position.Y>=-3 and v.Position.Y<=4 then
- mon.setBackgroundColor(colors.cyan)
- mon.setTextColor(colors.blue)
- mon.setCursorPos(60,15)
- mon.write("W")
- hoch()
- H = "W"
- print("W")
- else
- mon.setBackgroundColor(colors.cyan)
- mon.setTextColor(colors.white)
- mon.setCursorPos(60,15)
- mon.write("W")
- end
- --A
- if v.Name == "Player" and
- v.Position.X>=-1.5 and v.Position.X <=-0.5 and
- v.Position.Z>=5.5 and v.Position.Z<=6.5 and
- v.Position.Y>=-3 and v.Position.Y<=4 then
- mon.setBackgroundColor(colors.cyan)
- mon.setTextColor(colors.red)
- mon.setCursorPos(57,17)
- mon.write("A")
- links()
- H = "A"
- print("A")
- else
- mon.setBackgroundColor(colors.cyan)
- mon.setTextColor(colors.white)
- mon.setCursorPos(57,17)
- mon.write("A")
- end
- --S
- if v.Name == "Player" and
- v.Position.X>=0.5 and v.Position.X <=1.5 and
- v.Position.Z>=5.5 and v.Position.Z<=6.5 and
- v.Position.Y>=-3 and v.Position.Y<=4 then
- mon.setBackgroundColor(colors.cyan)
- mon.setTextColor(colors.lime)
- mon.setCursorPos(63,17)
- mon.write("S")
- rechts()
- H = "S"
- print("S")
- else
- mon.setBackgroundColor(colors.cyan)
- mon.setTextColor(colors.white)
- mon.setCursorPos(63,17)
- mon.write("S")
- end
- --D
- if v.Name == "Player" and
- v.Position.X>=-0.5 and v.Position.X <=0.5 and
- v.Position.Z>=6.5 and v.Position.Z<=7.5 and
- v.Position.Y>=-3 and v.Position.Y<=4 then
- mon.setBackgroundColor(colors.cyan)
- mon.setTextColor(colors.yellow)
- mon.setCursorPos(60,19)
- mon.write("D")
- H = "D"
- print("D")
- unten()
- else
- mon.setBackgroundColor(colors.cyan)
- mon.setTextColor(colors.white)
- mon.setCursorPos(60,19)
- mon.write("D")
- end
- end
- end
- function hoch()
- f=1
- end
- function links()
- f=2
- end
- function rechts()
- f=3
- end
- function unten()
- f=4
- end
- if f==1 then
- momPosy = momPosy-1
- end
- if f==2 then
- momPosx = momPosx-1
- end
- if f==3 then
- momPosx = momPosx+1
- end
- if f==4 then
- momPosy = momPosy+1
- end
- xMaxn=xMax+1
- yMaxn=yMax+1
- if momPosx == xMaxn then
- momPosx = 1
- end
- if momPosx == 0 then
- momPosx = xMax
- end
- if momPosy == yMaxn then
- momPosy = 1
- end
- if momPosy == 0 then
- momPosy = yMax
- end
- drawSnake(momPosx, momPosy)
- sleep(0.2)
- end
Add Comment
Please, Sign In to add comment