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.
52 lines
1.3 KiB
52 lines
1.3 KiB
Object = require("scripts.classic")
|
|
require("entities.player")
|
|
require("entities.enemy")
|
|
require("userInterface")
|
|
require("masterController")
|
|
|
|
function love.load()
|
|
--adjust the screen and set the bounds of the UI
|
|
ui = User_Interface(600, 800)
|
|
local window_width = love.graphics.getWidth()
|
|
local window_height = love.graphics.getHeight()
|
|
local bounds = ui:returnBounds()
|
|
|
|
print("Playable Bounds: ", bounds[1], " , ", bounds[2])
|
|
--place the player in the middle of the screen, close to the bottom
|
|
Player = Player(window_width / 2, window_height * 0.9, bounds)
|
|
Controller = MasterController()
|
|
|
|
ListOfEnemies = {}
|
|
|
|
table.insert(ListOfEnemies, Enemy((bounds[1] + 50), 100, 70, bounds))
|
|
table.insert(ListOfEnemies, Enemy((bounds[1] + bounds[2]) / 2, 125, 70, bounds))
|
|
table.insert(ListOfEnemies, Enemy((bounds[2] - 50), 75, 70, bounds))
|
|
|
|
--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
|
|
|