simple gravity game whit shader (Effects:Ripple)

Pelota = class()

function Pelota:init()

self.posicion = vec2( WIDTH /2 , HEIGHT / 2)

self.radio = 18

self.velocidad = vec2(Gravity.x*30 , Gravity.y*30)

end



function Pelota:draw()

self.velocidad = vec2(Gravity.x*30 , Gravity.y*30)

ellipse (self.posicion.x , self.posicion.y , 2* self.radio)

end


function Pelota:paredes()

self.posicion = self.posicion + self.velocidad


if (self.posicion.x + self.radio) >= WIDTH then

self.posicion.x = WIDTH - self.radio



self.velocidad.x =  -self.velocidad.x



elseif (self.posicion.x - self.radio) <= 0 then

self.posicion.x = self.radio



self.velocidad.x = -self.velocidad.x





elseif (self.posicion.y + self.radio) >= HEIGHT then



self.posicion.y = HEIGHT - self.radio

self.velocidad.y = -self.velocidad.y



 elseif (self.posicion.y - self.radio) <= 0 then

self.posicion.y = self.radio

self.velocidad.y = -self.velocidad.y



return false



end



return true  

 end


function Pelota:derecha()

return self.posicion.x + self.radio



 end



function Pelota:izquierda()



return self.posicion.x - self.radio



end



function Pelota:arriba()



return self.posicion.y + self.radio



 end  



function Pelota:abajo()



return self.posicion.y - self.radio 



end

Bloques = class()



function Bloques:init(x, y , tonos) parameter.integer("Texture",1,2)



allTextures = { 

            "Cargo Bot:Codea Icon",

          }







 m = mesh()

 m.texture = allTextures[Texture]


  self.posicion = vec2(x , y)



 self.tamano = vec2(70 , 35)



 self.mesh = mesh()



 self.color1 = tonos



 self.mesh:addRect (self.posicion.x , self.posicion.y , self.tamano.x , self.tamano.y)





 local oscuro = self.color1:mix( color(400,400,400), 0.4 )



 self.mesh:color(1 , self.color1)

 self.mesh:color(2 , oscuro)

 self.mesh:color(3 , self.color1)

 self.mesh:color(4 , oscuro)

 self.mesh:color(5 , self.color1)

 self.mesh:color(6 , oscuro)



 self.mesh.shader = shader("Effects:Ripple")

 end



 function Bloques:draw()



 fill(42, 82, 201, 153)





 self.mesh.shader.time = ElapsedTime

 self.mesh.shader.freq =1.5 noStroke() self.mesh:draw() rectMode(CENTER)



 end



function Bloques:rebote(ball)



if ball:derecha() >= self:izquierda() and ball:izquierda() <= self:derecha() and

 ball:arriba() >= self:abajo() and ball:abajo() <= self:arriba() then



sound(DATA, "ZgBAZAA+Qi0IQ0IWAAAAAAubAz5sIgq/VgBKU0BKQUBfIWcQ")



 if ball.posicion.y <= self:arriba() and ball.posicion.y >= self:abajo() then



     ball.velocidad.x = -ball.velocidad.x

 else

     ball.velocidad.y = -ball.velocidad.y



 end



 return true



 end



 return false

 end



  function Bloques:derecha()



 return self.posicion.x + self.tamano.x / 2

 end



function Bloques:izquierda()



return self.posicion.x - self.tamano.x /2

 end



