-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.lua
More file actions
101 lines (82 loc) · 2.54 KB
/
main.lua
File metadata and controls
101 lines (82 loc) · 2.54 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
--// written by melon!
-- Init
love.window.setTitle("Bankr - Release")
local input = require("src.utils.input")
local game = require("src.game.game")
local menu = require("src.game.menu")
local save = require("src.utils.save")
local hud = require("src.ui.hud")
local assets = require("src.utils.assets")
local endings = require("src.scenes.ending")
local loadingImage
function love.load()
loadingImage = love.graphics.newImage('assets/scenes/loading.png')
love.window.setMode( 1280, 720, {
resizable = true,
minwidth = 1280,
minheight = 720
} )
love.keyboard.setKeyRepeat(true)
save:createSaveIfNotExists()
assets:init(function()
menu:init()
endings:Init()
end)
end
function love.resize(w, h)
if game.hud then
game:resize(w, h)
end
menu:resize(w, h)
end
function love.update(dt)
assets:update()
if not assets.loaded then return end
menu:update(dt)
if game.hud then
game:update(dt)
end
if endings.loaded then
endings:Update(dt)
end
end
function love.textinput(text)
if not assets.loaded then return end
input:textinput(text)
menu:textinput(text)
end
function love.keypressed(key)
if not assets.loaded then return end
input:keypressed(key)
game:keypressed(key)
menu:keypressed(key)
end
function love.draw()
if not assets.loaded then
love.graphics.draw(loadingImage, 0, 0, 0, love.graphics.getWidth() / loadingImage:getWidth(), love.graphics.getHeight() / loadingImage:getHeight())
local barWidth = 400
local barHeight = 20
local x = (love.graphics.getWidth() - barWidth) / 2
local y = love.graphics.getHeight() * 0.8
love.graphics.setColor(0.1, 0.1, 0.1, 1)
love.graphics.rectangle("fill", x, y, barWidth, barHeight)
love.graphics.setColor(1, 1, 1, 1)
love.graphics.rectangle("fill", x, y, barWidth * assets:getProgress(), barHeight)
return
end
if menu.currentMode == "game" then
local r, g, b = love.math.colorFromBytes(104, 122, 160)
love.graphics.setBackgroundColor(r, g, b)
game:draw()
else
local r, g, b = love.math.colorFromBytes(118, 135, 173)
love.graphics.setBackgroundColor(r, g, b)
menu:draw()
end
if game.hud then
game.hud:drawEnd()
end
if endings.loaded then
endings:Draw()
end
end