aboutsummaryrefslogtreecommitdiff
path: root/src/init.lua
blob: 637dafda9d4f817e9d9154bbf214fe1bbef91dd4 (plain)
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
require "src.events"
require "src.ecs"
require "src.utils"
require "src.input"
require "src.textures"
require "src.phys"
require "src.sprite"
require "src.im"

SCR_WIDTH = 320
SCR_HEIGHT = 180
WindowScale = 1

register_input("Left",  {{"key", "left"},  {"key", "a"}})
register_input("Right", {{"key", "right"}, {"key", "d"}})
register_input("Down",  {{"key", "down"},  {"key", "s"}})
register_input("Up",    {{"key", "up"},    {"key", "w"}})

register_input("Right_Click", {{"mouse", 1}})
register_input("Left_Click",  {{"mouse", 2}})

lg = love.graphics
lf = love.filesystem
lw = love.window
lmath = love.math

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)
  lw.setVSync(1)

  load_textures_from()

  load_dir("src/objs")
  load_dir("src/scenes")
end