Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function startup()
- xMax,yMax = term.getSize()
- monSide = "top"
- mon = peripheral.wrap(monSide)
- end
- startup()
- function Bdraw(Bcol)
- term.setBackgroundColor(Bcol)
- for yPos = 1,yMax do
- for xPos = 1,xMax do
- term.setCursorPos(xPos,yPos)
- term.write(" ")
- end
- end
- end
- function Anzeige(Tcol)
- term.setTextColor(colors.red)
- term.setCursorPos(5,2)
- term.write("Tron ")
- term.setTextColor(colors.white)
- term.write("a ")
- term.setTextColor(colors.cyan)
- term.write("CC")
- term.setTextColor(colors.white)
- term.write("-")
- term.setTextColor(colors.orange)
- term.write("Minigame")
- term.setTextColor(colors.white)
- term.write(" [v.1.2]")
- term.setTextColor(Tcol)
- term.setCursorPos(2,3)
- term.write("Benutze WASD oder die Pfeiltasten zum steuern")
- term.setCursorPos(2,5)
- term.write("[Spiel starten]")
- term.setCursorPos(2,6)
- term.write("[Highscore]")
- term.setCursorPos(2,7)
- term.write("[Anleitung]")
- term.setCursorPos(2,8)
- term.write("[Beenden]")
- end
- function menue()
- i = 1
- while true do
- Anzeige(colors.white)
- --Markierung
- term.setTextColor(colors.red)
- if i == 1 then
- term.setCursorPos(2,5)
- term.write("[Spiel starten]")
- end
- if i == 2 then
- term.setCursorPos(2,6)
- term.write("[Highscore]")
- end
- if i == 3 then
- term.setCursorPos(2,7)
- term.write("[Anleitung]")
- end
- if i == 4 then
- term.setCursorPos(2,8)
- term.write("[Beenden]")
- end
- --
- local event, key = os.pullEvent("key")
- if key == 200 or key == 17 then
- i = i-1
- end
- if key == 208 or key == 31 then
- i = i+1
- end
- if i == 5 then
- i = 1
- end
- if i == 0 then
- i = 4
- end
- if key == 28 and i == 1 then
- Bdraw(colors.black)
- term.setCursorPos(7,5)
- term.setTextColor(colors.cyan)
- term.write("Enter Name: ")
- Name = io.read()
- Bdraw(colors.black)
- i = 1
- while true do
- term.setTextColor(colors.white)
- term.setCursorPos(7,5)
- term.write("[Einfach]")
- term.setCursorPos(7,6)
- term.write("[Mittel]")
- term.setCursorPos(7,7)
- term.write("[Schwer]")
- term.setCursorPos(7,8)
- term.write("[Multiplayer]")
- term.setTextColor(colors.red)
- if i == 1 then
- term.setCursorPos(7,5)
- term.write("[Einfach]")
- end
- if i == 2 then
- term.setCursorPos(7,6)
- term.write("[Mittel]")
- end
- if i == 3 then
- term.setCursorPos(7,7)
- term.write("[Schwer]")
- end
- if i == 4 then
- term.setCursorPos(7,8)
- term.write("[Multiplayer]")
- end
- event,key = os.pullEvent()
- if key == 200 or key == 17 then
- i = i-1
- end
- if key == 208 or key == 31 then
- i = i+1
- end
- if i == 5 then
- i = 1
- end
- if i == 0 then
- i = 4
- end
- if key == 28 and i == 1 then
- time = 0.3
- break
- elseif key == 28 and i == 2 then
- time = 0.2
- break
- elseif key == 28 and i == 3 then
- time = 0.1
- break
- elseif key == 28 and i == 4 then
- Bdraw(colors.black)
- term.setCursorPos(1,1)
- term.setTextColor(colors.red)
- term.write(Name)
- term.setCursorPos(20,1)
- term.setTextColor(colors.cyan)
- term.write("Name: ")
- Name2 = io.read()
- term.setCursorPos(10,4)
- term.setTextColor(colors.yellow)
- term.write("Spiel wird gestartet...")
- term.setCursorPos(1,6)
- term.setTextColor(colors.red)
- term.write("Spieler 1: "..Name.." steuert mit Pfeiltasten")
- term.setCursorPos(1,7)
- term.setTextColor(colors.cyan)
- term.write("Spieler 2: "..Name2.." steuert mit WASD")
- for b = 5,1,-1 do
- term.setTextColor(colors.orange)
- term.setCursorPos(10,9)
- term.write(b)
- sleep(1)
- end
- Bdraw(colors.black)
- xPosition1 = {}
- yPosition1 = {}
- xPosition2 = {}
- yPosition2 = {}
- Pos = 1
- xPos1 = 10
- yPos1 = 15
- xPos2 = 20
- yPos2 = 5
- Richtung1 = 2
- Richtung2 = 4
- while true do
- xPosition1[Pos] = xPos1
- yPosition1[Pos] = yPos1
- xPosition2[Pos] = xPos2
- yPosition2[Pos] = yPos2
- term.setBackgroundColor(colors.red)
- term.setCursorPos(xPos1,yPos1)
- term.write(" ")
- term.setBackgroundColor(colors.cyan)
- term.setCursorPos(xPos2,yPos2)
- term.write(" ")
- Timer = os.startTimer(0.2)
- event ,key = os.pullEvent()
- if event == "key" then
- sleep(0.2)
- --oben1
- if key == 200 then
- Richtung1 = 1
- --rechts1
- elseif key == 205 then
- Richtung1 = 2
- --unten1
- elseif key == 208 then
- Richtung1 = 3
- --links1
- elseif key == 203 then
- Richtung1 = 4
- end
- --oben2
- if key == 17 then
- Richtung2 = 1
- --rechts2
- elseif key == 32 then
- Richtung2 = 2
- --unten2
- elseif key == 31 then
- Richtung2 = 3
- --links2
- elseif key == 30 then
- Richtung2 = 4
- end
- end
- if Richtung1 == 1 then
- yPos1 = yPos1-1
- elseif
- Richtung1 == 2 then
- xPos1 = xPos1+1
- elseif
- Richtung1 == 3 then
- yPos1 = yPos1+1
- elseif
- Richtung1 == 4 then
- xPos1 = xPos1-1
- end
- if Richtung2 == 1 then
- yPos2 = yPos2-1
- elseif
- Richtung2 == 2 then
- xPos2 = xPos2+1
- elseif
- Richtung2 == 3 then
- yPos2 = yPos2+1
- elseif
- Richtung2 == 4 then
- xPos2 = xPos2-1
- end
- Pos = Pos+1
- for f = 1,#xPosition1 do
- if xPos1 == xPosition1[f] and yPos1 == yPosition1[f] or xPos1 == xMax+1 or yPos1 == yMax+1 or xPos1 == 0 or yPos1 == 0 or xPos1 == xPosition2[f] and yPos1 == yPosition2[f] then
- Bdraw(colors.black)
- term.setCursorPos(7,5)
- term.write(Name.." verliert")
- sleep(1)
- end
- if xPos2 == xPosition2[f] and yPos2 == yPosition2[f] or xPos2 == xMax+1 or yPos2 == yMax+1 or xPos2 == 0 or yPos2 == 0 or xPos2 == xPosition1[f] and yPos2 == yPosition1[f] then
- Bdraw(colors.black)
- term.setCursorPos(7,5)
- term.write(Name2.." verliert")
- sleep(1)
- end
- end
- -- for Px = 1,#xPosition1 do
- -- if xPos1 == xPosition1[Px] and yPos1 == yPosition1[Px] then
- -- Bdraw(colors.black)
- -- term.setCursorPos(7,5)
- -- term.write("Spieler 1 verliert")
- -- elseif xPos2 == xPosition2[Px] and yPos2 == yPosition2[Px] then
- -- Bdraw(colors.black)
- -- term.setCursorPos(7,5)
- -- term.write("Spieler 2 verliert")
- -- end
- -- end
- -- sleep(3)
- -- os.reboot()
- end
- end
- end
- Bdraw(colors.black)
- xPosition = {}
- yPosition = {}
- Pos = 1
- xPos = 10
- yPos = 15
- e = 2
- Points = 0
- while true do
- xPosition[Pos] = xPos
- yPosition[Pos] = yPos
- term.setBackgroundColor(colors.red)
- term.setCursorPos(xPos,yPos)
- term.write(" ")
- Timer = os.startTimer(time)
- event ,key = os.pullEvent()
- if event == "key" then
- sleep(time)
- --oben
- if key == 200 or key == 17 then
- e = 1
- --rechts
- elseif key == 205 or key == 32 then
- e = 2
- --unten
- elseif key == 208 or key == 31 then
- e = 3
- --links
- elseif key == 203 or key == 30 then
- e = 4
- end
- end
- if e == 1 then
- yPos = yPos-1
- elseif
- e == 2 then
- xPos = xPos+1
- elseif
- e == 3 then
- yPos = yPos+1
- elseif
- e == 4 then
- xPos = xPos-1
- end
- Points = math.floor((Points+1000*Pos)-(time*5)^10)
- mon.setTextColor(colors.orange)
- term.setTextColor(colors.orange)
- mon.setBackgroundColor(colors.black)
- term.setBackgroundColor(colors.black)
- mon.setCursorPos(15,1)
- term.setCursorPos(15,1)
- mon.write(Name.." Punkte: "..Points)
- term.write(Name.." Punkte: "..Points)
- mon.setBackgroundColor(colors.red)
- term.setBackgroundColor(colors.red)
- mon.setCursorPos(xPos,yPos)
- term.setCursorPos(xPos,yPos)
- mon.write(" ")
- term.write(" ")
- --print(xPosition[Pos])
- --print(yPosition[Pos])
- Pos = Pos+1
- for Px = 1,#xPosition do
- if xPos == xPosition[Px] and yPos == yPosition[Px] or xPos == xMax+1 or yPos == yMax+1 or xPos == 0 or yPos == 0 then
- Bdraw(colors.black)
- term.setCursorPos(7,5)
- term.write("Game over")
- term.setCursorPos(7,6)
- term.write("Score: "..Points)
- file = fs.open("highscore", "w")
- file.writeLine(Name)
- file.writeLine(Points)
- file.close()
- sleep(3)
- os.reboot()
- end
- end
- end
- elseif key == 28 and i == 2 then
- print("Optionen")
- elseif key == 28 and i == 3 then
- print("Anleitung")
- elseif key == 28 and i == 4 then
- os.reboot()
- end
- end
- end
- startup()
- Bdraw(colors.black)
- menue()
Advertisement
Add Comment
Please, Sign In to add comment