-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.lua
More file actions
95 lines (77 loc) · 2.41 KB
/
main.lua
File metadata and controls
95 lines (77 loc) · 2.41 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
local Font = require("include/font")
Global = require("global")
local World = require("world")
Resources = require("resourceHandler")
util = require("include/util")
local api = {}
--------------------------------------------------
-- Draw
--------------------------------------------------
function love.draw()
World.Draw()
end
function love.resize(width, height)
World.ViewResize(width, height)
end
--------------------------------------------------
-- Input
--------------------------------------------------
function love.mousemoved(x, y, dx, dy, istouch)
World.MouseMoved(x, y, dx, dy)
end
function love.mousereleased(x, y, button, istouch, presses)
World.MouseReleased(x, y, button, istouch, presses)
end
function love.keypressed(key, scancode, isRepeat)
World.KeyPressed(key, scancode, isRepeat)
end
function love.mousepressed(x, y, button, istouch, presses)
World.MousePressed(x, y, button, istouch, presses)
end
--------------------------------------------------
-- Update
--------------------------------------------------
local longFrames = 0
local frames = 0
local missingDt = 0
local MAX_DT = 0.1
function love.update(dt)
local realDt = dt
frames = frames + 1
if dt > 0.05 then
longFrames = longFrames + 1
end
if dt > MAX_DT then
missingDt = (dt - MAX_DT)
dt = MAX_DT
elseif missingDt > 0 then
local returnProp = 0.02 + 0.06 * missingDt / (missingDt + 2)
local toReturn = returnProp * dt
if toReturn > missingDt then
toReturn = missingDt
end
dt = dt + toReturn
missingDt = missingDt - toReturn
end
World.Update(dt, realDt)
end
function Global.ResetMissingDt()
missingDt = 0
end
local util = require("include/util")
--------------------------------------------------
-- Loading
--------------------------------------------------
function love.load(arg)
if arg[#arg] == "-debug" then require("mobdebug").start() end
local major, minor, revision, codename = love.getVersion()
print(string.format("Version %d.%d.%d - %s", major, minor, revision, codename))
love.window.setTitle("Hourglass Editor")
--love.graphics.setDefaultFilter("nearest", "nearest") -- Removing this helps some things and really hurts others
love.graphics.setBackgroundColor(Global.BACK_COL[1], Global.BACK_COL[2], Global.BACK_COL[3], 1)
love.keyboard.setKeyRepeat(true)
math.randomseed(os.clock())
Resources.LoadResources()
World.Initialize()
--love.window.maximize() -- Do not fullscreen since we lack an exit button.
end