A Little Space Game made in Love2D
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
967 B

function love.load()
Object = require("scripts.classic")
require("entities.player")
require("entities.enemy")
require("ui")
ui = Ui(600, 800)
local window_width = love.graphics.getWidth()
local window_height = love.graphics.getHeight()
--place the player in the middle of the screen, close to the bottom
player = Player(window_width / 2, window_height * 0.9)
listOfEnemies = {}
table.insert(listOfEnemies, Enemy(100, 100, 70))
--set background for space!
love.graphics.setBackgroundColor(27 / 255, 51 / 255, 85 / 255)
end
function love.update(dt)
player:update(dt, listOfEnemies)
for i, v in ipairs(listOfEnemies) do
if v.destroy == true then
print("Enemy destroyed! Enemies in Table:", #listOfEnemies)
table.remove(listOfEnemies, i)
end
v:update(dt, player)
end
end
function love.draw()
ui:draw()
player:draw()
for _, v in ipairs(listOfEnemies) do
v:draw()
end
end
function love.keypressed(key)
player:keyPressed(key)
end