1
-- copy references to existing globals so that
2
-- debug.reload() will have a correct initial starting point.
5
-- remember initial state
7
local _initialGlobals = {}
8
local _initialPackages = {}
10
for key, value in pairs(_G) do
11
_initialGlobals[key] = value
14
for key, value in pairs(package.loaded) do
15
-- it looks as though the type of a module
16
-- that is currently being loaded, but hasn't
17
-- completed is userdata
19
if type(value) ~= 'userdata' then
20
_initialPackages[key] = value
26
_initialGlobals = _initialGlobals,
27
_initialPackages = _initialPackages,
28
_originalErrhand = love.errhand,
32
-- replace crash handler
33
-- we have to do this at this stage; there seems to be
34
-- some magic that happens to connect to this function
35
-- such that changing it later, even when creating the
36
-- initial view, doesn't work
38
love.errhand = function (message)
39
if debugger._crashed then
40
debugger._originalErrhand(message)
44
if the.console and the.keys then
45
debugger._crashed = true
46
print(string.rep('=', 40))
47
print('\nCrash, ' .. message .. '\n')
48
print(debug.traceback())
49
print('\n' .. string.rep('=', 40) .. '\n')
53
-- enter a mini event loop, just updating the
62
for e, a, b, c, d in love.event.poll() do
64
if not love.quit or not love.quit() then return end
67
love.handlers[e](a, b, c, d)
73
elapsed = love.timer.getDelta()
76
the.keys:startFrame(elapsed)
77
the.console:startFrame(elapsed)
78
the.keys:update(elapsed)
79
the.console:update(elapsed)
80
the.keys:endFrame(elapsed)
81
the.console:endFrame(elapsed)
83
if the.keys:pressed('escape') then
84
if not love.quit or not love.quit() then return end
94
if love.timer then love.timer.sleep(0.02) end
95
if love.graphics then love.graphics.present() end
98
debugger._originalErrhand(message)
103
-- Warn about accessing undefined globals in strict mode
107
__index = function (table, key)
108
local info = debug.getinfo(2, 'Sl')
109
print('Warning: accessing undefined global ' .. key .. ', ' ..
110
info.short_src .. ' line ' .. info.currentline)
115
require 'zoetrope.core.class'
117
require 'zoetrope.core.app'
118
require 'zoetrope.core.cached'
119
require 'zoetrope.core.collision'
120
require 'zoetrope.core.globals'
121
require 'zoetrope.core.sprite'
122
require 'zoetrope.core.group'
123
require 'zoetrope.core.promise'
124
require 'zoetrope.core.timer'
125
require 'zoetrope.core.tween'
126
require 'zoetrope.core.view'
128
require 'zoetrope.input.gamepad'
129
require 'zoetrope.input.keys'
130
require 'zoetrope.input.mouse'
132
require 'zoetrope.sprites.animation'
133
require 'zoetrope.sprites.emitter'
134
require 'zoetrope.sprites.fill'
135
require 'zoetrope.sprites.map'
136
require 'zoetrope.sprites.text'
137
require 'zoetrope.sprites.tile'
139
require 'zoetrope.ui.button'
140
require 'zoetrope.ui.cursor'
141
require 'zoetrope.ui.textinput'
143
require 'zoetrope.utils.debug'
144
require 'zoetrope.utils.factory'
145
require 'zoetrope.utils.recorder'
146
require 'zoetrope.utils.storage'
147
require 'zoetrope.utils.subview'
149
-- simple load function to bootstrap the app if love.load() hasn't already been defined;
150
-- defining it again after this works fine as well
152
if not love.load then
153
love.load = function()
155
-- if we only extended an app, instantiate it
156
if not (the.app.view and the.app.meta) then the.app = the.app:new() end