Advertisement
xerpi

Untitled

Apr 4th, 2011
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.81 KB | None | 0 0
  1. -----------------------NIVELES.LUA
  2. --(TODO VACIO XD)
  3.  
  4. nivel={
  5. {--1
  6. {"e","e","e","e","e","e","e","e"},
  7. {"e","e","e","e","e","e","e","e"},
  8. {"e","e","e","e","e","e","e","e"},
  9. {"e","e","e","e","e","e","e","e"},
  10. {"e","e","e","e","e","e","e","e"},
  11. {"e","e","e","e","e","e","e","e"},
  12. {"e","e","e","e","e","e","e","e"},
  13. {"e","e","e","e","e","e","e","e"}
  14. },
  15. {--2
  16. {"e","e","e","e","e","e","e","e"},
  17. {"e","e","e","e","e","e","e","e"},
  18. {"e","e","e","e","e","e","e","e"},
  19. {"e","e","e","e","e","e","e","e"},
  20. {"e","e","e","e","e","e","e","e"},
  21. {"e","e","e","e","e","e","e","e"},
  22. {"e","e","e","e","e","e","e","e"},
  23. {"e","e","e","e","e","e","e","e"}
  24. },
  25. {--3
  26. {"e","e","e","e","e","e","e","e"},
  27. {"e","e","e","e","e","e","e","e"},
  28. {"e","e","e","e","e","e","e","e"},
  29. {"e","e","e","e","e","e","e","e"},
  30. {"e","e","e","e","e","e","e","e"},
  31. {"e","e","e","e","e","e","e","e"},
  32. {"e","e","e","e","e","e","e","e"},
  33. {"e","e","e","e","e","e","e","e"}
  34. }
  35. }
  36.  
  37.  
  38. ----------------SCRIPT.LUA
  39.  
  40.  
  41. cnv=1  --nivel actual
  42. size=25   --tamaño de los bloques (wii o psp)
  43. function loading(text)  --función cagando...
  44. screen.print(480-5-screen.textwidth(tostring(text),0.8),258,tostring(text),0.8,color.new(255,255,255),0x0)
  45. screen.flip()
  46. end
  47. loading("Cargando niveles...")
  48. dofile("niveles.lua")
  49. loading("Cargando imágenes...")
  50. map={img = image.create(size*8,size*8),x=480/2-size*8/2,y=272/2-size*8/2} --cremos una imagen donde se "guardará" el mapa
  51.  
  52. img={empty=image.load("imagenes/blocks/empty.png"),
  53. grey=image.load("imagenes/blocks/grey.png"),
  54. blue=image.load("imagenes/blocks/blue.png"),
  55. brown=image.load("imagenes/blocks/brown.png")
  56. }
  57. arrow={d=image.load("imagenes/arrows/arrowd.png"),u=image.load("imagenes/arrows/arrowu.png"),
  58. l=image.load("imagenes/arrows/arrowl.png"),r=image.load("imagenes/arrows/arrowr.png")}
  59.  
  60. arrowp={d=image.load("imagenes/arrows/arrowd.png"),u=image.load("imagenes/arrows/arrowpu.png"),
  61. l=image.load("imagenes/arrows/arrowpl.png"),r=image.load("imagenes/arrows/arrowpr.png")}
  62.  
  63. for y = 1, #nivel[cnv] do
  64.   for x = 1, #nivel[cnv][y] do
  65.      if string.sub(nivel[cnv][y][x],1,1) == "g" or string.sub(nivel[cnv][y][x],2,2) == "g" then
  66.       map.img:blit((x-1)*size,(y-1)*size,img.grey)
  67.      elseif string.sub(nivel[cnv][y][x],1,1) == "b" or string.sub(nivel[cnv][y][x],2,2) == "b" then
  68.         map.img:blit((x-1)*size,(y-1)*size,img.blue)
  69.      elseif string.sub(nivel[cnv][y][x],1,1) == "m" or string.sub(nivel[cnv][y][x],2,2) == "m" then
  70.         map.img:blit((x-1)*size,(y-1)*size,img.brown)
  71.      elseif string.sub(nivel[cnv][y][x],1,1) == "e" then
  72.         map.img:blit((x-1)*size,(y-1)*size,img.empty)
  73.      end
  74. end
  75. end
  76. ----------------------------------------------------------
  77.  
  78.  
  79.  
  80.  
  81. while true do
  82. controls.read()
  83. map.img:blit(map.x,map.y)--bliteamos la imagen del mapa
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91. screen.flip()
  92. if controls.select() then a() end
  93. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement