/ld26

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

« back to all changes in this revision

Viewing changes to main.lua

  • Committer: Josh C
  • Date: 2013-04-27 17:56:22 UTC
  • Revision ID: josh@9ix.org-20130427175622-ksu8aap9zjpcicvx
add shore, first pass level switching

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
STRICT = true
 
2
DEBUG = true
 
3
 
 
4
require 'zoetrope'
 
5
 
 
6
--require 'sprite'
 
7
require 'version'
 
8
 
 
9
require 'player'
 
10
 
 
11
GameView = View:extend {
 
12
   onNew = function (self)
 
13
              self:newLevel('forest1')
 
14
 
 
15
              --self:loadLayers('data/map.lua')
 
16
              --self.focus = the.player
 
17
              --self:clampTo(self.map)
 
18
           end,
 
19
   draw = function (self, x, y)
 
20
             View.draw(self, x, y)
 
21
             love.graphics.print('FPS:' .. love.timer.getFPS(), 20, 20)
 
22
             love.graphics.print('version:' .. VERSION, 20, 570)
 
23
          end,
 
24
   onUpdate = function (self, dt)
 
25
                 if the.keys:justPressed('a') then
 
26
                    self:newLevel('forest1')
 
27
                 elseif the.keys:justPressed('b') then
 
28
                    self:newLevel('shore')
 
29
                 end
 
30
              end,
 
31
   newLevel = function (self, level)
 
32
                 self.sprites = {}
 
33
                 bg = Tile:new{image = 'data/' .. level .. '-bg.png'}
 
34
                 fg = Tile:new{image = 'data/' .. level .. '-fg.png'}
 
35
                 the.player = Player:new{x = 196, y = 350}
 
36
                 self:add(bg)
 
37
                 self:add(the.player)
 
38
                 self:add(fg)
 
39
              end
 
40
}
 
41
 
 
42
the.app = App:new {
 
43
   onRun = function (self)
 
44
              self.view = GameView:new()
 
45
              if DEBUG then
 
46
                 self.console:watch('VERSION', 'VERSION')
 
47
                 self.console:watch('updateTook', 'the.updateTook')
 
48
                 --self.console:watch('drawTook', 'the.drawTook')
 
49
              end
 
50
           end,
 
51
   onUpdate = function (self, dt)
 
52
                 if the.keys:justPressed('escape') then
 
53
                    self.quit()
 
54
                 end
 
55
              end,
 
56
   update = function (self, dt)
 
57
               the.updateStart = love.timer.getMicroTime()
 
58
               App.update(self, dt)
 
59
               if the.updateStart then
 
60
                  the.updateTook = love.timer.getMicroTime() - the.updateStart
 
61
               end
 
62
            end
 
63
}