function Bloques:arriba()



 return self.posicion.y + self.tamano.y /2

 end



 function Bloques:abajo()



 return self.posicion.y - self.tamano.y /2



 end

 niveles = {



  {{1,1,1,1,1,1,1,1,1,1},{1,1,1,1,1,1,1,1,1,1},{1,1,1,1,1,1,1,1,1,1},{1,1,1,1,1,1,1,1,1,1},
  {1,1,1,1,1,1,1,1,1,1},{1,1,1,1,1,1,1,1,1,1},{1,1,1,1,1,1,1,1,1,1},{1,1,1,1,1,1,1,1,1,1}},



 {{1,1,1,1,1,1,1,1,1,1},{1,1,1,1,1,1,1,1,1,1},{1,1,1,1,1,1,1,1,1,1},{1,1,1,1,1,1,1,1,1,1},
 {1,1,1,1,1,1,1,1,1,1},{1,1,1,1,1,1,1,1,1,1},{1,1,1,1,1,1,1,1,1,1},{1,1,1,1,1,1,1,1,1,1}},



  {{1,1,1,1,1,1,1,1,1,1},{1,1,1,1,1,1,1,1,1,1},{1,1,1,1,1,1,1,1,1,1},{1,1,1,1,1,1,1,1,1,1},
  {1,1,1,1,1,1,1,1,1,1},{1,1,1,1,1,1,1,1,1,1},{1,1,1,1,1,1,1,1,1,1},{1,1,1,1,1,1,1,1,1,1}},



  {{1,1,1,1,1,1,1,1,1,1},{1,1,1,1,1,1,1,1,1,1},{1,1,1,1,1,1,1,1,1,1},{1,1,1,1,1,1,1,1,1,1},
   {1,1,1,1,1,1,1,1,1,1},{1,1,1,1,1,1,1,1,1,1},{1,1,1,1,1,1,1,1,1,1},{1,1,1,1,1,1,1,1,1,1}},



   {{1,1,1,1,1,1,1,1,1,1},{1,1,1,1,1,1,1,1,1,1},{1,1,1,1,1,1,1,1,1,1},{1,1,1,1,1,1,1,1,1,1}, 
   {1,1,1,1,1,1,1,1,1,1},{1,1,1,1,1,1,1,1,1,1},{1,1,1,1,1,1,1,1,1,1},{1,1,1,1,1,1,1,1,1,1}},



  }



 displayMode(FULLSCREEN)



 ball = nil Bola_movimiento = false bloques = {} nivel=1 velocidad = 0   maximo_nivel = table.maxn(niveles)



 function setup()



 ball = Pelota()



 ball.velocidad.x = math.random(-3,3)



  Poner_bloques()

 end



 function Poner_bloques()



 for i = 1,8 do

c = obtenerColorPorNivel(i)

for x = 1,10 do

    if niveles[nivel][i][x] > 0 then

        table.insert(bloques, Bloques(35 + (x * 62), HEIGHT - (i * 35 + 35) , c))



        end

 end

 end

 end



 function obtenerColorPorNivel(fila)



  cambiarTono = fila * 35

 if nivel % 4 == 1 then

 c = color(cambiarTono,255,255)

 elseif nivel % 4 == 2 then

 c = color(255,cambiarTono,255)

 elseif nivel % 4 == 3 then

 c = color(255,255,cambiarTono,255)

 else

 c = color(0,255,cambiarTono,255)

 end

 return c

 end



 function draw()



 background(0, 25, 25, 5)

 noSmooth()



 if ball:paredes()  == false then

     end



          for i = 1, table.maxn(bloques) do

              if bloques[i]:rebote(ball) then



                 table.remove(bloques, i)

                              break

                             end



 end



        --

        if table.maxn(bloques) == 0 then



            nuevo_nivel()



            end



 strokeWidth(2)



  ball:draw()





 for i = 1, table.maxn(bloques)do

 bloques[i]:draw()

 end

 function touched(touch)



 if CurrentTouch.state == BEGAN or



 CurrentTouch.state == MOVING then



  lastDelta = CurrentTouch.deltaX



 if Bola_movimiento == false then

        if CurrentTouch.x < bat:derecha() + 100 and 

            CurrentTouch.x > bat:izquierda() - 100 and 

            CurrentTouch.y < bat:arriba() + 200 and 

            CurrentTouch.y > bat:abajo() then



            if Bola_movimiento == false then

                Bola_movimiento = true

            end

        end

 else



 end

 elseif juego_finito == true or ganar == true then if CurrentTouch.tapCount == 1 then resetearJuego() end



 end



end

 lastDelta = 0

 end



 function nuevo_nivel()



 if nivel <= maximo_nivel then



 nivel = nivel + 1



 Poner_bloques()

 vidas = vidas + 1

 else ganar = true end



 end

sorry my bad @mnjk78lg

I’m thinking this forum should include a button in the comment space that creates lua syntax tags around the selected text