/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'
13
15
      elseif dir == 'y' then
14
16
         return 'height'
15
17
      else
16
 
         print 'dir ??'
 
18
         if STRICT then error('dir '..dir) end
17
19
      end
18
20
   end
19
21
}
242
244
              self:loadLayers('data/map.lua')
243
245
              self.focus = the.player
244
246
              self:clampTo(self.map)
 
247
 
 
248
              the.recorder = Recorder:new{mousePosInterval = 9999}
 
249
              the.app.meta:add(the.recorder)
 
250
              if RECORD then
 
251
                 the.recorder:startRecording()
 
252
              elseif PLAYBACK then
 
253
                 local storage = Storage:new{filename = 'record.lua'}
 
254
                 storage:load()
 
255
                 --print(inspect(storage.data))
 
256
                 the.recorder.record = storage.data
 
257
                 the.recorder:startPlaying()
 
258
              end
245
259
           end,
246
260
   onUpdate = function (self)
247
261
                 --print('drawTook: ', the.drawTook)
248
262
                 --print('tick')
249
263
                 --the.player:collide(self.map)
250
264
                 --self.map:collide(the.player)
251
 
              end
 
265
              end,
 
266
   -- draw = function (self, x, y)
 
267
   --           View.draw(self, x, y)
 
268
 
 
269
   --           love.graphics.print('FPS:' .. love.timer.getFPS(), 20, 20)
 
270
   --        end
252
271
}
253
272
 
254
273
the.app = App:new {
258
277
              self.console:watch('onWall', 'the.player.onWall')
259
278
              self.console:watch('updateTook', 'the.updateTook')
260
279
              self.console:watch('drawTook', 'the.drawTook')
 
280
              self.console:watch('recorder state', 'the.recorder.state')
261
281
 
262
282
              --the.profiler = newProfiler('time', 2000)
263
283
              --the.profiler = newProfiler()
272
292
                       outfile:close()
273
293
                    end
274
294
 
 
295
                    if RECORD then
 
296
                       if not love.filesystem.remove('record.lua') then
 
297
                          error('could not remove record.lua')
 
298
                       end
 
299
                       local storage = Storage:new{
 
300
                          data = the.recorder.record,
 
301
                          filename = 'record.lua'
 
302
                       }
 
303
                       storage:save(false)
 
304
                       --print(inspect(the.recorder.record))
 
305
                    end
 
306
 
275
307
                    self.quit()
276
308
                 end
277
309
              end,