Nike622000

CC Minigame

Aug 10th, 2016
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.62 KB | None | 0 0
  1.  
  2. function startup()
  3. xMax,yMax = term.getSize()
  4. monSide = "top"
  5.  
  6. mon = peripheral.wrap(monSide)
  7.  
  8. end
  9.  
  10. startup()
  11.  
  12. function Bdraw(Bcol)
  13. term.setBackgroundColor(Bcol)
  14.     for yPos = 1,yMax do
  15.         for xPos = 1,xMax do
  16.         term.setCursorPos(xPos,yPos)
  17.         term.write(" ")
  18.         end
  19.     end
  20. end
  21.  
  22. function Anzeige(Tcol)
  23. term.setTextColor(colors.red)
  24. term.setCursorPos(5,2)
  25. term.write("Tron ")
  26. term.setTextColor(colors.white)
  27. term.write("a ")
  28. term.setTextColor(colors.cyan)
  29. term.write("CC")
  30. term.setTextColor(colors.white)
  31. term.write("-")
  32. term.setTextColor(colors.orange)
  33. term.write("Minigame")
  34. term.setTextColor(colors.white)
  35. term.write(" [v.1.2]")
  36. term.setTextColor(Tcol)
  37. term.setCursorPos(2,3)
  38. term.write("Benutze WASD oder die Pfeiltasten zum steuern")
  39. term.setCursorPos(2,5)
  40. term.write("[Spiel starten]")
  41. term.setCursorPos(2,6)
  42. term.write("[Highscore]")
  43. term.setCursorPos(2,7)
  44. term.write("[Anleitung]")
  45. term.setCursorPos(2,8)
  46. term.write("[Beenden]")
  47. end
  48.  
  49. function menue()
  50. i = 1
  51.     while true do
  52. Anzeige(colors.white)
  53.  
  54. --Markierung
  55. term.setTextColor(colors.red)
  56. if i == 1 then
  57. term.setCursorPos(2,5)
  58. term.write("[Spiel starten]")
  59. end
  60.  
  61. if i == 2 then
  62. term.setCursorPos(2,6)
  63. term.write("[Highscore]")
  64. end
  65.  
  66. if i == 3 then
  67. term.setCursorPos(2,7)
  68. term.write("[Anleitung]")
  69. end
  70.  
  71. if i == 4 then
  72. term.setCursorPos(2,8)
  73. term.write("[Beenden]")
  74. end
  75.  
  76. --
  77.  
  78. local event, key = os.pullEvent("key")
  79.  
  80. if key == 200 or key == 17 then
  81. i = i-1
  82. end
  83.  
  84. if key == 208 or key == 31 then
  85. i = i+1
  86. end
  87.  
  88. if i == 5 then
  89. i = 1
  90. end
  91.  
  92.  
  93. if i == 0 then
  94. i = 4
  95. end
  96.  
  97. if key == 28 and i == 1 then
  98. Bdraw(colors.black)
  99. term.setCursorPos(7,5) 
  100. term.setTextColor(colors.cyan)
  101. term.write("Enter Name: ")
  102. Name = io.read()
  103. Bdraw(colors.black)
  104. i = 1
  105. while true do
  106.  
  107. term.setTextColor(colors.white)
  108. term.setCursorPos(7,5)
  109. term.write("[Einfach]")
  110. term.setCursorPos(7,6)
  111. term.write("[Mittel]")
  112. term.setCursorPos(7,7)
  113. term.write("[Schwer]")
  114. term.setCursorPos(7,8)
  115. term.write("[Multiplayer]")
  116. term.setTextColor(colors.red)
  117. if i == 1 then
  118. term.setCursorPos(7,5)
  119. term.write("[Einfach]")
  120. end
  121.  
  122. if i == 2 then
  123. term.setCursorPos(7,6)
  124. term.write("[Mittel]")
  125. end
  126.  
  127. if i == 3 then
  128. term.setCursorPos(7,7)
  129. term.write("[Schwer]")
  130. end
  131.  
  132. if i == 4 then
  133. term.setCursorPos(7,8)
  134. term.write("[Multiplayer]")
  135. end
  136. event,key = os.pullEvent()
  137. if key == 200 or key == 17 then
  138. i = i-1
  139. end
  140.  
  141. if key == 208 or key == 31 then
  142. i = i+1
  143. end
  144. if i == 5 then
  145. i = 1
  146. end
  147.  
  148.  
  149. if i == 0 then
  150. i = 4
  151. end
  152.  
  153.  
  154.  
  155. if key == 28 and i == 1 then
  156. time = 0.3
  157. break
  158. elseif key == 28 and i == 2 then
  159. time = 0.2
  160. break
  161. elseif key == 28 and i == 3 then
  162. time = 0.1
  163. break
  164. elseif key == 28 and i == 4 then
  165.     Bdraw(colors.black)
  166.     term.setCursorPos(1,1)
  167.     term.setTextColor(colors.red)      
  168.     term.write(Name)
  169.    
  170.     term.setCursorPos(20,1)
  171.     term.setTextColor(colors.cyan)
  172.     term.write("Name: ")
  173.     Name2 = io.read()
  174.    
  175.     term.setCursorPos(10,4)
  176.     term.setTextColor(colors.yellow)
  177.     term.write("Spiel wird gestartet...")
  178.     term.setCursorPos(1,6)
  179.     term.setTextColor(colors.red)
  180.     term.write("Spieler 1: "..Name.." steuert mit Pfeiltasten")
  181.     term.setCursorPos(1,7)
  182.     term.setTextColor(colors.cyan)
  183.     term.write("Spieler 2: "..Name2.." steuert mit WASD")
  184.     for b = 5,1,-1 do
  185.     term.setTextColor(colors.orange)
  186.     term.setCursorPos(10,9)
  187.     term.write(b)
  188.     sleep(1)
  189.     end
  190.  
  191.     Bdraw(colors.black)
  192.     xPosition1 = {}
  193.     yPosition1 = {}
  194.     xPosition2 = {}
  195.     yPosition2 = {}
  196.     Pos = 1
  197.     xPos1 = 10
  198.     yPos1 = 15
  199.     xPos2 = 20
  200.     yPos2 = 5
  201.  
  202. Richtung1 = 2
  203. Richtung2 = 4
  204.  
  205.     while true do
  206.     xPosition1[Pos] = xPos1
  207.     yPosition1[Pos] = yPos1
  208.     xPosition2[Pos] = xPos2
  209.     yPosition2[Pos] = yPos2
  210.  
  211.  
  212.     term.setBackgroundColor(colors.red)
  213.     term.setCursorPos(xPos1,yPos1)
  214.     term.write(" ")
  215.  
  216.     term.setBackgroundColor(colors.cyan)
  217.     term.setCursorPos(xPos2,yPos2)
  218.     term.write(" ")
  219.  
  220.     Timer = os.startTimer(0.2)
  221.     event ,key = os.pullEvent()
  222.  
  223.     if event == "key" then
  224.    
  225.     sleep(0.2)
  226. --oben1
  227.     if key == 200 then
  228.     Richtung1 = 1
  229. --rechts1
  230.     elseif key == 205 then
  231.     Richtung1 = 2
  232. --unten1
  233.     elseif key == 208 then
  234.     Richtung1 = 3
  235. --links1
  236.     elseif key == 203 then
  237.     Richtung1 = 4
  238.     end
  239.  
  240. --oben2
  241.     if key == 17 then
  242.     Richtung2 = 1
  243. --rechts2
  244.     elseif key == 32 then
  245.     Richtung2 = 2
  246. --unten2
  247.     elseif key == 31 then
  248.     Richtung2 = 3
  249. --links2
  250.     elseif key == 30 then
  251.     Richtung2 = 4
  252.     end
  253.  
  254.     end
  255.     if Richtung1 == 1 then
  256.     yPos1 = yPos1-1
  257.     elseif
  258.     Richtung1 == 2 then
  259.     xPos1 = xPos1+1
  260.     elseif
  261.     Richtung1 == 3 then
  262.     yPos1 = yPos1+1
  263.     elseif
  264.     Richtung1 == 4 then
  265.     xPos1 = xPos1-1
  266.     end
  267.  
  268.     if Richtung2 == 1 then
  269.     yPos2 = yPos2-1
  270.     elseif
  271.     Richtung2 == 2 then
  272.     xPos2 = xPos2+1
  273.     elseif
  274.     Richtung2 == 3 then
  275.     yPos2 = yPos2+1
  276.     elseif
  277.     Richtung2 == 4 then
  278.     xPos2 = xPos2-1
  279.     end
  280.  
  281.     Pos = Pos+1
  282.  
  283. for f = 1,#xPosition1 do
  284. 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
  285. Bdraw(colors.black)
  286. term.setCursorPos(7,5)
  287. term.write(Name.." verliert")
  288. sleep(1)
  289. end
  290. 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
  291. Bdraw(colors.black)
  292. term.setCursorPos(7,5)
  293. term.write(Name2.." verliert")
  294. sleep(1)
  295. end
  296.  
  297. end
  298.  
  299. --  for Px = 1,#xPosition1 do
  300. --  if xPos1 == xPosition1[Px] and yPos1 == yPosition1[Px] then
  301. --  Bdraw(colors.black)
  302. --  term.setCursorPos(7,5)
  303. --  term.write("Spieler 1 verliert")
  304. --  elseif xPos2 == xPosition2[Px] and yPos2 == yPosition2[Px] then
  305. --  Bdraw(colors.black)
  306. --  term.setCursorPos(7,5)
  307. --  term.write("Spieler 2 verliert")
  308. --  end
  309. --  end
  310. --  sleep(3)
  311. --  os.reboot()
  312.  
  313.  
  314.     end
  315.  
  316.  
  317.  
  318. end
  319.  
  320. end
  321. Bdraw(colors.black)
  322.     xPosition = {}
  323.     yPosition = {}
  324.     Pos = 1
  325.     xPos = 10
  326.     yPos = 15
  327.     e = 2
  328.     Points = 0
  329.  
  330.     while true do
  331.     xPosition[Pos] = xPos
  332.     yPosition[Pos] = yPos
  333.     term.setBackgroundColor(colors.red)
  334.     term.setCursorPos(xPos,yPos)
  335.     term.write(" ")
  336.     Timer = os.startTimer(time)
  337.     event ,key = os.pullEvent()
  338.  
  339.     if event == "key" then
  340.    
  341.     sleep(time)
  342.    
  343.    
  344. --oben
  345.     if key == 200 or key == 17 then
  346.     e = 1
  347. --rechts
  348.     elseif key == 205 or key == 32 then
  349.     e = 2
  350. --unten
  351.     elseif key == 208 or key == 31 then
  352.     e = 3
  353. --links
  354.     elseif key == 203 or key == 30 then
  355.     e = 4
  356.     end
  357.  
  358.     end
  359.    
  360.     if e == 1 then
  361.     yPos = yPos-1
  362.     elseif
  363.     e == 2 then
  364.     xPos = xPos+1
  365.     elseif
  366.     e == 3 then
  367.     yPos = yPos+1
  368.     elseif
  369.     e == 4 then
  370.     xPos = xPos-1
  371.     end
  372.     Points = math.floor((Points+1000*Pos)-(time*5)^10)
  373.     mon.setTextColor(colors.orange)
  374.     term.setTextColor(colors.orange)
  375.     mon.setBackgroundColor(colors.black)
  376.     term.setBackgroundColor(colors.black)
  377.     mon.setCursorPos(15,1)
  378.     term.setCursorPos(15,1)
  379.     mon.write(Name.." Punkte: "..Points)
  380.     term.write(Name.." Punkte: "..Points)
  381.    
  382.     mon.setBackgroundColor(colors.red)
  383.     term.setBackgroundColor(colors.red)
  384.     mon.setCursorPos(xPos,yPos)
  385.     term.setCursorPos(xPos,yPos)
  386.     mon.write(" ")
  387.     term.write(" ")
  388.     --print(xPosition[Pos])
  389.     --print(yPosition[Pos])
  390.     Pos = Pos+1
  391.     for Px = 1,#xPosition do
  392.     if xPos == xPosition[Px] and yPos == yPosition[Px] or xPos == xMax+1 or yPos == yMax+1 or xPos == 0 or yPos == 0 then
  393.     Bdraw(colors.black)
  394.     term.setCursorPos(7,5)
  395.     term.write("Game over")
  396.     term.setCursorPos(7,6)
  397.     term.write("Score: "..Points)
  398.     file = fs.open("highscore", "w")
  399.     file.writeLine(Name)
  400.     file.writeLine(Points)
  401.     file.close()
  402.  
  403.     sleep(3)
  404.     os.reboot()
  405.     end
  406.     end
  407.     end
  408.  
  409.  
  410.  
  411.  
  412.  
  413. elseif key == 28 and i == 2 then
  414. print("Optionen")
  415. elseif key == 28 and i == 3 then
  416. print("Anleitung")
  417. elseif key == 28 and i == 4 then
  418. os.reboot()
  419. end
  420.  
  421.     end
  422. end
  423.  
  424. startup()
  425. Bdraw(colors.black)
  426. menue()
Advertisement
Add Comment
Please, Sign In to add comment