Advertisement
Alyssa

-- Tetris, NOT FINISHED --

Mar 27th, 2012
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.48 KB | None | 0 0
  1. wt = 0
  2. width, height = term.getSize()
  3. os.pullEvent = os.pullEventRaw
  4. function blockstart()
  5. -- Telling it to draw the shape
  6. term.setCursorPos(spw1, sph1)
  7. write("#")
  8. term.setCursorPos(spw2, sph2)
  9. write("#")
  10. term.setCursorPos(spw3, sph3)
  11. write("#")
  12. term.setCursorPos(spw4, sph4)
  13. write("#")
  14. end
  15. function newblock()
  16. --Setting Rotation to 1
  17. rot = 1
  18. -- Shape
  19. local bshape = math.ceil(math.random(0,3))
  20. if bshape == 0 then
  21. shape = "square"
  22. end
  23. if bshape == 1 then
  24. shape = "line"
  25. end
  26. if bshape == 2 then
  27. shape = "l"
  28. end
  29. if bshape == 3 then
  30. shape="hill"
  31. end
  32. startposw = width/2
  33. startposh = 1
  34. -- setting what shapes look like
  35. if shape == "hill" then
  36. spw1 = startposw
  37. spw2 = spw1 -1
  38. spw3 = spw1 +1
  39. spw4 = spw1
  40. sph1 = startposh
  41. sph2 = sph1 -1
  42. sph3 = sph1 -1
  43. sph4 = sph1 -1
  44. blockstart()
  45. end
  46. if shape == "l" then
  47. spw1 = startposw
  48. spw2 = spw1
  49. spw3 = spw1
  50. spw4 = spw3 +1
  51. sph1 = startposh
  52. sph2 = sph1 -1
  53. sph3 = sph2 -1
  54. sph4 = sph3
  55. blockstart()
  56. end
  57. if shape == "line" then
  58. spw1 = startposw
  59. spw2 = spw1
  60. spw3 = spw1
  61. spw4 = spw1
  62. sph1 = startposh
  63. sph2 = sph1 -1
  64. sph3 = sph2 -1
  65. sph4 = sph3 -1
  66. blockstart()
  67. end
  68. if shape == "square" then
  69. spw1 = startposw
  70. spw2 = spw1 +1
  71. spw3 = spw1
  72. spw4 = spw2
  73. sph1 = startposh
  74. sph2 = sph1
  75. sph3 = sph1 -1
  76. sph4 = sph1 -1
  77. blockstart()
  78. end
  79. end
  80. function updateblock()
  81. if wt ~= 4 then
  82. wt = wt +1
  83. end
  84. if wt == 4 then
  85. sph1 = sph1 -1
  86. sph2 = sph2 -1
  87. sph3 = sph3 -1
  88. sph4 = sph4 -1
  89. blockstart()
  90. end
  91. function rotl()
  92. if rot == 1 then
  93. rot = 4
  94. if shape == "hill" then
  95. spw3 = spw1
  96. spw1 = spw2
  97. spw4 = spw4
  98. spw2 = spw4
  99. sph3 = sph1
  100. sph1 = sph2
  101. sph4 = sph4
  102. sph2 = sph4 -1
  103. end
  104. if shape == "square" then
  105. end
  106. if shape == "line" then
  107. spw3 = spw4 -1
  108. spw2 = spw3 -1
  109. spw1 = spw2 -1
  110. spw4 = spw4
  111. sph1 = sph4
  112. sph2 = sph4
  113. sph3 = sph4
  114. sph4 = sph4
  115. end
  116. if shape == "l" then
  117. sph4 = sph2
  118. sph2 = sph3
  119. sph1 = sph3
  120. sph3 = sph3
  121. spw2 = spw3 -1
  122. spw1 = spw2 -1
  123. spw4 = spw3
  124. spw3 = spw3
  125. end
  126. end
  127. if rot == 4 then
  128. rot = 3
  129. if shape == "hill" then
  130. spw3 = spw1
  131. spw1 = spw2
  132. spw4 = spw4
  133. spw2 = spw4 +1
  134. sph3 = sph1
  135. sph1 = sph2
  136. sph2 = sph4
  137. sph4 = sph4
  138. end
  139. if shape == "square" then
  140. end
  141. if shape == "line" then
  142. spw1 = spw4
  143. spw2 = spw4
  144. spw3 = spw4
  145. spw4 = spw4
  146. sph3 = sph4 -1
  147. sph2 = sph3 -1
  148. sph1 = sph2 -1
  149. sph4 = sph4
  150. end
  151. if shape == "l" then
  152. spw4 = spw4
  153. spw3 = spw4 +1
  154. spw2 = spw3
  155. spw1 = spw3
  156. sph4 = sph4
  157. sph3 = sph4
  158. sph2 = sph4 -1
  159. sph1 = sph2 -1
  160. end
  161. end
  162. if rot == 3
  163. rot = 2
  164. if shape == "l" then
  165. sph4 = sph2
  166. sph2 = sph3
  167. sph1 = sph3
  168. sph3 = sph3
  169. spw2 = spw3 +1
  170. spw1 = spw2 +1
  171. spw4 = spw4
  172. spw3 = spw3
  173. end
  174. if shape == "square" then
  175. end
  176. if shape == "line" then
  177. spw3 = spw4 +1
  178. spw2 = spw3 +1
  179. spw1 = spw2 +1
  180. spw4 = spw4
  181. sph3 = sph4
  182. sph2 = sph4
  183. sph1 = sph4
  184. sph4 = sph4
  185. end
  186. if shape == "hill" then
  187. spw3 = spw1
  188. spw1 = spw2
  189. spw2 = spw4
  190. spw4 = spw4
  191. sph3 = sph1
  192. sph1 = sph4
  193. sph2 = sph4 +1
  194. sph4 = sph4
  195. end
  196. end
  197. if rot == 2 then
  198. rot = 1
  199. if shape == "square" then
  200. end
  201. if shape == "line" then
  202. spw1 = spw4
  203. spw2 = spw4
  204. spw3 = spw4
  205. spw4 = spw4
  206. spw3 = spw4 +1
  207. spw2 = spw3 +1
  208. spw1 = spw2 +1
  209. end
  210. if shape == "hill" then
  211. spw3 = spw1
  212. spw1 = spw2
  213. spw2 = spw4 -1
  214. spw4 = spw4
  215. sph3 = sph4
  216. sph2 = sph4
  217. sph1 = sph4 +1
  218. end
  219. if shape == "l" then
  220.  
  221. end
  222. end
  223. function update()
  224. updateblock()
  225. os.startTimer(.1)
  226. end
  227. timer1 = os.startTimer(.1)
  228. while true do
  229. event , varx = os.pullEvent()
  230. if event == "timer"
  231. if varx == "timer1" then
  232. update()
  233. end
  234. end
  235. if event == "char" then
  236. if varx == "a" then
  237. rotl()
  238. end
  239. end
  240. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement