/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-03-16 19:31:02 UTC
  • Revision ID: josh@9ix.org-20130316193102-68imraus0srbj653
don't go off the edge

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
5
3
 
6
4
require 'zoetrope'
7
5
__ = require 'underscore'
15
13
      elseif dir == 'y' then
16
14
         return 'height'
17
15
      else
18
 
         if STRICT then error('dir '..dir) end
 
16
         print 'dir ??'
19
17
      end
20
18
   end
21
19
}
79
77
                  if minVel[dir] and vel[dir] < minVel[dir] then vel[dir] = minVel[dir] end
80
78
                  if maxVel[dir] and vel[dir] > maxVel[dir] then vel[dir] = maxVel[dir] end
81
79
 
82
 
                  -- ugly hack for falling through floor on really slow frames
83
 
                  if math.abs(vel[dir] * elapsed) > 32 then
84
 
                     print('skip')
85
 
                     return
86
 
                  end
87
 
 
88
80
                  if vel[dir] ~= 0 then self[dir] = self[dir] + vel[dir] * elapsed end
89
81
 
90
82
                  if self[dir] < 0 then self[dir] = 0 end
234
226
   other[dir] = other[dir] + chg
235
227
end
236
228
 
237
 
function Sprite:update (elapsed)
238
 
   if self.onUpdate then self:onUpdate(elapsed) end
239
 
end
240
 
 
241
229
GameView = View:extend {
242
230
   onNew = function (self)
243
231
              self:loadLayers('data/map.lua')
244
232
              self.focus = the.player
245
233
              self:clampTo(self.map)
246
 
 
247
 
              the.recorder = Recorder:new{mousePosInterval = 9999}
248
 
              the.app.meta:add(the.recorder)
249
 
              if RECORD then
250
 
                 the.recorder:startRecording()
251
 
              elseif PLAYBACK then
252
 
                 local storage = Storage:new{filename = 'record.lua'}
253
 
                 storage:load()
254
 
                 --print(inspect(storage.data))
255
 
                 the.recorder.record = storage.data
256
 
                 the.recorder:startPlaying()
257
 
              end
258
234
           end,
259
235
   onUpdate = function (self)
260
 
                 --print('drawTook: ', the.drawTook)
261
236
                 --print('tick')
262
237
                 --the.player:collide(self.map)
263
238
                 --self.map:collide(the.player)
264
 
              end,
265
 
   -- draw = function (self, x, y)
266
 
   --           View.draw(self, x, y)
267
 
 
268
 
   --           love.graphics.print('FPS:' .. love.timer.getFPS(), 20, 20)
269
 
   --        end
 
239
              end
270
240
}
271
241
 
272
242
the.app = App:new {
277
246
              self.console:watch('onWall', 'the.player.onWall')
278
247
              self.console:watch('updateTook', 'the.updateTook')
279
248
              self.console:watch('drawTook', 'the.drawTook')
280
 
              self.console:watch('recorder state', 'the.recorder.state')
281
249
 
282
250
              --the.profiler = newProfiler('time', 2000)
283
251
              --the.profiler = newProfiler()
292
260
                       outfile:close()
293
261
                    end
294
262
 
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
 
 
307
263
                    self.quit()
308
264
                 end
309
265
              end,