-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.lua
More file actions
75 lines (61 loc) · 1.58 KB
/
main.lua
File metadata and controls
75 lines (61 loc) · 1.58 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
require "globals"
local Game = require "systems.game"
local DebugMenu = require "systems.debugMenu"
local ConstantsMenu = require "systems.constantsMenu"
-- global key-handling
love.keyboard.keysPressed = {}
love.keyboard.keysReleased = {}
function love.load()
love.graphics.setDefaultFilter("nearest", "nearest")
love.physics.setMeter(_G.PIXELS_PER_METER)
Game:load()
DebugMenu:load()
ConstantsMenu:load()
end
function love.mousepressed(x, y, button, _) -- isTouch not used
DebugMenu:mousepressed(x, y, button)
ConstantsMenu:mousepressed(x, y, button)
end
function love.keyboard.wasPressed(key)
if love.keyboard.keysPressed[key] then
return true
else
return false
end
end
function love.keyboard.wasReleased(key)
if love.keyboard.keysReleased[key] then
return true
else
return false
end
end
function love.update(dt)
Game:update(dt)
-- reset all keys pressed and released
love.keyboard.keysPressed = {}
love.keyboard.keysReleased = {}
end
function love.draw()
Game:draw()
DebugMenu:draw()
ConstantsMenu:draw()
if _G.DEBUGGING then
local x, y = love.mouse.getPosition()
local text = "X:" .. x .. " Y:" .. y
love.graphics.print(text, x, y - 15)
end
end
function love.textinput(t)
ConstantsMenu:textinput(t)
end
function love.keypressed(key)
if key == "f3" then
ConstantsMenu:toggle()
end
ConstantsMenu:keypressed(key)
love.keyboard.keysPressed[key] = true
end
function love.keyreleased(key)
love.keyboard.keysReleased[key] = true
end