Advertisement
xerpi

Untitled

Apr 30th, 2011
291
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.13 KB | None | 0 0
  1. --T.W.O.S Coming On 2011
  2. -- Movimiento
  3. --Created By -Deinous-
  4. --Colors
  5. --System.memclean()
  6.  
  7. black = color.new(0,0,0)
  8.  
  9. miImagen1 = image.load("./Images/pausa1.png")
  10. miImagen2 = image.load("./Images/pausa2.png")
  11.  
  12. options = 2
  13.  
  14. mActual = 1
  15.  
  16. --Loading images
  17.  
  18. --Imagenes: Fondo
  19.  
  20. Fondo = image.load("./Images/Fondo.png")
  21.  
  22. --Imagenes: Personaje
  23.  
  24. pd1 = image.load("./Images/pd1.png")
  25. pd2 = image.load("./Images/pd2.png")
  26. pd3 = image.load("./Images/pd3.png")
  27. pd4 = image.load("./Images/pd4.png")
  28.  
  29. pi1 = image.load("./Images/pi1.png")
  30. pi2 = image.load("./Images/pi2.png")
  31. pi3 = image.load("./Images/pi3.png")
  32. pi4 = image.load("./Images/pi4.png")
  33. life = image.load("./Images/life.png")
  34. bala = image.load("./Images/bala.png")
  35.  
  36. battery1 = image.load("./Images/battery1.png")
  37. battery2 = image.load("./Images/battery2.png")
  38. battery3 = image.load("./Images/battery3.png")
  39. battery4 = image.load("./Images/battery4.png")
  40.  
  41. --sonidos
  42. shoot = sound.load("shoot.wav")
  43. thememenu = sound.load("thememenu.ogg")
  44.  
  45. --COlores
  46. negro = color.new(0,0,0)
  47.  
  48. rojo = color.new(255,0,0)
  49. blanco = color.new(255,255,255)
  50.  
  51.  
  52.  
  53.  
  54. Personaje = {}
  55.  
  56. Personaje[1] = { x = 60, y = 210 }
  57.  
  58. Personaje.gravedad = 210
  59. Personaje.velocidadSalto = 10
  60. Personaje.estadoSalto = "suelo"
  61.  
  62. sprite = pd1
  63. pasosd = 0
  64. pasosi = 0
  65.  
  66. balaActual = 0
  67. direccion = "derecha"
  68.  
  69. barraSalud = {}
  70. barraSalud.y = 10
  71.  
  72. personaje = {}
  73. personaje.salud = 100
  74.  
  75. infoBala = {}
  76. for a = 1,5 do
  77.    infoBala[a] = { imagen = bala , disparando = false, direccion = "derecha", x = Personaje[1].x + 32, y = Personaje[1].y + 16 }
  78. end
  79.  
  80. --Funciones.
  81.  
  82. function configBala()
  83. --Incrementamos la balaActual en 1 or la reiniciamos a 1.
  84. if balaActual < 5 then
  85.    balaActual = balaActual + 1
  86. else
  87.    balaActual = 1
  88. end
  89. if direccion == "izquierda" then
  90.    infoBala[balaActual].x = Personaje[1].x
  91.    infoBala[balaActual].y = Personaje[1].y + 16
  92. end
  93. if direccion == "derecha" then
  94.    infoBala[balaActual].x = Personaje[1].x + 32
  95.    infoBala[balaActual].y = Personaje[1].y + 16
  96. end
  97. if direccion == "arriba" then
  98.    infoBala[balaActual].x = Personaje[1].x + 16
  99.    infoBala[balaActual].y = Personaje[1].y
  100. end
  101. if direccion == "abajo" then
  102.    infoBala[balaActual].x = Personaje[1].x + 16
  103.    infoBala[balaActual].y = Personaje[1].y + 32
  104. end
  105. infoBala[balaActual].direccion = direccion
  106. infoBala[balaActual].disparando = true
  107. end
  108.  
  109. function disparoBala()
  110. for i = 1,5 do
  111.    if infoBala[i].disparando == true then
  112.       if infoBala[i].direccion == "derecha" then infoBala[i].x = infoBala[i].x + 10 end
  113.       if infoBala[i].direccion == "izquierda" then infoBala[i].x = infoBala[i].x - 10 end
  114.       if infoBala[i].direccion == "arriba" then infoBala[i].y = infoBala[i].y - 10 end
  115.       if infoBala[i].direccion == "abajo" then infoBala[i].y = infoBala[i].y + 10 end
  116.       image.blit(infoBala[i].x,infoBala[i].y,infoBala[i].imagen)
  117.    end
  118.    if infoBala[i].x < 0 or infoBala[i].x > 480 or infoBala[i].y < 0 or infoBala[i].y > 272 then
  119.       infoBala[i].disparando = false
  120.    end
  121. end
  122. end
  123.  
  124. function mov()
  125. if controls.right() then
  126. direccion = "derecha"
  127. Personaje[1].x = Personaje[1].x +2
  128. pasosd = pasosd + 1
  129. end
  130.  
  131. if controls.left() then
  132. direccion = "izquierda"
  133. Personaje[1].x = Personaje[1].x -2
  134. pasosi = pasosi + 1
  135. end
  136. end
  137.  
  138. function sprd()
  139. if pasosd >= 0 and pasosd < 10 and controls.right() then
  140. sprite=pd1
  141. end
  142. if pasosd >= 10 and pasosd < 20  and controls.right() then
  143. sprite=pd2
  144. end
  145. if pasosd >= 20 and pasosd < 30 and controls.right() then
  146. sprite=pd3
  147. end
  148. if pasosd >= 30 and pasosd < 40 and controls.right() then
  149. sprite=pd4
  150. end
  151. if pasosd >= 40 then
  152. pasosd=0
  153. end
  154. end
  155.  
  156. function spri()
  157. if pasosi >= 0 and pasosi < 10 and controls.left() then
  158. sprite=pi1
  159. end
  160. if pasosi >= 10 and pasosi < 20 and controls.left() then
  161. sprite=pi2
  162. end
  163. if pasosi >= 20 and pasosi < 30 and controls.left() then
  164. sprite=pi3
  165. end
  166. if pasosi >= 30 and pasosi < 40 and controls.left() then
  167. sprite=pi4
  168. end
  169. if pasosi >= 40 then
  170. pasosi=0
  171. end
  172. end
  173.  
  174.  
  175. --Fin Función--
  176.  
  177.  
  178. while true do
  179. controls.read()
  180.  
  181.  
  182. --play sound
  183. sound.play(thememenu)
  184.    
  185.  
  186.     if controls.cross() and Personaje.estadoSalto == "suelo" then
  187.         Personaje.estadoSalto = "saltando"
  188.     end
  189.  
  190.     if Personaje.estadoSalto == "saltando" then
  191.         Personaje.velocidadSalto = Personaje.velocidadSalto - 0.5
  192.         Personaje.gravedad = Personaje.gravedad - Personaje.velocidadSalto
  193.     end
  194.  
  195.     if Personaje.velocidadSalto < 0 then
  196.         Personaje.estadoSalto = "cayendo"
  197.     end
  198.  
  199.     if Personaje.gravedad < 210 and Personaje.estadoSalto == "cayendo" then
  200.         Personaje.velocidadSalto = Personaje.velocidadSalto + 0.5
  201.         Personaje.gravedad = Personaje.gravedad + Personaje.velocidadSalto
  202.     end
  203.  
  204.     if Personaje.gravedad == 210 then
  205.         Personaje.velocidadSalto = 10
  206.         Personaje.estadoSalto = "suelo"
  207.     end
  208.  
  209.     if Personaje.gravedad > 210 then Personaje.gravedad = 210 end
  210.  
  211.     Personaje[1].y = Personaje.gravedad
  212.  
  213.     image.blit(0,0,Fondo)
  214. --miscare
  215.     image.blit(Personaje[1].x,Personaje[1].y,sprite)
  216.  
  217. --shoot
  218. if controls.press("circle") then
  219.      configBala()
  220. sound.play(shoot)
  221. end
  222.  
  223. --saritura 
  224.     if controls.press("cross") then
  225.  
  226.     end
  227.  
  228.     --limita ecran
  229.     if Personaje[1].x <= 0  then Personaje[1].x = 0 -- pentru in partea cealanta este >
  230.     -- solo ponle que si el personaje es menor a 0 entonces se quede en 0
  231.     -- fin
  232.  
  233.  
  234. end
  235.  
  236.     if controls.up() then
  237.     dofile("lala.lua")
  238.     end
  239.    
  240.    
  241.    
  242.     --viata
  243.     draw.fillrect(10,10,personaje.salud,barraSalud.y,rojo)
  244.     screen.print(41,40,personaje.salud,0.6,blanco,0x0)
  245.     draw.fillrect(15,23,life)
  246.     screen.print(70,40,"%",0.6,blanco,0x0)
  247.  
  248.    
  249.     if controls.up() and personaje.salud < 100 then
  250.         personaje.salud = personaje.salud + 0.5
  251.      
  252.     end
  253.  
  254.     if controls.down() and personaje.salud > 0 then
  255.         personaje.salud = personaje.salud - 0.5
  256.     image.blit(0,0,life)
  257.     end
  258.  
  259.    
  260. if controls.start() then
  261.  
  262. dofile("./pausa.lua")
  263.  
  264. end
  265.  
  266.  
  267. --baterie
  268.   if batt.percent() >= 0 then batteryL = battery1 end
  269.   if batt.percent() > 25 then batteryL = battery2 end
  270.   if batt.percent() > 50 then batteryL = battery3 end
  271.   if batt.percent() > 75 then batteryL = battery4 end
  272.  
  273. image.blit(425,7,batteryL)
  274. --
  275. mov()
  276. sprd()
  277. spri()
  278. disparoBala()
  279. screen.flip
  280. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement