-
Notifications
You must be signed in to change notification settings - Fork 0
/
globals.lua
168 lines (154 loc) · 4.76 KB
/
globals.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-- !! This flag controls the ability to toggle the debug view. !!
-- !! You will want to turn this to 'true' when you publish your game. !!
-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
RELEASE = false
-- Enables the debug stats
DEBUG = not RELEASE
require "libs.tablesave"
require "libs.coordinates"
Lume = require "libs.lume"
Class = require "libs.class"
Saver = require "libs.saver"
Timer = require "libs.timer"
Camera = require "libs.camera"
Signal = require "libs.signal"
Vector = require "libs.vector"
Inspect = require "libs.inspect"
GameState = require "libs.gamestate"
Window = require "libs.window"
Saveable = require "libs.saveable"
Scene = require "house.scene"
System = require "libs.system"
-- MenuEngine = require "libs.menuengine"
Anim8 = require "libs.anim8"
CutScene = require "house.cutscene"
-- MenuEngine.stop_on_nil_functions = true
require "libs.set"
CONFIG = {
graphics = {
filter = {
-- FilterModes: linear (blurry) / nearest (blocky)
-- Default filter used when scaling down
down = "nearest",
-- Default filter used when scaling up
up = "nearest",
-- Amount of anisotropic filter performed
anisotropy = 1
}
},
debug = {
-- The key (scancode) that will toggle the debug state.
-- Scancodes are independent of keyboard layout so it will always be in the same
-- position on the keyboard. The positions are based on an American layout.
key = "`",
stats = {
font = nil, -- set after fonts are created
fontSize = 10,
lineHeight = 12,
foreground = { 1, 1, 1, 1 },
shadow = { 0, 0, 0, 1 },
shadowOffset = {
x = 1,
y = 1
},
position = {
x = 420,
y = 6
},
kilobytes = false
},
-- Error screen config
error = {
font = nil, -- set after fonts are created
fontSize = 16,
background = { .1, .31, .5 },
foreground = { 1, 1, 1 },
shadow = { 0, 0, 0, .88 },
shadowOffset = {
x = 1,
y = 1
},
position = {
x = 70,
y = 70
}
}
}
}
Fonts = {
default = nil,
regular = System.graphics.createFont "assets/fonts/Roboto-Regular.ttf",
bold = System.graphics.createFont "assets/fonts/Roboto-Bold.ttf",
light = System.graphics.createFont "assets/fonts/Roboto-Light.ttf",
thin = System.graphics.createFont "assets/fonts/Roboto-Thin.ttf",
regularItalic = System.graphics.createFont "assets/fonts/Roboto-Italic.ttf",
boldItalic = System.graphics.createFont "assets/fonts/Roboto-BoldItalic.ttf",
lightItalic = System.graphics
.createFont "assets/fonts/Roboto-LightItalic.ttf",
thinItalic = System.graphics.createFont "assets/fonts/Roboto-Italic.ttf",
monospace = System.graphics.createFont "assets/fonts/RobotoMono-Regular.ttf",
pixel = System.graphics.createFont "assets/fonts/Pixel.ttf"
}
-- -@alias Colors table<string, number>
Colors = {
white = { 1, 1, 1, 1 },
black = { 0, 0, 0, 1 },
red = { 255, 0, 0, 1 }
}
Fonts.default = Fonts.regular
CONFIG.debug.stats.font = Fonts.monospace
CONFIG.debug.error.font = Fonts.monospace
Player = nil -- loaded in main
House = nil -- loaded in main
Fade = nil -- loaded in main
Flashlight = nil -- loaded in main
States = {
start = require "states.start",
game = require "states.game",
pause = require "states.pause"
}
Controls = {
up = "up",
down = "down",
left = "left",
right = "right",
a = "a",
b = "s",
start = "enter",
z = "z",
d = "d",
u = "u",
arrowkeys = set("up", "down", "left", "right")
}
GamePad = {
up = Controls.up,
down = Controls.down,
left = Controls.left,
right = Controls.right,
start = Controls.start
}
GamePad.includes = set(
GamePad.up, GamePad.down, GamePad.left, GamePad.right,
GamePad.start
)
function keyOf(table, value)
for k, v in pairs(table) do if v == value then return k end end
return nil
end
function indexOf(table, value)
for k, v in ipairs(table) do if v == value then return k end end
return nil
end
function cloneFunction(fn)
local dumped = string.dump(fn)
local cloned = loadstring(dumped)
local i = 1
while true do
local name = debug.getupvalue(fn, i)
if not name then break end
debug.upvaluejoin(cloned, i, fn, i)
i = i + 1
end
return cloned
end