-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.lua
74 lines (61 loc) · 1.97 KB
/
main.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
local Entity = require('services/entity')
local keyboard = require('services/keyboard')
local Camera = require('services/camera')
local menu = require('menu/menu')
local textures = require('services/textures')
local background = require('services/background')
local HUD = require('services/HUD')
local map = require('services/map')
local State = require 'services/state'
local save = require('services/save')
local ControlPlayer = require('systems/ControlPlayer')
local Gravitate = require('systems/Gravitate')
local UpdateCamera = require('systems/UpdateCamera')
local UpdateEntityAnimation = require('systems/UpdateEntityAnimation')
local SpaceFriction = require('systems/SpaceFriction')
love.load = function()
love.window.updateMode(State.camera.window_width, State.camera.window_height)
love.graphics.setDefaultFilter('nearest', 'nearest')
textures.load()
love.globalFont = love.graphics.newFont('assets/gnevejpixel.ttf', 30)
love.graphics.setFont(love.globalFont)
love.starLocations = background.load()
save.read()
menu.load()
end
-- Game time
love.keypressed = function(pressed_key)
if State.paused then
menu.current_menu_keys(pressed_key)
else
if keyboard.key_map[pressed_key] then
keyboard.key_map[pressed_key]()
end
end
end
love.draw = function()
Camera.set()
background.draw(love.starLocations) -- Currently bugged with how stars update to new resolution
map.draw()
if State.paused == true then
menu.draw()
else
HUD.draw()
end
Camera.unset()
end
love.update = function(dt)
if State.paused == false then
State.world:update(dt)
State.seconds = State.seconds + dt
for _, entity in ipairs(Entity.list) do
ControlPlayer(entity, dt)
Gravitate(entity)
SpaceFriction(entity, dt)
UpdateCamera(entity)
UpdateEntityAnimation(entity, dt)
end
else
menu.update(dt)
end
end