/
main.lua
76 lines (60 loc) · 1.81 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
75
76
Vector = require "lib.hump.vector"
Class = require "lib.hump.class"
Utils = require "engine.utils.utils"
require "settings"
prof = require "lib.jprof.jprof"
StateManager = require "lib.hump.gamestate"
AssetManager = require "engine.utils.asset_manager"
AssetManager:load("data")
local SoundData = require "data.sound.sound_data"
SoundManager = require "engine.sound.sound_manager" (SoundData)
local MusicData = require "data.music.music_data"
MusicPlayer = require "engine.sound.music_player" (MusicData)
fonts = require "data.fonts.fonts"
states = {
game = require "game.states.game",
}
function love.load()
love.graphics.setDefaultFilter('nearest', 'nearest')
StateManager.switch(states.game)
love.keyboard.setKeyRepeat( true )
end
function love.draw()
love.graphics.setFont(fonts.thin.font)
StateManager.draw()
if Debug and Debug.showFps == 1 then
love.graphics.print(""..tostring(love.timer.getFPS( )), 2, 2)
end
if Debug and Debug.mousePos == 1 then
local x, y = love.mouse.getPosition()
love.graphics.print(""..tostring(x)..","..tostring(y), 2, 16)
end
prof.pop("frame")
end
function love.fixedUpdate(dt)
prof.push("frame")
StateManager.update(dt)
end
function love.mousepressed(x, y)
if StateManager.current().mousepressed then
StateManager.current():mousepressed(x, y)
end
end
function love.mousereleased(x, y)
if StateManager.current().mousereleased then
StateManager.current():mousereleased(x, y)
end
end
function love.keypressed(key)
if StateManager.current().keypressed then
StateManager.current():keypressed(key)
end
end
function love.quit()
prof.write("prof.mpack")
end
function love.resize( w, h )
if StateManager.current().resize then
StateManager.current():resize(w, h)
end
end