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
|
require "src.events"
require "src.ecs"
require "src.utils"
require "src.input"
require "src.textures"
require "src.phys"
require "src.sprite"
require "src.state_machine"
require "src.im"
require "src.room_editor"
require "src.export"
require "src.sound"
require "src.specks"
require "src.camera"
SCR_WIDTH = 320
SCR_HEIGHT = 180
GRAVITY = 1000
TERMINAL_VELOCITY = 900
WindowScale = 1
register_input("Left", {{"key", "left"}, {"key", "a"}})
register_input("Right", {{"key", "right"}, {"key", "d"}})
register_input("Jump", {{"key", "space"}})
register_input("Dash", {{"key", "lshift"}})
register_input("Right_Click", {{"mouse", 2}})
register_input("Left_Click", {{"mouse", 1}})
li = love.image
la = love.audio
lg = love.graphics
lf = love.filesystem
lw = love.window
lmath = love.math
function init_global_systems()
event_bind(global_on_update, "Body", body_sys)
event_bind(global_on_update, "State_Machine", state_update_sys)
event_bind(global_on_update, "Sprite", sprite_anim_sys)
event_bind(global_on_update, "Speck_System", speck_update_sys)
event_bind(global_on_update, "Speck_Entity", speck_entity_system)
event_bind(global_on_update, "Camera", camera_move_system)
event_bind(global_on_draw, "Sprite", sprite_draw_sys)
event_bind(global_on_draw, "Tilemap", tilemap_draw_sys)
event_bind(global_on_draw, "Speck_System", speck_draw_sys)
end
function reload_assets()
-- TODO:
-- would be cool if it also made already loaded sprites and specks reload
-- probably do some expensive thing to update, but strip it on build
load_textures_from()
load_sounds_from()
load_specks_from()
end
local function load_dir(path)
local files = lf.getDirectoryItems(path)
for _, file in ipairs(files) do
local filepath = path.."/"..file
if lf.getInfo(filepath).type == "directory" then
load_dir(filepath)
else
lf.load(filepath)();
end
end
end
function main_init()
lg.setDefaultFilter("nearest", "nearest")
viewport = lg.newCanvas(SCR_WIDTH, SCR_HEIGHT)
reload_assets()
load_dir("src/objs")
load_dir("src/scenes")
init_global_systems()
end
|