This is code:
Code: Select all
require('variables')
local obj = {}
function addObj(x, y)
table.insert(obj, {
x = x,
y = y,
numeroaleatorio = math.random(20)
})
end
function draw(y1, y2, x1, x2)
love.graphics.draw(love.graphics.newImage( "imagens/spacial.png" ), x1, y1, 0, 0.05, 0.05)
love.graphics.draw(love.graphics.newImage( "imagens/bomba.png" ), x2, y2, 0, 0.05, 0.05)
end
function checacolisao(x1, y1, w1, h1, x2, y2, w2, h2)
return x1 < x2 + w2 and x2 < x1 + w1 and y1 < y2 + h2 and y2 < y1 + h1
end
function love.load()
love.graphics.setDefaultFilter("nearest", "nearest")
end
function love.update(dt)
addObj(math.random(love.graphics.getWidth()), 0)
for i, obj in ipairs(obj) do
obj.y = obj.y + gravity
if obj.y > w/2 then
table.remove(obj, i)
end
end
--if checacolisao()
love.mouse.setVisible(true)
end
function love.draw()
love.graphics.draw(love.graphics.newImage( "imagens/space.png" ), spaceX, spaceY, 0, 1, 1)
love.graphics.print("pontos: " .. pontos .. "fps: " .. love.timer.getFPS(), 10, 10)
for i = 1, #obj do
if obj[i].numeroaleatorio == 8 then love.graphics.draw(love.graphics.newImage( "imagens/spacial.png" ), obj[i].x, obj[i].y, 0, 0.05, 0.05) else
love.graphics.draw(love.graphics.newImage( "imagens/bomba.png" ), obj[i].x, obj[i].y, 0, 0.05, 0.05)
end
end
love.graphics.draw(love.graphics.newImage( "imagens/enemy.png" ), posX, 400, 0, 0.2, 0.2, 90, 0)
end