xXm0dzXx

Easiest Game Ever

Nov 4th, 2012
1,144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.85 KB | None | 0 0
  1. local x,y = term.getSize()
  2. os.pullEvent = os.pullEventRaw
  3.  
  4. local function cPrint(text)
  5. x2,y2 = term.getCursorPos()
  6. term.setCursorPos(math.ceil((x / 2) - (text:len() / 2)), y2)
  7. write(text.. "\n")
  8. end
  9.  
  10. term.setBackgroundColour( colors.gray )
  11. term.clear()
  12. term.setCursorPos(1,3)
  13. cPrint("The Hardest Game Ever")
  14. cPrint("Level 1")
  15. sleep(1)
  16. term.clear()
  17.  
  18. local maps = {
  19. ["map_0"] = {
  20. "",
  21. "",
  22. "XXXXXXXXX",
  23. "XZBBBBBRX",
  24. "XXXXXXXXX",
  25. }
  26. }
  27.  
  28. local currentMap = ""
  29. local charX = 0
  30. local charY = 0
  31. local colorSet = {
  32. ["X"] = colors.lightGray,
  33. ["B"] = colors.black,
  34. ["Z"] = colors.cyan,
  35. ["R"] = colors.red,
  36. }
  37.  
  38. function loadmap( map, offset )
  39. term.setBackgroundColour( colors.gray )
  40. term.clear()
  41. local theMap = maps[map]
  42. for i=1,#theMap do
  43. for iv=1,#(theMap[i]) do
  44. local pixel = string.sub( theMap[i], iv, iv )
  45. if colorSet[pixel] then
  46. paintutils.drawPixel( 3+iv, offset+i, colorSet[pixel] )
  47. if map ~= currentMap then --If first time loading then...
  48. if pixel == "Z" then
  49. charX = 3+iv
  50. charY = 3+i
  51. end
  52. end
  53. end
  54. end
  55. end
  56.  
  57. if map ~= currentMap then
  58. currentMap = map
  59. end
  60. end
  61.  
  62. function redraw( char, offset )
  63. loadmap( "map_0", offset )
  64. term.setCursorPos(charX, charY)
  65. term.setBackgroundColour( colors.black )
  66. term.setTextColour( colors.lime )
  67. write( char )
  68. end
  69.  
  70. redraw( ">", 3 )
  71.  
  72. repeat
  73. local event, key = os.pullEvent("key")
  74. until key == keys.right
  75.  
  76. charX = charX +1
  77. redraw( ">", 3 )
  78. sleep(0.5)
  79. redraw( "v", 3 )
  80. sleep(0.5)
  81. redraw( "v", 2 )
  82. term.setCursorPos( 1, y )
  83. term.setBackgroundColour( colors.black )
  84. term.clearLine()
  85. term.setTextColour( colors.yellow )
  86. write("Press Ctrl to access menu")
  87. term.setCursorPos( x-#("Ln 957"), y )
  88. write("Ln 957")
  89. term.setTextColour( colors.white )
  90. term.setCursorPos( x-#("957"), y )
  91. write("957")
  92. sleep(0.5)
  93.  
  94. for i=charY, y-3 do
  95. redraw( "v", 1 )
  96. term.setCursorPos( 1, y )
  97. term.setBackgroundColour( colors.black )
  98. term.clearLine()
  99. term.setTextColour( colors.yellow )
  100. write("Press Ctrl to access menu")
  101. term.setCursorPos( x-#("Ln 957"), y )
  102. write("Ln 957")
  103. term.setTextColour( colors.white )
  104. term.setCursorPos( x-#("957"), y )
  105. write("957")
  106.  
  107. term.setCursorPos( 1, y-1 )
  108. term.setBackgroundColour( colors.black )
  109. term.clearLine()
  110. term.setTextColour( colors.white )
  111. write("end")
  112.  
  113. charY = charY +1
  114. sleep(0.5)
  115. end
  116.  
  117. term.setCursorBlink( true )
  118. term.setCursorPos( 1, y-1 )
  119. term.clearLine()
  120. textutils.slowPrint("error(\"Hacked\")")
  121. term.setCursorPos( 16, y-1 )
  122. sleep(1)
  123. term.setCursorPos( 1, y )
  124. term.clearLine()
  125. print( shell.getRunningProgram().. ":957: Hacked" )
  126. term.setCursorBlink( false )
  127. sleep(1)
  128. term.setCursorBlink( true )
  129. write("> ")
  130. textutils.slowPrint("lua")
  131. term.setCursorPos( 6, y-1 )
  132. sleep(1)
  133. print("\nInteractive Lua prompt.")
  134. print("Call exit() to exit.")
  135. write("lua> ")
  136. sleep(1)
  137. textutils.slowPrint("os = nil")
  138. term.setCursorBlink( false )
  139. sleep(1)
  140. print("error")
  141. sleep(3)
  142. for i=1,50 do
  143. for i=1,20 do
  144. term.setCursorPos( math.random( x ), math.random( y ) )
  145. local color = math.random( 1, 5 )
  146. if color == 1 then
  147. term.setTextColour( colors.white )
  148. elseif color == 2 then
  149. term.setTextColour( colors.green )
  150. elseif color == 3 then
  151. term.setTextColour( colors.red )
  152. elseif color == 4 then
  153. term.setTextColour( colors.lime )
  154. else
  155. term.setTextColour( colors.blue )
  156. end
  157. write("bios:32: Attempt to call nil")
  158. end
  159.  
  160. sleep(0)
  161. end
  162.  
  163. term.setBackgroundColour( colors.blue )
  164. term.clear()
  165. term.setBackgroundColour( colors.white )
  166. term.setTextColour( colors.blue )
  167. term.setCursorPos(1, 4)
  168. cPrint(" Error ")
  169. term.setCursorPos(1, 6)
  170. term.setBackgroundColour( colors.blue )
  171. term.setTextColour( colors.black )
  172. cPrint("Your computer has crashed because")
  173. cPrint("you never got a antivirus, but hey")
  174. cPrint("atleast we made you your own realistic")
  175. cPrint("BSoD, I don't know how long i'll have to")
  176. cPrint("type to make this as realistic as possible")
  177. print()
  178. sleep(3)
  179. cPrint("Press any key to continue")
  180.  
  181. repeat
  182. local event, key = os.pullEvent("key")
  183. until key ~= 1
  184. print( "bios:32:Attempt to call nil (os.pullEvent)" )
  185. sleep(1)
  186. print("LOL JK :3")
  187. repeat
  188. write("> ")
  189. until read() ~= ""
  190. print("Hah! The virus is still going on...")
  191. write("> ")
  192. sleep(1)
  193. textutils.slowPrint( shell.getRunningProgram() )
  194. while true do
  195. for i=1,50 do
  196. for i=1,20 do
  197. term.setCursorPos( math.random( x ), math.random( y ) )
  198. local color = math.random( 1, 5 )
  199. if color == 1 then
  200. term.setTextColour( colors.white )
  201. elseif color == 2 then
  202. term.setTextColour( colors.green )
  203. elseif color == 3 then
  204. term.setTextColour( colors.red )
  205. elseif color == 4 then
  206. term.setTextColour( colors.lime )
  207. else
  208. term.setTextColour( colors.blue )
  209. end
  210. write("bios:32: Attempt to call nil")
  211. end
  212.  
  213. sleep(0)
  214. end
  215. end
Advertisement
Add Comment
Please, Sign In to add comment