/zoeplat

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

« back to all changes in this revision

Viewing changes to main.lua

  • Committer: Josh C
  • Date: 2013-04-10 00:41:47 UTC
  • Revision ID: josh@9ix.org-20130410004147-fj20d61atq2cgyqb
record/playback system (doesn't really work)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
STRICT = true
2
2
DEBUG = true
 
3
RECORD = true
 
4
PLAYBACK = false
3
5
 
4
6
require 'zoetrope'
5
7
__ = require 'underscore'
6
8
--inspect = require 'inspect'
7
9
require 'pepperprof'
8
 
require 'getopt_alt'
9
10
 
10
11
util = {
11
12
   dim = function(dir)
188
189
                  self.jumping = false
189
190
               end
190
191
 
191
 
               -- text blob
192
 
               if not self.text then
193
 
                  self.text = Text:new{wordWrap = true, width = 50, tint = {0,0,0}}
194
 
                  self.textfill = Fill:new{width = 54, border = {0,0,255}}
195
 
                  --the.view:add(self.textfill)
196
 
                  --the.view:add(self.text)
197
 
               end
198
 
               self.text.text = "Blah blah big text etc etc wrapping"
199
 
               self.text:centerAround(self.x+16, self.y+16, 'horizontal')
200
 
               _, texth = self.text:getSize()
201
 
               self.text.y = self.y - texth - 4
202
 
               self.textfill.x = self.text.x - 2
203
 
               self.textfill.y = self.text.y - 2
204
 
               self.textfill.height = texth + 4
205
 
 
206
192
               Animation.update(self, elapsed)
207
193
            end,
208
194
   collide = function (self, ...)
261
247
 
262
248
              the.recorder = Recorder:new{mousePosInterval = 9999}
263
249
              the.app.meta:add(the.recorder)
264
 
              if the.app.record then
 
250
              if RECORD then
265
251
                 the.recorder:startRecording()
266
 
              elseif the.app.playback then
 
252
              elseif PLAYBACK then
267
253
                 local storage = Storage:new{filename = 'record.lua'}
268
254
                 storage:load()
269
255
                 --print(inspect(storage.data))
285
271
}
286
272
 
287
273
the.app = App:new {
288
 
   record = true,
289
274
   onRun = function (self)
290
275
              self.view = GameView:new()
291
276
              self.console:watch('onGround', 'the.player.onGround')
307
292
                       outfile:close()
308
293
                    end
309
294
 
310
 
                    if self.record then
 
295
                    if RECORD then
311
296
                       if not love.filesystem.remove('record.lua') then
312
 
                          print('could not remove record.lua')
 
297
                          error('could not remove record.lua')
313
298
                       end
314
299
                       local storage = Storage:new{
315
300
                          data = the.recorder.record,
330
315
               end
331
316
            end
332
317
}
333
 
 
334
 
function love.load (arg)
335
 
   opts = getopt(arg, '')
336
 
   if opts['p'] then
337
 
      the.app.playback = true
338
 
      the.app.record = false
339
 
   elseif opts['r'] then
340
 
      the.app.record = true
341
 
   end
342
 
 
343
 
   the.app:run()
344
 
end
 
 
b'\\ No newline at end of file'