Advertisement
Guest User

t

a guest
Aug 1st, 2014
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.20 KB | None | 0 0
  1. rednet.open("top")
  2. mon = peripheral.find("monitor")
  3. mon.clear()
  4. mon.setTextScale(1)
  5. mon.setBackgroundColor(colors.black)
  6. local vie = 0
  7. local xjp, yjp = 0, 0
  8.  
  9. function menu1()
  10. mon.clear()
  11. mon.setTextScale(2)
  12. mon.setCursorPos(1,5)
  13. mon.write("------------------------------------")
  14. mon.setCursorPos(16,2)
  15. mon.write("LuaMan")
  16. mon.setCursorPos(10,4)
  17. mon.write("Le Jeu CodåA9 En Lua ")
  18. mon.setCursorPos(4,9)
  19. mon.write("> Nouvelle partie.")
  20. mon.setCursorPos(4,12)
  21. mon.write("  Infos.")
  22. end
  23.  
  24. function menu2()
  25. mon.clear()
  26. mon.setTextScale(2)
  27. mon.setCursorPos(1,5)
  28. mon.write("-------------------------------------")
  29. mon.setCursorPos(16,2)
  30. mon.write("LuaMan")
  31. mon.setCursorPos(10,4)
  32. mon.write("Le Jeu CodåA9 En Lua ")
  33. mon.setCursorPos(4,9)
  34. mon.write("  Nouvelle partie.")
  35. mon.setCursorPos(4,12)
  36. mon.write("> Infos.")
  37. end
  38.  
  39. function menuchoix()
  40. menu1()
  41. local q = 0
  42. while q == 0 do
  43. id, cm = rednet.receive()
  44. if cm == "up" then
  45. menu1()
  46. mchoix = 1
  47. elseif cm == "down" then
  48. menu2()
  49. mchoix = 2
  50. elseif cm == "d" then
  51. q = 1
  52. if mchoix == 1 then
  53. partie()
  54. elseif mchoix == 2 then
  55. infos()
  56. end
  57. end
  58. end
  59. end
  60.  
  61. function infos()
  62.  
  63. end
  64.  
  65. function saut()
  66. yjp = yjp - 1
  67. sleep(0.1)
  68. aff()
  69. yjp = yjp - 1
  70. sleep(0.1)
  71. aff()
  72. yjp = yjp - 1
  73. sleep(0.1)
  74. aff()
  75. yjp = yjp + 1
  76. sleep(0.1)
  77. aff()
  78. yjp = yjp + 1
  79. sleep(0.1)
  80. aff()
  81. yjp = yjp + 1
  82. sleep(0.1)
  83. aff()
  84. end
  85.  
  86. function sautd()
  87. yjp = yjp - 1
  88. sleep(0.1)
  89. aff()
  90. yjp = yjp - 1
  91. sleep(0.1)
  92. aff()
  93. yjp = yjp - 1
  94. sleep(0.1)
  95. aff()
  96. yjp = yjp - 1
  97. sleep(0.1)
  98. aff()
  99. xjp = xjp + 1
  100. sleep(0.1)
  101. aff()
  102. xjp = xjp + 1
  103. sleep(0.1)
  104. aff()
  105. xjp = xjp + 1
  106. sleep(0.1)
  107. aff()
  108. xjp = xjp + 1
  109. sleep(0.1)
  110. aff()
  111. xjp = xjp + 1
  112. sleep(0.1)
  113. aff()
  114. yjp = yjp + 1
  115. sleep(0.1)
  116. aff()
  117. yjp = yjp + 1
  118. sleep(0.1)
  119. aff()
  120. yjp = yjp + 1
  121. sleep(0.1)
  122. aff()
  123. yjp = yjp + 1
  124. sleep(0.1)
  125. aff()
  126. end
  127.  
  128. function sautg()
  129. yjp = yjp - 1
  130. sleep(0.1)
  131. aff()
  132. yjp = yjp - 1
  133. sleep(0.1)
  134. aff()
  135. yjp = yjp - 1
  136. sleep(0.1)
  137. aff()
  138. yjp = yjp - 1
  139. sleep(0.1)
  140. aff()
  141. xjp = xjp - 1
  142. sleep(0.1)
  143. aff()
  144. xjp = xjp - 1
  145. sleep(0.1)
  146. aff()
  147. xjp = xjp - 1
  148. sleep(0.1)
  149. aff()
  150. xjp = xjp - 1
  151. sleep(0.1)
  152. aff()
  153. xjp = xjp - 1
  154. sleep(0.1)
  155. aff()
  156. yjp = yjp + 1
  157. sleep(0.1)
  158. aff()
  159. yjp = yjp + 1
  160. sleep(0.1)
  161. aff()
  162. yjp = yjp + 1
  163. sleep(0.1)
  164. aff()
  165. yjp = yjp + 1
  166. sleep(0.1)
  167. aff()
  168. end
  169.  
  170. function joueur()
  171. local yjp1 = yjp - 1
  172. local yjp2 = yjp1 - 1
  173. local yjp3 = yjp2 - 1
  174. mon.setCursorPos(xjp,yjp)
  175. mon.write(" /l ")
  176. mon.setCursorPos(xjp,yjp1)
  177. mon.write(" <| ")
  178. mon.setCursorPos(xjp,yjp2)
  179. mon.write(" ('>  ")
  180. mon.setCursorPos(xjp,yjp3)
  181. mon.write(" ))) ")
  182. end
  183.  
  184.  
  185. function ecran()
  186. mon.setCursorPos(1,3)
  187. mon.write("-----------------------------------------------------------------------")
  188. mon.setCursorPos(1,27)
  189. mon.write("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|___|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
  190. mon.setCursorPos(63,2)
  191. mon.write("Vies : "..vie)
  192. end
  193.  
  194. function aff()
  195. mon.clear()
  196. ecran()
  197. joueur()
  198. end
  199.  
  200. function gameover()
  201. local tour = 0
  202. local tour2 = 0
  203. mon.clear()
  204. while tour ~= 5 do
  205. sleep(0.5)
  206. mon.setCursorPos(26,17)
  207. mon.write("Game Over")
  208. sleep(0.5)
  209. mon.clear()
  210. tour = tour + 1
  211. end
  212. while tour2 ~= 3 do
  213. mon.setCursorPos(26,17)
  214. mon.write("Vie : "..vie)
  215. sleep(0.5)
  216. mon.clear()
  217. sleep(0.5)
  218. tour2 = tour2 + 1
  219. end
  220. vie = vie - 1
  221. mon.setCursorPos(26,17)
  222. mon.write("Vie : "..vie)
  223. sleep(0.5)
  224. mon.clear()
  225. sleep(0.5)
  226. mon.setCursorPos(26,17)
  227. mon.write("Vie : "..vie)
  228. sleep(2)
  229. if vie == 0 then
  230. partiefini()
  231. else
  232. xjp, yjp = 3, 26
  233. aff()
  234. end
  235. end
  236.  
  237. function partiefini()
  238. mon.clear()
  239. mon.setCursorPos(26,17)
  240. mon.write("Partie terminåA9e !!")
  241. menu()
  242. end
  243.  
  244. function mort()
  245. if xjp > 29 and xjp < 34 and yjp == 26 then
  246. gameover()
  247. end
  248. end
  249.  
  250. function info()
  251. print(xjp..", "..yjp)
  252. end
  253.  
  254. function partie()
  255. vie = 3
  256. xjp, yjp = 3, 26
  257. aff()
  258. while true do
  259. id, msg = rednet.receive()
  260. if msg == "up" then
  261. saut()
  262. info()
  263. mort()
  264. elseif msg == "g" then
  265. xjp = xjp - 1
  266. info()
  267. mort()
  268. elseif msg == "d" then
  269. xjp = xjp + 1
  270. info()
  271. mort()
  272. elseif msg == "upg" then
  273. sautg()
  274. info()
  275. mort()
  276. elseif msg == "upd" then
  277. sautd()
  278. info()
  279. mort()
  280. elseif msg == "tp" then
  281. id, xco = rednet.receive()
  282. id, yco = rednet.receive()
  283. print(xco.." "..yco)
  284. xjp = xco
  285. yjp = yco
  286. aff()
  287. end
  288. aff()
  289. end
  290. end
  291.  
  292. menuchoix()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement