Nike622000

Multiplayer

Aug 10th, 2016
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.60 KB | None | 0 0
  1. --  Bdraw(colors.black)
  2. --  term.setCursorPos(1,1)
  3. --  term.setTextColor(colors.red)      
  4. --  term.write(Name)
  5.    
  6. --  term.setCursorPos(20,1)
  7. --  term.setTextColor(colors.cyan)
  8. --  term.write("Name: ")
  9. --  Name2 = io.read()
  10.    
  11.     term.setCursorPos(10,4)
  12.     term.setTextColor(colors.yellow)
  13.     term.write("Spiel wird gestartet...")
  14.     term.setCursorPos(1,6)
  15.     term.setTextColor(colors.red)
  16. --  term.write("Spieler 1: "..Name.." steuert mit Pfeiltasten")
  17.     term.setCursorPos(1,7)
  18.     term.setTextColor(colors.cyan)
  19. --  term.write("Spieler 2: "..Name2.." steuert mit WASD")
  20.     for b = 5,1,-1 do
  21.     term.setTextColor(colors.orange)
  22.     term.setCursorPos(10,9)
  23.     term.write(b)
  24.     sleep(1)
  25.     end
  26.  
  27. --  Bdraw(colors.black)
  28.     xPosition1 = {}
  29.     yPosition1 = {}
  30.     xPosition2 = {}
  31.     yPosition2 = {}
  32.     Pos = 1
  33.     xPos1 = 10
  34.     yPos1 = 15
  35.     xPos2 = 20
  36.     yPos2 = 5
  37.  
  38. Richtung1 = 2
  39. Richtung2 = 4
  40.  
  41.     while true do
  42.     xPosition1[Pos] = xPos1
  43.     yPosition1[Pos] = yPos1
  44.     xPosition2[Pos] = xPos2
  45.     yPosition2[Pos] = yPos2
  46.  
  47.  
  48.     term.setBackgroundColor(colors.red)
  49.     term.setCursorPos(xPos1,yPos1)
  50.     term.write(" ")
  51.  
  52.     term.setBackgroundColor(colors.cyan)
  53.     term.setCursorPos(xPos2,yPos2)
  54.     term.write(" ")
  55.  
  56.     Timer = os.startTimer(0.2)
  57.     event ,key = os.pullEvent()
  58.  
  59.     if event == "key" then
  60.    
  61.     sleep(0.2)
  62. --oben1
  63.     if key == 200 then
  64.     Richtung1 = 1
  65. --rechts1
  66.     elseif key == 205 then
  67.     Richtung1 = 2
  68. --unten1
  69.     elseif key == 208 then
  70.     Richtung1 = 3
  71. --links1
  72.     elseif key == 203 then
  73.     Richtung1 = 4
  74.     end
  75.  
  76. --oben2
  77.     if key == 17 then
  78.     Richtung2 = 1
  79. --rechts2
  80.     elseif key == 32 then
  81.     Richtung2 = 2
  82. --unten2
  83.     elseif key == 31 then
  84.     Richtung2 = 3
  85. --links2
  86.     elseif key == 30 then
  87.     Richtung2 = 4
  88.     end
  89.  
  90.     end
  91.     if Richtung1 == 1 then
  92.     yPos1 = yPos1-1
  93.     elseif
  94.     Richtung1 == 2 then
  95.     xPos1 = xPos1+1
  96.     elseif
  97.     Richtung1 == 3 then
  98.     yPos1 = yPos1+1
  99.     elseif
  100.     Richtung1 == 4 then
  101.     xPos1 = xPos1-1
  102.     end
  103.  
  104.     if Richtung2 == 1 then
  105.     yPos2 = yPos2-1
  106.     elseif
  107.     Richtung2 == 2 then
  108.     xPos2 = xPos2+1
  109.     elseif
  110.     Richtung2 == 3 then
  111.     yPos2 = yPos2+1
  112.     elseif
  113.     Richtung2 == 4 then
  114.     xPos2 = xPos2-1
  115.     end
  116. xMax = 10
  117. yMax = 20
  118.     Pos = Pos+1
  119.     --for Px = 1,#xPosition1 do
  120.     --if xPos1 == xPosition1[Px] and yPos1 == yPosition1[Px] or xPos1 == xMax+1 or yPos1 == yMax+1 or xPos1 == 0 or yPos1 == 0 then
  121.     --Bdraw(colors.black)
  122.     --term.setCursorPos(7,5)
  123.     --term.write("Spieler 1 verliert")
  124.     --elseif xPos2 == xPosition2[Px] and yPos2 == yPosition2[Px] or xPos2 == xMax+1 or yPos2 == yMax+1 or xPos2 == 0 or yPos2 == 0 then
  125.     --Bdraw(colors.black)
  126.     --term.setCursorPos(7,5)
  127.     --term.write("Spieler 2 verliert")
  128.     --end
  129.     --end
  130.     --sleep(3)
  131.     --os.reboot()
  132.  
  133.  
  134.     end
Advertisement
Add Comment
Please, Sign In to add comment