MatthewGB

BoxShooter

May 3rd, 2014
356
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.22 KB | None | 0 0
  1. mpa = false
  2. if peripheral.isPresent("top") and peripheral.getType("top") == "modem" then
  3. print("Modem found; you can play multiplayer!")
  4. rednet.open("top")
  5. mpa = true
  6. elseif peripheral.isPresent("back") and peripheral.getType("back") == "modem" then
  7. print("Modem found; you can play multiplayer!")
  8. rednet.open("back")
  9. mpa = true
  10. elseif peripheral.isPresent("right") and peripheral.getType("right") == "modem" then
  11. print("Modem found; you can play multiplayer!")
  12. rednet.open("right")
  13. mpa = true
  14. elseif peripheral.isPresent("left") and peripheral.getType("left") == "modem" then
  15. print("Modem found; you can play multiplayer!")
  16. rednet.open("left")
  17. mpa = true
  18. else
  19. print("No modems found; multiplayer is unavailable")
  20. end
  21. if mpa then
  22. spormp = read("SP or MP? ")
  23. if spormp == "MP" or spormp == "Mp" or spormp == "mp" then
  24. mpa = true
  25. else
  26. mpa = false
  27. end
  28. end
  29. sleep(1)
  30. shell.run("rm mainimg")
  31. shell.run("pastebin get s0K2qDds mainimg")
  32. shell.run("rm menuimg")
  33. shell.run("pastebin get s0K2qDds menuing")
  34. running = true
  35. ptmainimg = "mainimg"
  36. ptmenuimg = "menuing"
  37. charge = 1
  38. maxcharge = 16
  39. lives = 3
  40. score = 0
  41. gs = 1
  42. ex = 0
  43. ey = 0
  44. bx = 0
  45. by = 0
  46. ba = false
  47. et = 0
  48. img = paintutils.loadImage(ptmainimg)
  49. paintutils.drawImage(img,1,1)
  50. while running == true do
  51. tid = os.startTimer(0.25)
  52. evt, v1, v2, v3 = os.pullEvent()
  53. if gs == 0 then
  54. paintutils.drawPixel(2, charge+1, 44)
  55. paintutils.drawPixel(3, charge+1, 44)
  56. if charge >= maxcharge then
  57. ready = true
  58. else
  59. charge = charge + 1
  60. end
  61. if evt == "rednet_message" then
  62. msg1 = v2
  63. msg2 = v2
  64. typeofcmd = string.sub(msg1, 1, 1)
  65. if typeofcmd == "1" then
  66. ey = tonumber(string.sub(msg2, 2, 3))
  67. print(ey)
  68. ey = 2
  69. ex = 4
  70. end
  71. elseif evt == "mouse_click" then
  72. if charge == maxcharge then
  73. paintutils.drawLine(2, 2, 2, 17, 64)
  74. paintutils.drawLine(3, 2, 3, 17, 64)
  75. charge = 1
  76. paintutils.drawPixel(bx, by, 55)
  77. bx = 4
  78. if v3 < 2 then
  79. v3 = 3
  80. end
  81. if v3 > 17 then
  82. v3 = 17
  83. end
  84. rednet.broadcast("1"..tostring(v3))
  85. by = v3
  86. end
  87. end
  88. v1 = v1 + 1
  89. if v1 == tid then
  90. term.setCursorPos(2,1)
  91. write("Lives: ")
  92. i = 0
  93. while i < lives do
  94. write("*")
  95. i = i + 1
  96. end
  97. while i < 5 do
  98. write(" ")
  99. i = i + 1
  100. end
  101. term.setCursorPos(35,1)
  102. write("Score: "..tostring(score))
  103. et = et + 1
  104. if et > 45 then
  105. et = 0
  106. ey = math.random(2,17)
  107. ex = 48
  108. end
  109. if ex == 4 then
  110. lives = lives - 1
  111. ex = 0
  112. ey = 0
  113. end
  114. if ey == by then
  115. if ex == bx or ex == bx+1 or ex == bx-1 then
  116. score = score + 1
  117. paintutils.drawPixel(ex, ey, 64)
  118. sleep(0.3)
  119. paintutils.drawPixel(ex, ey+1, 2)
  120. paintutils.drawPixel(ex, ey-1, 2)
  121. paintutils.drawPixel(ex+1, ey, 2)
  122. paintutils.drawPixel(ex-1, ey, 2)
  123. sleep(0.3)
  124. paintutils.drawPixel(ex, ey+2, 2)
  125. paintutils.drawPixel(ex, ey-2, 2)
  126. paintutils.drawPixel(ex+2, ey, 2)
  127. paintutils.drawPixel(ex-2, ey, 2)
  128. paintutils.drawPixel(ex-1, ey+1, 2)
  129. paintutils.drawPixel(ex+1, ey-1, 2)
  130. paintutils.drawPixel(ex-1, ey-1, 2)
  131. paintutils.drawPixel(ex+1, ey+1, 2)
  132. sleep(0.3)
  133. paintutils.drawPixel(ex, ey, 30)
  134. sleep(0.3)
  135. paintutils.drawPixel(ex, ey+1, 30)
  136. paintutils.drawPixel(ex, ey-1, 30)
  137. paintutils.drawPixel(ex+1, ey, 30)
  138. paintutils.drawPixel(ex-1, ey, 30)
  139. sleep(0.3)
  140. paintutils.drawPixel(ex, ey+2, 30)
  141. paintutils.drawPixel(ex, ey-2, 30)
  142. paintutils.drawPixel(ex+2, ey, 30)
  143. paintutils.drawPixel(ex-2, ey, 30)
  144. paintutils.drawPixel(ex-1, ey+1, 30)
  145. paintutils.drawPixel(ex+1, ey-1, 30)
  146. paintutils.drawPixel(ex-1, ey-1, 30)
  147. paintutils.drawPixel(ex+1, ey+1, 30)
  148. ex = 0
  149. ey = 0
  150. bx = 0
  151. by = 0
  152. end
  153. end
  154. paintutils.drawPixel(ex, ey, 30)
  155. ex = ex - 1
  156. paintutils.drawPixel(ex, ey, 2)
  157. paintutils.drawPixel(bx, by, 30)
  158. bx = bx + 1
  159. paintutils.drawPixel(bx, by, 99)
  160. end
  161. elseif gs == 1 then
  162. term.clear()
  163. img = paintutils.loadImage(ptmainimg)
  164. paintutils.drawImage(img,1,1)
  165. if evt == "mouse_click" then
  166. gs = 0
  167. end
  168. end -- GS
  169. end -- Main while loop
Advertisement
Add Comment
Please, Sign In to add comment