-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.lua
81 lines (73 loc) · 2.07 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
77
78
79
80
81
love.graphics.setDefaultFilter("nearest", "nearest")
love.filesystem.setRequirePath("src/?.lua")
local log = require "log"
local state = require "state"
local input = require "input"
local util = require "util"
local config = require "config"
function love.load ()
love.window.setMode(240*config.scale, 160*config.scale)
if os.getenv('DIG_DEBUG') then
_G.DEBUG = {
input = true,
joystick = true,
debugaudio = false,
debuggems = false,
player = false,
player_invincible = false,
strings = {},
show = function (s, duration)
local ser = util.serialize(s)
local height = 1
for _ in ser:gmatch('\n') do
height = height + 1
end
DEBUG.strings[#DEBUG.strings+1] = {
text = ser,
height = height,
duration = duration or 1,
}
end,
}
end
local font = love.graphics.newFont('res/grand9k.ttf', 8, 'mono')
love.graphics.setFont(font)
end
local time = 0
function love.update (dt)
time = time + dt
local framelen = 1/60
if time >= 0 then
time = time - framelen
state:update()
input.update()
end
end
function love.draw ()
love.graphics.push()
love.graphics.setBlendMode("alpha", "alphamultiply")
love.graphics.scale(config.scale, config.scale)
state:draw()
love.graphics.pop()
if _G.DEBUG then
_G.DEBUG.show(collectgarbage("count"))
local height = 0
for i,s in ipairs(_G.DEBUG.strings) do
height = height + s.height
end
love.graphics.setColor(0,0,0)
love.graphics.rectangle('fill',5,10,150,height*12+5)
love.graphics.setColor(1,1,1)
local height = 0
local newstrs = {}
for i,s in ipairs(_G.DEBUG.strings) do
love.graphics.print(s.text, 5, 12*height+10)
height = height + s.height
s.duration = s.duration - 1
if s.duration > 0 then
newstrs[#newstrs+1] = s
end
end
_G.DEBUG.strings = newstrs
end
end