Repository navigation
Expand file tree
/
Copy pathmain.lua
More file actions
138 lines (109 loc) · 3.06 KB
/
Copy pathmain.lua
File metadata and controls
138 lines (109 loc) · 3.06 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
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
local _gameTitle = "Conclavus"
local _start = os.clock()
local _curTime, _prntcnt = 0, 0
local _input
local lw = love.window
__NULL__ = function() end -- null function so you can do "(a or __NULL__)(...)" instead of "if (a != nil) then a(...) end".
currentTime = function() return _curTime end
local oldprint = print
function print( ... )
oldprint("[".._prntcnt.."]", ...)
_prntcnt = _prntcnt + 1
end
function _inputController()
return _input
end
game = {}
require("engine/engine_includes")
require("game/game_includes")
function love.load( arg )
-- zerobrane studio support
if arg[#arg] == "-debug" then require("mobdebug").start() end
_curTime = 0
local libdiff = os.clock() - _start
_start = os.clock()
math.randomseed(_start)
-------------------------------------------------------
love.joystick.loadGamepadMappings( "gamecontrollerdb.txt" )
_input = InputController()
screen.init( lw.getMode() )
lovebird.init()
game.load()
-------------------------------------------------------
print("-- Initializing ".._gameTitle.." --")
print("Loaded libraries in "..math.round(libdiff*1000).."ms")
local initdiff = os.clock() - _start
print("Initialized game in "..math.round(initdiff*1000).."ms")
end
function love.update( dt )
_curTime = _curTime + dt
lw.setTitle(_gameTitle.." ("..love.timer.getFPS().." fps)")
lovebird.update()
timer.update(dt)
resource.update()
game.update(dt)
loveframes.update( dt )
_input:clear()
-- hotswap changed files
package.updatePackages()
end
function love.draw()
screen.preDraw()
game.draw()
loveframes.draw()
screen.postDraw()
end
function love.mousepressed(x, y, button)
x, y = screen.getMousePosition() -- correct coordinates
_input:handle_mousepressed(x, y, button)
loveframes.mousepressed(x, y, button)
end
function love.mousereleased(x, y, button)
x, y = screen.getMousePosition()
_input:handle_mousereleased(x, y, button)
loveframes.mousereleased(x, y, button)
end
function love.mousemoved( x, y, dx, dy )
(game.mousemoved or __NULL__)(x, y, dx, dy)
end
function love.keypressed(key, unicode)
_input:handle_keypressed(key, unicode)
loveframes.keypressed(key, unicode)
end
function love.keyreleased(key, unicode)
_input:handle_keyreleased(key, unicode)
loveframes.keyreleased(key)
end
function love.gamepadpressed( joystick, button )
_input:handle_gamepadpressed(joystick, button)
end
function love.gamepadreleased( joystick, button )
_input:handle_gamepadreleased(joystick, button)
end
function love.gamepadaxis( joystick, axis, value )
_input:handle_gamepadaxis( joystick, axis, value )
end
function love.joystickadded( joystick )
_input:handle_gamepadadded(joystick)
end
function love.joystickadded( joystick )
_input:handle_gamepadremoved(joystick)
end
function love.resize( w, h )
screen.resize( w, h )
end
function love.textinput(text)
loveframes.textinput(text)
end
function love.focus( f )
(game.focus or __NULL__)( f )
end
function love.mousefocus( f )
(game.mousefocus or __NULL__)( f )
end
function love.visible( v )
(game.visible or __NULL__)( v )
end
function love.quit()
(game.quit or __NULL__)()
end