You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
2.6 KiB
Lua

function love.load()
love.graphics.setBackgroundColor(0,0,0) --set the background color to blue
love.window.setFullscreen(true, "desktop") -- set the window to fullscreen
screen = {}
screen.w, screen.h = love.graphics.getDimensions()
screen.wc = screen.w / 2 -- x center screen
screen.hc = screen.h / 2 -- y center screen
gravity_x = 0
gravity_y = 9.81
size_meter = 64
love.physics.setMeter(size_meter)
world = love.physics.newWorld(gravity_x, gravity_y*size_meter, true)
world:setCallbacks(beginContact, endContact, preSolve, postSolve)
objeto = {}
objeto.bola = {}
objeto.bola.body = love.physics.newBody(world, screen.wc, screen.hc, "dynamic")
objeto.bola.radio = 30
objeto.bola.body:setMass(10)
objeto.bola.shape = love.physics.newCircleShape(objeto.bola.radio)
objeto.bola.fixture = love.physics.newFixture(objeto.bola.body, objeto.bola.shape, 1)
objeto.bola.fixture:setRestitution(0.9)
objeto.bola.fixture:setUserData("bola")
objeto.suelo = {}
objeto.suelo.alto = 50
objeto.suelo.ancho = screen.w
objeto.suelo.body = love.physics.newBody(world, screen.wc, screen.h-(objeto.suelo.alto/2))
objeto.suelo.shape = love.physics.newRectangleShape(screen.w, objeto.suelo.alto)
objeto.suelo.fixture = love.physics.newFixture(objeto.suelo.body, objeto.suelo.shape);
objeto.suelo.fixture:setUserData("suelo")
objeto.pizquierda = {}
objeto.pizquierda.alto = screen.h
objeto.pizquierda.ancho = 50
objeto.pizquierda.body = love.physics.newBody(world, objeto.pizquierda.ancho/2, screen.hc)
objeto.pizquierda.shape = love.physics.newRectangleShape(objeto.pizquierda.ancho, objeto.pizquierda.alto)
objeto.pizquierda.fixture = love.physics.newFixture(objeto.pizquierda.body, objeto.pizquierda.shape);
objeto.pizquierda.fixture:setUserData("pizquierda")
objeto.pderecha = {}
objeto.pderecha.alto = screen.h
objeto.pderecha.ancho = 50
objeto.pderecha.body = love.physics.newBody(world, screen.w-(objeto.pderecha.ancho/2), screen.hc)
objeto.pderecha.shape = love.physics.newRectangleShape(objeto.pderecha.ancho, objeto.pderecha.alto)
objeto.pderecha.fixture = love.physics.newFixture(objeto.pderecha.body, objeto.pderecha.shape);
objeto.pderecha.fixture:setUserData("pderecha")
objeto.cielo = {}
objeto.cielo.alto = 50
objeto.cielo.ancho = screen.w
objeto.cielo.body = love.physics.newBody(world, screen.wc, objeto.cielo.alto/2)
objeto.cielo.shape = love.physics.newRectangleShape(objeto.cielo.ancho, objeto.cielo.alto)
objeto.cielo.fixture = love.physics.newFixture(objeto.cielo.body, objeto.cielo.shape);
objeto.cielo.fixture:setUserData("cielo")
puntuacion = 0
puntuacion_max = 0
sonido = love.audio.newSource("bola.ogg")
end