/ld26

To get this branch, use:
bzr branch http://9ix.org/bzr/ld26
5 by Josh C
load a level, move a player around
1
STRICT = true
2
DEBUG = true
3
4
require 'zoetrope'
5
6
--require 'sprite'
7
require 'version'
8
9
require 'player'
10
9 by Josh C
levels hash, scale player
11
levels = {
12
   forest1 = {
13
      objects = function() return {
14
                      Tile:new{image = 'data/forest1-bg.png'},
15
                      Player:new{x = 200, y = 370, image = 'data/forest1-player.png'},
16
                      Tile:new{image = 'data/forest1-fg.png'}
17
                   } end,
18
   },
19
   shore = {
20
      objects = function() return {
21
                      Tile:new{image = 'data/shore-bg.png'},
22
                      Player:new{x = 145, y = 133, image = 'data/shore-player.png'},
23
                      Tile:new{image = 'data/shore-fg.png'}
24
                   } end
25
   }
26
}
27
5 by Josh C
load a level, move a player around
28
GameView = View:extend {
29
   onNew = function (self)
8 by Josh C
add shore, first pass level switching
30
              self:newLevel('forest1')
5 by Josh C
load a level, move a player around
31
32
              --self:loadLayers('data/map.lua')
33
              --self.focus = the.player
34
              --self:clampTo(self.map)
35
           end,
36
   draw = function (self, x, y)
37
             View.draw(self, x, y)
38
             love.graphics.print('FPS:' .. love.timer.getFPS(), 20, 20)
7 by Josh C
show version
39
             love.graphics.print('version:' .. VERSION, 20, 570)
8 by Josh C
add shore, first pass level switching
40
          end,
41
   onUpdate = function (self, dt)
42
                 if the.keys:justPressed('a') then
43
                    self:newLevel('forest1')
44
                 elseif the.keys:justPressed('b') then
45
                    self:newLevel('shore')
46
                 end
47
              end,
48
   newLevel = function (self, level)
9 by Josh C
levels hash, scale player
49
                 self.sprites = levels[level].objects()
8 by Josh C
add shore, first pass level switching
50
              end
5 by Josh C
load a level, move a player around
51
}
52
53
the.app = App:new {
54
   onRun = function (self)
55
              self.view = GameView:new()
56
              if DEBUG then
57
                 self.console:watch('VERSION', 'VERSION')
58
                 self.console:watch('updateTook', 'the.updateTook')
59
                 --self.console:watch('drawTook', 'the.drawTook')
60
              end
61
           end,
62
   onUpdate = function (self, dt)
63
                 if the.keys:justPressed('escape') then
64
                    self.quit()
65
                 end
66
              end,
67
   update = function (self, dt)
68
               the.updateStart = love.timer.getMicroTime()
69
               App.update(self, dt)
70
               if the.updateStart then
71
                  the.updateTook = love.timer.getMicroTime() - the.updateStart
72
               end
73
            end
74
}