/ld27

To get this branch, use:
bzr branch http://9ix.org/bzr/ld27

« back to all changes in this revision

Viewing changes to zoetrope/init.lua

  • Committer: Josh C
  • Date: 2013-08-24 19:37:30 UTC
  • Revision ID: josh@9ix.org-20130824193730-ahyzlm50f169fc24
slow level + tiny player

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
        -- initial view, doesn't work
37
37
 
38
38
        love.errhand = function (message)
39
 
                if debugger._handleCrash then debugger._handleCrash(message) end
 
39
                if debugger._crashed then
 
40
                        debugger._originalErrhand(message)
 
41
                        return
 
42
                end
 
43
 
 
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')
 
50
                        the.console:show()
 
51
                        love.audio.stop()
 
52
 
 
53
                        -- enter a mini event loop, just updating the
 
54
                        -- console and keys
 
55
 
 
56
                        local elapsed = 0
 
57
 
 
58
                        while true do
 
59
                                if love.event then
 
60
                                        love.event.pump()
 
61
                                        
 
62
                                        for e, a, b, c, d in love.event.poll() do
 
63
                                                if e == 'quit' then
 
64
                                                        if not love.quit or not love.quit() then return end
 
65
                                                end
 
66
 
 
67
                                                love.handlers[e](a, b, c, d)
 
68
                                        end
 
69
                                end
 
70
 
 
71
                                if love.timer then
 
72
                                        love.timer.step()
 
73
                                        elapsed = love.timer.getDelta()
 
74
                                end
 
75
 
 
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)
 
82
 
 
83
                                if the.keys:pressed('escape') then
 
84
                                        if not love.quit or not love.quit() then return end
 
85
                                end
 
86
 
 
87
                                if love.graphics then
 
88
                                        love.graphics.clear()
 
89
                                        if love.draw then
 
90
                                                the.console:draw()
 
91
                                        end
 
92
                                end
 
93
 
 
94
                                if love.timer then love.timer.sleep(0.02) end
 
95
                                if love.graphics then love.graphics.present() end
 
96
                        end
 
97
                else
 
98
                        debugger._originalErrhand(message)
 
99
                end
40
100
        end
41
101
end
42
102
 
46
106
        setmetatable(_G, {
47
107
                __index = function (table, key)
48
108
                        local info = debug.getinfo(2, 'Sl')
49
 
                        local print = debugger.unsourcedPrint or print
50
109
                        print('Warning: accessing undefined global ' .. key .. ', ' ..
51
110
                                  info.short_src .. ' line ' .. info.currentline)
52
111
                end
81
140
require 'zoetrope.ui.cursor'
82
141
require 'zoetrope.ui.textinput'
83
142
 
 
143
require 'zoetrope.utils.debug'
84
144
require 'zoetrope.utils.factory'
85
145
require 'zoetrope.utils.recorder'
86
146
require 'zoetrope.utils.storage'
87
147
require 'zoetrope.utils.subview'
88
148
 
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
 
 
101
149
-- simple load function to bootstrap the app if love.load() hasn't already been defined;
102
150
-- defining it again after this works fine as well
103
151