/ld27

To get this branch, use:
bzr branch http://9ix.org/bzr/ld27
1 by Josh C
zoetrope 1.4
1
-- copy references to existing globals so that
2
-- debug.reload() will have a correct initial starting point.
3
4
if DEBUG then
5
	-- remember initial state
6
7
	local _initialGlobals = {}
8
	local _initialPackages = {}
9
10
	for key, value in pairs(_G) do
11
		_initialGlobals[key] = value
12
	end
13
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
18
19
		if type(value) ~= 'userdata' then
20
			_initialPackages[key] = value
21
		end
22
	end
23
24
	debugger =
25
	{
26
		_initialGlobals = _initialGlobals,
27
		_initialPackages = _initialPackages,
28
		_originalErrhand = love.errhand,
29
		_crashed = false
30
	}
31
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
37
38
	love.errhand = function (message)
35 by Josh C
cluke009 zoetrope + my spritebatch changes
39
		if debugger._handleCrash then debugger._handleCrash(message) end
1 by Josh C
zoetrope 1.4
40
	end
41
end
42
43
-- Warn about accessing undefined globals in strict mode
44
45
if STRICT then
46
	setmetatable(_G, {
47
		__index = function (table, key)
48
			local info = debug.getinfo(2, 'Sl')
35 by Josh C
cluke009 zoetrope + my spritebatch changes
49
			local print = debugger.unsourcedPrint or print
1 by Josh C
zoetrope 1.4
50
			print('Warning: accessing undefined global ' .. key .. ', ' ..
51
				  info.short_src .. ' line ' .. info.currentline)
52
		end
53
	})
54
end
55
56
require 'zoetrope.core.class'
57
58
require 'zoetrope.core.app'
59
require 'zoetrope.core.cached'
60
require 'zoetrope.core.collision'
61
require 'zoetrope.core.globals'
62
require 'zoetrope.core.sprite'
63
require 'zoetrope.core.group'
64
require 'zoetrope.core.promise'
65
require 'zoetrope.core.timer'
66
require 'zoetrope.core.tween'
67
require 'zoetrope.core.view'
68
69
require 'zoetrope.input.gamepad'
70
require 'zoetrope.input.keys'
71
require 'zoetrope.input.mouse'
72
73
require 'zoetrope.sprites.animation'
74
require 'zoetrope.sprites.emitter'
75
require 'zoetrope.sprites.fill'
76
require 'zoetrope.sprites.map'
77
require 'zoetrope.sprites.text'
78
require 'zoetrope.sprites.tile'
79
80
require 'zoetrope.ui.button'
81
require 'zoetrope.ui.cursor'
82
require 'zoetrope.ui.textinput'
83
84
require 'zoetrope.utils.factory'
85
require 'zoetrope.utils.recorder'
86
require 'zoetrope.utils.storage'
87
require 'zoetrope.utils.subview'
88
35 by Josh C
cluke009 zoetrope + my spritebatch changes
89
if DEBUG then
90
	require 'zoetrope.debug.instrument'
91
	require 'zoetrope.debug.console'
92
	require 'zoetrope.debug.locals'
93
	require 'zoetrope.debug.performance'
94
	require 'zoetrope.debug.shortcuts'
95
	require 'zoetrope.debug.stack'
96
	require 'zoetrope.debug.stepper'
97
	require 'zoetrope.debug.watch'
98
	require 'zoetrope.debug.debugger'
99
end
100
1 by Josh C
zoetrope 1.4
101
-- simple load function to bootstrap the app if love.load() hasn't already been defined;
102
-- defining it again after this works fine as well
103
104
if not love.load then
105
	love.load = function()
106
		if the.app then
107
			-- if we only extended an app, instantiate it
108
			if not (the.app.view and the.app.meta) then the.app = the.app:new() end
109
			the.app:run()
110
		end
111
	end
112
end