Advertisement
Guest User

--

a guest
Aug 20th, 2013
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.35 KB | None | 0 0
  1. Pelota = class()
  2.  
  3. function Pelota:init()
  4. -- you can accept and set parameters here
  5. self.posicion = vec2( WIDTH /2,41)
  6. self.radio = 12
  7. self.velocidad = vec2(0,15)
  8. end
  9.  
  10. function Pelota:draw()
  11. local color_adicional = 255
  12. fill(255,255,255,color_adicional)
  13. noStroke()
  14. ellipse (self.posicion.x , self.posicion.y , 2* self.radio)
  15.  
  16.  
  17. local soltar_bola = self.posicion - self.velocidad
  18.  
  19. if Bola_movimiento == true then
  20. for y = 1,2 do
  21. color_adicional = color_adicional / 2
  22. fill (255,25,255,color_adicional)
  23. ellipse(soltar_bola.x , soltar_bola.y ,1* self.radio)
  24. soltar_bola = soltar_bola - self.velocidad
  25.  
  26. end
  27. end
  28. end
  29.  
  30. function Pelota:paredes()
  31. self.posicion = self.posicion + self.velocidad
  32.  
  33. --pared lateral derecha
  34. if (self.posicion.x + self.radio) >= WIDTH then
  35. -- self.posicion.x = WIDTH - self.radio
  36. --esta linea hace que el balon rebote en la pared derecha
  37. self.velocidad.x = -self.velocidad.x
  38. --sound(SOUND_JUMP)
  39. --pared lateral izquierda
  40. elseif (self.posicion.x - self.radio) <= 0 then
  41. -- self.posicion.x = self.radio
  42. --esta linea hace que el balon rebote en la pared izquierda
  43. self.velocidad.x = -self.velocidad.x
  44.  
  45. --pared de arriba
  46. elseif (self.posicion.y + self.radio) >= HEIGHT then
  47. physics.gravity(0,4000)
  48. -- self.posicion.y = HEIGHT - self.radio
  49. self.velocidad.y = -self.velocidad.y
  50.  
  51. --pared de abajo
  52. elseif (self.posicion.y - self.radio) <= 0 then
  53. -- self.posicion.y = self.radio
  54. self.velocidad.y = -self.velocidad.y
  55. sound(SOUND_RANDOM, 79)
  56.  
  57. return false
  58. end
  59. return true
  60. end
  61.  
  62. function Pelota:derecha()
  63. return self.posicion.x + self.radio
  64. end
  65. function Pelota:izquierda()
  66. return self.posicion.x - self.radio
  67. end
  68. function Pelota:arriba()
  69. return self.posicion.y + self.radio
  70. end
  71. function Pelota:abajo()
  72. return self.posicion.y - self.radio
  73. end
  74.  
  75.  
  76.  
  77. Barra = class()
  78.  
  79. function Barra:init()
  80. -- se realizaran la implementacion de la barra del juego
  81. -- el largo y el ancho de la barra
  82. self.posicion = vec2(380 , 60)
  83. -- tamano
  84. self.tamano = vec2(120, 15)
  85. end
  86.  
  87. function Barra:draw()
  88. -- le damos color a la barra
  89. fill(45, 197, 200, 255)
  90. -- sprite("Tyrian Remastered:Boss A",300,400)
  91. rectMode(CENTER)
  92.  
  93. --le damos curvatura a la recta en las esquinas
  94. ellipse(self.posicion.x - self.tamano.x /1.9 , self.posicion.y, 15)
  95. ellipse(self.posicion.x + self.tamano.x /1.9 , self.posicion.y, 15)
  96. --mostramos la recta
  97. ellipse(self.posicion.x , self.posicion.y , self.tamano.x , self.tamano.y)
  98. end
  99.  
  100.  
  101. function Barra:rebote(ball)
  102. if ball:izquierda() <= self:derecha() and ball:derecha() >= self:izquierda() and ball:abajo() <= self:arriba() and
  103. ball:arriba() >= self:abajo() then
  104.  
  105. ball.velocidad.y = -ball.velocidad.y
  106. ball.posicion.y = self:arriba() + ball.radio
  107. posicion = ball.posicion.x - self.posicion.x
  108. ball.velocidad.x = posicion /10
  109.  
  110. return true
  111. end
  112. return false
  113. end
  114.  
  115.  
  116. function Barra:derecha()
  117. return self.posicion.x + self.tamano.x /2
  118. end
  119. function Barra:izquierda()
  120. return self.posicion.x - self.tamano.x /2
  121. end
  122. function Barra:arriba()
  123. return self.posicion.y + self.tamano.y /2
  124. end
  125. function Barra:abajo()
  126. return self.posicion.y - self.tamano.y /2
  127. end
  128.  
  129.  
  130.  
  131.  
  132. --function Barra:touched(touch)
  133. -- Codea does not automatically call this method
  134. --end
  135.  
  136.  
  137. Bloques = class()
  138.  
  139. function Bloques:init(x, y , tonos)
  140. parameter.integer("Texture",1,2)
  141.  
  142. allTextures = {
  143. "Cargo Bot:Star Filled",
  144. }
  145.  
  146.  
  147.  
  148. m = mesh()
  149. m.texture = allTextures[Texture]
  150. -- parametros aqui
  151. -- damos posicion a los bloques
  152. self.posicion = vec2(x , y)
  153. -- damos tamano a los bloques
  154. self.tamano = vec2(70 , 43)
  155.  
  156. self.mesh = mesh()
  157.  
  158. self.color1 = tonos
  159. --implementamos los bloques en forma de recta
  160. self.mesh:addRect (self.posicion.x , self.posicion.y , self.tamano.x , self.tamano.y)
  161.  
  162. --le da,os tnos de color a los bloques
  163. local oscuro = self.color1:mix( color(400,400,400), 0.4 )
  164.  
  165. self.mesh:color(1 , self.color1)
  166. self.mesh:color(2 , oscuro)
  167. self.mesh:color(3 , self.color1)
  168. self.mesh:color(4 , oscuro)
  169. self.mesh:color(5 , self.color1)
  170. self.mesh:color(6 , oscuro)
  171.  
  172. self.mesh.shader = shader("Effects:Ripple")
  173.  
  174.  
  175. end
  176.  
  177. function Bloques:draw()
  178. fill(42, 82, 201, 153)
  179.  
  180. -- Configure out custom uniforms for the ripple shader
  181. self.mesh.shader.time = ElapsedTime
  182. self.mesh.shader.freq =1.5
  183. noStroke()
  184. self.mesh:draw()
  185. rectMode(CENTER)
  186. -- Codea does not automatically call this method
  187. end
  188.  
  189. function Bloques:rebote(ball)
  190.  
  191. if ball:derecha() >= self:izquierda() and ball:izquierda() <= self:derecha() and
  192. ball:arriba() >= self:abajo() and ball:abajo() <= self:arriba() then
  193.  
  194. sound(DATA, "ZgBAZAA+Qi0IQ0IWAAAAAAubAz5sIgq/VgBKU0BKQUBfIWcQ")
  195.  
  196. if ball.posicion.y <= self:arriba() and ball.posicion.y >= self:abajo() then
  197.  
  198. ball.velocidad.x = -ball.velocidad.x
  199. else
  200. ball.velocidad.y = -ball.velocidad.y
  201.  
  202. end
  203. return true
  204.  
  205. end
  206. return false
  207.  
  208. end
  209.  
  210. function Bloques:rebote(ball1)
  211.  
  212. if ball1:derecha() >= self:izquierda() and ball1:izquierda() <= self:derecha() and
  213. ball1:arriba() >= self:abajo() and ball1:abajo() <= self:arriba() then
  214. sound(DATA, "ZgBAZAA+Qi0IQ0IWAAAAAAubAz5sIgq/VgBKU0BKQUBfIWcQ")
  215.  
  216. if ball1.posicion.y <= self:arriba() and ball1.posicion.y >= self:abajo() then
  217.  
  218. ball1.velocidad.x = -ball1.velocidad.x
  219. else
  220. ball1.velocidad.y = -ball1.velocidad.y
  221.  
  222. end
  223. return true
  224.  
  225. end
  226. return false
  227.  
  228. end
  229.  
  230. -- creamos las funciones de arriba, abajo, izquierda, derecha
  231.  
  232. function Bloques:derecha()
  233. return self.posicion.x + self.tamano.x / 2
  234. end
  235. function Bloques:izquierda()
  236. return self.posicion.x - self.tamano.x /2
  237. end
  238. function Bloques:arriba()
  239. return self.posicion.y + self.tamano.y /2
  240. end
  241. function Bloques:abajo()
  242. return self.posicion.y - self.tamano.y /2
  243. end
  244.  
  245.  
  246. niveles = {
  247.  
  248. {{0,0,1,1,1,1,1,1,0,0},{0,0,0,0,0,0,0,0,0,0},
  249. {0,0,1,0,1,1,0,1,0,0},{0,0,0,0,0,0,0,0,0,0},
  250. {0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0},
  251. {0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0}},
  252.  
  253. {{1,1,1,1,1,1,1,1,1,1},{0,1,1,1,1,1,1,1,1,0},
  254. {0,0,1,1,1,1,1,1,0,0},{0,0,0,1,1,1,1,0,0,0},--nivel2 lluvia
  255. {0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0},
  256. {0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0}},
  257.  
  258. {{0,0,0,1,1,1,1,0,0,0},{0,0,1,1,1,1,1,1,0,0}
  259. ,{0,0,1,1,1,1,1,1,0,0},{0,0,1,1,1,1,1,1,0,0},--nivel3 bate invertido
  260. {0,0,1,1,1,1,1,1,0,0},{0,0,0,1,1,1,1,0,0,0},
  261. {0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0}},
  262.  
  263. {{1,1,1,1,1,1,1,1,1,1},{1,1,1,1,0,0,0,0,1,1},
  264. {1,1,1,1,0,1,1,0,1,1},{1,1,1,1,0,0,0,0,1,1},--nivel4 doble balon
  265. {1,1,1,1,0,1,1,1,1,1},{1,1,1,1,0,1,1,1,1,1},
  266. {1,1,1,1,0,1,1,1,1,1},{1,1,1,1,1,1,1,1,1,1}},
  267.  
  268. {{1,1,1,1,1,1,1,1,1,1},{1,1,1,1,1,1,1,1,1,1},
  269. {1,1,1,1,1,1,1,1,1,1},{1,1,1,1,1,1,1,1,1,1},--nivel5 direccion balon con barra
  270. {1,1,1,1,1,1,1,1,1,1},{0,0,0,0,0,0,0,0,0,0},
  271. {0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0}},
  272.  
  273. {{1,1,1,1,1,1,1,1,1,1},{1,1,1,1,1,1,1,1,1,1},
  274. {1,1,1,1,1,1,1,1,1,1},{1,1,1,1,1,1,1,1,1,1},--nivel6
  275. {1,1,1,1,1,1,1,1,1,1},{0,0,0,0,1,1,1,0,0,0},
  276. {0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0}},
  277.  
  278. {{1,1,1,1,1,1,1,1,1,1},{1,1,1,1,1,1,1,1,1,1},
  279. {1,1,1,1,1,1,1,1,1,1},{1,1,1,1,1,1,1,1,1,1},--nivel7
  280. {1,1,1,1,1,1,1,1,1,1},{0,0,0,0,1,1,1,0,0,0},
  281. {0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0}}
  282.  
  283. }
  284.  
  285.  
  286.  
  287. linea = class()
  288.  
  289. function linea:init(vel , pos)
  290. -- you can accept and set parameters here
  291. self.velocidad = vel
  292. self.posicion = pos
  293. end
  294.  
  295. function linea:cargar()
  296. self.posicion.y = self.posicion.y - self.velocidad
  297.  
  298. end
  299.  
  300. function linea:mostrar()
  301. if (self.posicion.y + self.velocidad) < 0 then
  302.  
  303. return true
  304.  
  305. end
  306. return false
  307.  
  308. end
  309.  
  310. function linea:dibujar()
  311. p = self.posicion
  312. -- gotas = {"Small World:Raindrop"}
  313. line(p.x,p.y,p.x,p.y + self.velocidad)
  314. end
  315. -------------------------------------------------------------------------
  316.  
  317.  
  318. lineas = class()
  319.  
  320.  
  321. function lineas:init()
  322.  
  323. self.velocidad_0 = 3
  324. self.velocidad_1 = 20
  325. self.rango =1
  326. self.lines = {}
  327.  
  328. end
  329.  
  330. function lineas:mostrarTodo()
  331. for i,v in ipairs(self.lines) do
  332. if v:mostrar() then
  333. table.remove(self.lines , i )
  334.  
  335.  
  336. else
  337. v:cargar()
  338. end
  339.  
  340. end
  341.  
  342.  
  343. end
  344. function lineas:cargar()
  345.  
  346. for i = 1 , self.rango do
  347. Velocidad = math.random(self.velocidad_0 , self.velocidad_1)
  348.  
  349. dato_1 = vec2(math.random(WIDTH/1) , HEIGHT - Velocidad)
  350.  
  351. table.insert(self.lines , linea(Velocidad , dato_1))
  352. end
  353. self:mostrarTodo()
  354.  
  355.  
  356. end
  357.  
  358. function lineas:dibujar()
  359. --sound(DATA,"ZgNAeABCQj4/Pj1DWQtwPxDT77u1THs/dQBHf0JFQD9AQj9A")
  360.  
  361. pushStyle()
  362. noSmooth()
  363. stroke(255,255,255,73.9)
  364. strokeWidth(3)
  365.  
  366. for i,v in ipairs(self.lines) do
  367.  
  368.  
  369. v:dibujar()
  370.  
  371.  
  372. end
  373.  
  374. popStyle()
  375. end
  376.  
  377.  
  378. -- juego 3
  379. displayMode(FULLSCREEN)
  380. --declaracion de variables para llamar clases
  381. --bg = mesh()
  382. bat = nil
  383. ball = nil
  384. ball1 = nil
  385. lastDelta = 0
  386. Bola_movimiento = false
  387. bloques = {}
  388. nivel=1
  389. vidas =3
  390. gravedad= vec2(0,0)
  391. lluvia = nil
  392. sonidos = nil
  393. velocidad = 0
  394. explotar = nil
  395. juego_finito = false
  396. ganar = false
  397. puntos = 0
  398. maximo_nivel = table.maxn(niveles)
  399.  
  400. function setup()
  401. -- sound(DATA,"ZgNAeABCQj4/Pj1DWQtwPxDT77u1THs/dQBHf0JFQD9AQj9A" , 0.6)
  402.  
  403. bat = Barra()
  404. ball = Pelota()
  405. ball1 = Pelota()
  406. lluvia = lineas()
  407. sonido_de_lluvia = 0
  408. sonidoBarra = 0
  409. -- explotar = Explosiones()
  410. ball.velocidad.x = math.random(-3,3)
  411.  
  412. Poner_bloques()
  413. print("juego de ping pong terminado")
  414. print("toca la barra para empezar a jugar")
  415. print("una ves se te acaben las 3 vidas pierdes")
  416. print("si pasas de nivel se te agrefara una vida")
  417. print("cada ves que subes de nivel la pelota sera mas rapida")
  418. print("SUERTE!!")
  419.  
  420. end
  421.  
  422. --se crea una funcion para mostarar la cantidad de bloques
  423.  
  424. function Poner_bloques()
  425.  
  426. for i = 1,8 do
  427. c = obtenerColorPorNivel(i)
  428. for x = 1,10 do
  429. if niveles[nivel][i][x] > 0 then
  430. table.insert(bloques, Bloques(35 + (x * 62), HEIGHT - (i * 35 + 35) , c))
  431.  
  432. end
  433. end
  434. end
  435. end
  436.  
  437. function obtenerColorPorNivel(fila)
  438. cambiarTono = fila * 35
  439. if nivel % 4 == 1 then
  440. c = color(cambiarTono,255,255)
  441. elseif nivel % 4 == 2 then
  442. c = color(255,cambiarTono,255)
  443. elseif nivel % 4 == 3 then
  444. c = color(255,255,cambiarTono,255)
  445. else
  446. c = color(0,255,cambiarTono,255)
  447. end
  448. return c
  449. end
  450.  
  451. -- This function gets called once every frame
  452. function draw()
  453. --color de fondo
  454.  
  455. background(0, 25, 25, 5)
  456.  
  457.  
  458. noSmooth()
  459.  
  460. if Bola_movimiento then
  461. if ball:paredes() == false then
  462. perder_vidas()
  463. end
  464.  
  465. end
  466.  
  467. if bat:rebote(ball) == false then
  468.  
  469. end
  470. for i = 1, table.maxn(bloques) do
  471. if bloques[i]:rebote(ball) then
  472.  
  473. table.remove(bloques, i)
  474.  
  475. puntos = puntos + 50
  476.  
  477. break
  478. end
  479. -- esta sentncia funciona bien
  480. if puntos == 1000 then
  481.  
  482.  
  483. -- mostrarTexto("EN RACHA!!" , 380 , 450)
  484. --mostrarTexto("BARRA ALARGADA !!" , 350 , 400)
  485.  
  486. bat.tamano.x = bat.tamano.x + 2
  487. bat.posicion.y = bat.posicion.y + 0.2
  488.  
  489. end
  490.  
  491. end
  492.  
  493.  
  494. if table.maxn(bloques) == 1 then
  495. --ball1:draw()
  496. ball.posicion.x = bat.posicion.x
  497. ball1.posicion.x = bat.posicion.x
  498. ball.radio = 10
  499. ball1.radio = 10
  500. end
  501.  
  502. --
  503. if table.maxn(bloques) == 0 then
  504. -- sound(SOUND_RANDOM, 21158)
  505. nuevo_nivel()
  506.  
  507. end
  508.  
  509.  
  510.  
  511. -- llamamos la funcion de la clase Barra() que es draw para mostrar la barra
  512.  
  513. strokeWidth(2)
  514.  
  515. bat:draw()
  516. ball:draw()
  517.  
  518. --muestra los bloques por pantalla
  519. for i = 1, table.maxn(bloques)do
  520. bloques[i]:draw()
  521. end
  522.  
  523.  
  524.  
  525. if nivel == 2 or nivel == 4 or nivel == 6 or nivel == 7 then
  526. -- mantiene el sonido equilirado y con mayor fluides y duracion
  527. if ElapsedTime > sonido_de_lluvia then
  528. sonido_de_lluvia = ElapsedTime + 2
  529. sound(DATA, "ZgNAfwBAQj4/Pj9DAACAPwAAAAAAAIA/AABHf0JFQD9AQj9A")
  530. end
  531.  
  532. lluvia:cargar()
  533.  
  534. lluvia:dibujar()
  535.  
  536. end
  537.  
  538. -- nivel 3 con barra invertida
  539. if nivel == 3 then
  540. bat.posicion.x = bat.posicion.x-lastDelta
  541. bat.posicion.x = bat.posicion.x-lastDelta
  542.  
  543. end
  544. -- fin del nivel 3
  545.  
  546. -- nivel 4 con balon duplicado y velocidad de bola aumentada en 4
  547. if nivel == 4 then
  548.  
  549. if Bola_movimiento then
  550. if ball1:paredes() == false then
  551. perder_vidas()
  552.  
  553. end
  554. end
  555.  
  556. if bat:rebote(ball1) == false then
  557. -- Check collision with the blocks
  558. -- no need to do this if ball has hit bat.
  559. -- Still does a lot of unecessary checks
  560.  
  561. end
  562.  
  563. for u = 1, table.maxn(bloques) do
  564. if bloques[u]:rebote(ball1) then
  565.  
  566. table.remove(bloques, u )
  567.  
  568. puntos = puntos + 50
  569.  
  570.  
  571. break
  572.  
  573. end
  574. end
  575.  
  576. ball1:draw()
  577.  
  578. end
  579. -- fin de nivel 4
  580.  
  581. -- nivel 5 con bola mismo sentido que el bate
  582.  
  583. if nivel == 5 then
  584.  
  585. ball.posicion.x = bat.posicion.x
  586. ball1.posicion.x = bat.posicion.x
  587.  
  588. if Bola_movimiento then
  589. if ball1:paredes() == false then
  590. perder_vidas()
  591.  
  592. end
  593. end
  594.  
  595. if bat:rebote(ball1) == false then
  596. -- Check collision with the blocks
  597. -- no need to do this if ball has hit bat.
  598. -- Still does a lot of unecessary checks
  599.  
  600. end
  601.  
  602. for u = 1, table.maxn(bloques) do
  603. if bloques[u]:rebote(ball1) then
  604.  
  605. table.remove(bloques, u )
  606.  
  607. puntos = puntos + 50
  608.  
  609.  
  610. break
  611.  
  612. end
  613. end
  614.  
  615. ball1:draw()
  616. end
  617.  
  618.  
  619. -- fin del nivel 5
  620.  
  621. --
  622.  
  623. if nivel == 6 or nivel == 7 then
  624. bat.posicion.x = bat.posicion.x - lastDelta
  625. bat.posicion.x = bat.posicion.x - lastDelta
  626.  
  627. --bat.tamano.x = bat.tamano.x + 2
  628.  
  629. if Bola_movimiento then
  630. if ball1:paredes() == false then
  631. perder_vidas()
  632.  
  633. end
  634. end
  635.  
  636. if bat:rebote(ball1) == false then
  637. -- Check collision with the blocks
  638. -- no need to do this if ball has hit bat.
  639. -- Still does a lot of unecessary checks
  640.  
  641. end
  642.  
  643. for u = 1, table.maxn(bloques) do
  644. if bloques[u]:rebote(ball1) then
  645.  
  646. table.remove(bloques, u )
  647.  
  648. puntos = puntos + 50
  649.  
  650.  
  651. break
  652.  
  653. end
  654. end
  655.  
  656. ball1:draw()
  657. --background(40,40,50)
  658. lluvia:cargar()
  659.  
  660. lluvia:dibujar()
  661.  
  662. -- using the table to define properties
  663.  
  664. end
  665. -- fin del level 6 y 7
  666.  
  667.  
  668. if juego_finito then
  669.  
  670. mostrarTexto("PERDISTE", 350, 400)
  671. elseif ganar then
  672. mostrarTexto("GANASTE" , 350, 400)
  673.  
  674. end
  675.  
  676.  
  677. function touched(touch)
  678.  
  679. if CurrentTouch.state == BEGAN or
  680.  
  681. CurrentTouch.state == MOVING then
  682.  
  683. lastDelta = CurrentTouch.deltaX
  684.  
  685. if Bola_movimiento == false then
  686. if CurrentTouch.x < bat:derecha() + 100 and
  687. CurrentTouch.x > bat:izquierda() - 100 and
  688. CurrentTouch.y < bat:arriba() + 200 and
  689. CurrentTouch.y > bat:abajo() then
  690. sound(DATA, "ZgJANwBAUyFBBgUrFEQgPnuCCD/ggYs9cwB/bUBAP0c/On0N")
  691. if Bola_movimiento == false then
  692. Bola_movimiento = true
  693. end
  694. end
  695. else
  696. --movemos la barra
  697. bat.posicion.x = bat.posicion.x + lastDelta
  698. bat.posicion.x = math.min( bat.posicion.x, WIDTH - bat.tamano.x/2 )
  699. bat.posicion.x = math.max( bat.tamano.x/2, bat.posicion.x )
  700. end
  701. elseif juego_finito == true or ganar == true then
  702. if CurrentTouch.tapCount == 1 then
  703. resetearJuego()
  704. end
  705.  
  706. end
  707.  
  708. end
  709. lastDelta = 0
  710. end
  711.  
  712.  
  713. --ceramos una funcion que reseteara el balon una ves se falle con el bate
  714. function resetearBalon()
  715. Bola_movimiento = false
  716. ball.posicion.x = bat.posicion.x
  717. ball1.posicion.x = bat.posicion.x
  718. ball.posicion.y = 30
  719. ball1.posicion.y = 30
  720. ball.posicion.x = 380
  721. ball.radio = 12
  722. ball1.ratio = 12
  723. bat.posicion.x = 380
  724. bat.posicion.y = 47
  725.  
  726. end
  727.  
  728. -- funcion para pasar a un nuevo nivel
  729.  
  730. function nuevo_nivel()
  731.  
  732. puntos = puntos + 100 * vidas * nivel
  733.  
  734. -- ball.velocidad.y = ball.velocidad.y + 0.5 --hace que destrose de a un bloque cada ves que se aumente el nivel
  735. -- ball.velocidad.y = ball.velocidad.y * 1.2
  736. resetearBalon()
  737.  
  738. if nivel <= maximo_nivel then
  739. --el nivel aumenta a n+1
  740. nivel = nivel + 1
  741. --ball.velocidad.y = math.random(0,30)
  742. -- se colocan los bloques nuevamente del resectivo nivel
  743. Poner_bloques()
  744. ball.velocidad.y = ball.velocidad.y * 1.2
  745. vidas = vidas + 1
  746. bat.tamano = vec2(120,15)
  747. -- sound(SOUND_RANDOM, 61)
  748.  
  749. else
  750. ganar = true
  751. end
  752.  
  753. end
  754. -- creamos una nueva funcion para ir descontando las vidas
  755.  
  756. function perder_vidas()
  757.  
  758. resetearBalon()
  759. --se descuenta la vida
  760. vidas = vidas - 1
  761. if vidas == 0 then
  762. juego_finito = true
  763. -- Poner_bloques()
  764. end
  765.  
  766. end
  767.  
  768. -- cramos una funcion para mostrar si se perdio o se gano
  769.  
  770. function mostrarTexto(str , x , y )
  771. pushStyle()
  772. textMode(CORNER)
  773. fill(255, 255, 0, 255)
  774. font("Arial")
  775. fontSize(50)
  776. text(str,x,y)
  777. popStyle()
  778. end
  779.  
  780. function mostrar_advertencia(acomodar,x,y)
  781. pushMatrix()
  782. fill(255,25,25,255)--rojo
  783. font("Georgia")
  784. fontSize(20)
  785. textWrapWidth(200)
  786. text(acomodar,x,y)
  787. popMatrix()
  788.  
  789.  
  790. end
  791.  
  792. --creamos una funcion que resetear el juego cunado pierdes
  793.  
  794. function resetearJuego()
  795.  
  796. vidas = 3
  797. puntos = 0
  798. nivel = 1
  799. bloques = {}
  800. Poner_bloques()
  801. juego_finito = false
  802. ganar = false
  803. ball.velocidad.y = 15
  804. --ball1.velocidad.y = math.random(0,15)
  805.  
  806. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement