Guest User

CC Beams Update Request

a guest
Sep 27th, 2013
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.53 KB | None | 0 0
  1. m = "1"
  2. local pX = 10
  3. local pY = 5
  4. local sc = 0
  5. run = true
  6. beam = math.max(math.random(1,20),0)
  7. local icolor = colors.white
  8. local pcolor = colors.blue
  9. local bcolor = colors.red
  10. local reset = colors.black
  11. term.setBackgroundColor(colors.brown)
  12. term.clear()
  13. term.setCursorPos(pX,pY)
  14. term.setBackgroundColor(pcolor)
  15. print(" ")
  16. term.setBackgroundColor(colors.brown)
  17.  
  18. i = paintutils.loadImage("sprites/world/bworld")
  19. paintutils.drawImage(i,1,1)
  20. term.setCursorPos(1,5)
  21.  iX = math.max(math.random(1,40),0)
  22. iY = math.max(math.random(5,17),0)
  23. term.setTextColor(colors.black)
  24. term.setCursorPos(iX,iY)
  25. term.setBackgroundColor(icolor)
  26. print "I"
  27.  i2X = math.max(math.random(1,40),0)
  28. i2Y = math.max(math.random(5,17),0)
  29. term.setTextColor(colors.black)
  30.  term.setCursorPos(i2X,i2Y)
  31. term.setBackgroundColor(icolor)
  32. print "I"
  33. term.setBackgroundColor(reset)
  34. term.setTextColor(colors.white)
  35. term.setBackgroundColor(colors.brown)
  36. term.setCursorPos(1,1)
  37. print "--------------------------------------------------"
  38. print "|                Wellcome to Beams:              |"
  39. print("|                  Score: " ..sc)
  40. print "--------------------------------------------------"
  41. term.setCursorPos(50,3)
  42. print "|"
  43.  
  44. function db()
  45. i = paintutils.loadImage("sprites/world/bworld")
  46. paintutils.drawImage(i,1,1)
  47. end
  48.  
  49. function reitem()
  50. term.setTextColor(colors.black)
  51. term.setCursorPos(iX,iY)
  52. term.setBackgroundColor(icolor)
  53. print "I"
  54. term.setTextColor(colors.black)
  55.  term.setCursorPos(i2X,i2Y)
  56. term.setBackgroundColor(icolor)
  57. print "I"
  58. end
  59.  
  60. function rei()
  61.  iX = math.max(math.random(1,40),0)
  62. iY = math.max(math.random(5,17),0)
  63. term.setTextColor(colors.black)
  64. term.setCursorPos(iX,iY)
  65. term.setBackgroundColor(icolor)
  66. print "I"
  67.  i2X = math.max(math.random(1,40),0)
  68. i2Y = math.max(math.random(5,17),0)
  69. term.setTextColor(colors.black)
  70.  term.setCursorPos(i2X,i2Y)
  71. term.setBackgroundColor(icolor)
  72. print "I"
  73. end
  74.  
  75. function drawLabel()
  76. term.setBackgroundColor(reset)
  77. term.setTextColor(colors.white)
  78. term.setBackgroundColor(colors.brown)
  79. term.setCursorPos(1,1)
  80. print "--------------------------------------------------"
  81. print "|                Wellcome to Beams:              |"
  82. print("|                  Score: " ..sc)
  83. print "--------------------------------------------------"
  84. term.setCursorPos(50,3)
  85. print "|"
  86. term.setCursorPos(1,5)
  87. term.setTextColor(colors.black)
  88. end
  89.  
  90.  
  91. function drawChar()
  92. term.setCursorPos(pX,pY)
  93. term.setBackgroundColor(pcolor)
  94. print(" ")
  95. term.setBackgroundColor(reset)
  96. end
  97.  
  98. function check()
  99. if pX == iX and pY == iY then
  100. term.setCursorPos(iX,iY)
  101. term.setBackgroundColor(reset)
  102. print " "
  103. term.setCursorPos(pX,pY)
  104. term.setBackgroundColor(colors.blue)
  105. print " "
  106. sc = sc + 10
  107. drawLabel()
  108. sleep(0.5)
  109. rei()
  110.  elseif pX == i2X and pY == i2Y then
  111.  term.setCursorPos(i2X,i2Y)
  112. term.setBackgroundColor(reset)
  113. print " "
  114. term.setCursorPos(pX,pY)
  115. term.setBackgroundColor(colors.blue)
  116. print " "
  117. sc = sc + 10
  118. drawLabel()
  119. sleep(0.5)
  120. rei()
  121. end
  122. end
  123.  
  124. function beeam()
  125. ranb = math.max(math.random(1,10),0)
  126. if ranb == 3 then
  127. beam = math.max(math.random(5,17),0)
  128. term.setCursorPos(54,beam)
  129. sleep(0.1)
  130. term.setCursorPos(pX,pY)
  131. term.setBackgroundColor(colors.blue)
  132. print " "
  133. be = beam + 1
  134. term.setCursorPos(1,1)
  135. term.setTextColor(colors.white)
  136. term.setBackgroundColor(colors.brown)
  137. print("INCOMEING Line:  "..beam)
  138. sleep(1.2)
  139. term.setCursorPos(54,beam)
  140. term.setBackgroundColor(colors.red)
  141. term.setCursorPos(54,beam)
  142. print " "
  143. term.setBackgroundColor(colors.red)
  144. print("================================================")
  145. sleep(0.2)
  146. term.setCursorPos(pX,pY)
  147. term.setBackgroundColor(colors.blue)
  148. print " "
  149. if be == pY then
  150. term.setBackgroundColor(colors.black)
  151. term.clear()
  152. term.setCursorPos(10,5)
  153. term.setTextColor(colors.yellow)
  154. print "Game Over"
  155. term.setCursorPos(10,5)
  156. print("Score: "..sc)
  157. sleep(2)
  158. run = false
  159. return
  160. else
  161. term.setBackgroundColor(colors.brown)
  162. term.clear()
  163. db()
  164. drawLabel()
  165. term.setCursorPos(pX,pY)
  166. term.setBackgroundColor(colors.blue)
  167. print " "
  168.  
  169.  term.setCursorPos(iX,iY)
  170. term.setBackgroundColor(icolor)
  171. print "I"
  172.  term.setCursorPos(i2X,i2Y)
  173. term.setBackgroundColor(icolor)
  174. print "I"
  175. move()
  176. term.setCursorPos(pX,pY)
  177. term.setBackgroundColor(colors.blue)
  178. print " "
  179. return move()
  180. end
  181. end
  182. end
  183.  
  184.  
  185. function move()
  186. while run == true do
  187. local event, button = os.pullEventRaw("key")
  188. term.setTextColor(colors.white)
  189. term.setBackgroundColor(colors.black)
  190.  
  191.     if button == 200 then --up
  192.      if pY == 5 then
  193.     term.setCursorPos(1,1)
  194.     print "Cantmove"
  195.       event = os.pullEvent("key")
  196.      drawLabel()
  197.       move()
  198.      else
  199.      sleep(0.001)
  200. db()
  201. reitem()
  202. drawLabel()
  203.      pY = pY - 1
  204.     print " "
  205.    
  206.     drawChar()
  207.     check()
  208.     beeam()
  209.     move()
  210.     end
  211.     end
  212.    
  213.     if button == 208 then -- down
  214.      if pY == 18 then
  215.      term.setCursorPos(1,1)
  216.     print "Cantmove"
  217.       event = os.pullEvent("key")
  218.      drawLabel()
  219.       move()
  220.      else
  221.      sleep(0.001)
  222.      db()
  223. reitem()
  224. drawLabel()
  225.         pY = pY + 1
  226.        
  227.         check()
  228.         beeam()
  229. drawChar()
  230. move()
  231.     end
  232.     end
  233.    
  234.     if button == 203 then -- left
  235.      if pX == 1 then
  236.      term.setCursorPos(1,1)
  237.     print "Cantmove"
  238.      event = os.pullEvent("key")
  239.      drawLabel()
  240.      move()
  241.      else
  242.      sleep(0.001)
  243.      pX = pX - 1
  244. db()
  245. reitem()
  246. drawLabel()
  247.      check()
  248.          beeam()
  249. drawChar()
  250. move()
  251.     end
  252.     end
  253.    
  254.     if button == 205 then -- right
  255.      if pX == 51 then
  256.      term.setCursorPos(1,1)
  257.     print "Cantmove"
  258.       event = os.pullEvent("key")
  259.      drawLabel()
  260.      move()
  261.      else
  262.      sleep(0.001)
  263. db()
  264. reitem()
  265. drawLabel()
  266.      pX = pX + 1
  267.    
  268.      check()
  269.       beeam()
  270.     drawChar()
  271.     move()
  272.     end
  273.     end
  274. end
  275. end
  276. move()
Advertisement
Add Comment
Please, Sign In to add comment