/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-28 17:38:34 UTC
  • Revision ID: josh@9ix.org-20130428173834-ps7dq286wp4gdpd0
bridge

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
                      Tile:new{image = 'data/forest1-fg.png'}
25
25
                   } end,
26
26
   },
 
27
   foresthut = {
 
28
      objects = function() return {
 
29
                      Tile:new{image = 'data/foresthut-bg.png'},
 
30
                      Player:new{x = 745, y = 430,
 
31
                                 image = 'data/forest1-player.png'},
 
32
                      Tile:new{image = 'data/foresthut-fg.png'}
 
33
                   } end,
 
34
   },
27
35
   shore = {
28
36
      objects = function() return {
29
37
                      Tile:new{image = 'data/shore-bg.png'},
50
58
                                 image = 'data/village-player.png'},
51
59
                   }
52
60
                end
 
61
   },
 
62
   bridge = {
 
63
      objects = function() return {
 
64
                      Tile:new{image = 'data/bridge-bg.png'},
 
65
                      Player:new{x = 121, y = 440,
 
66
                                 image = 'data/bridge-player.png'},
 
67
                      Tile:new{image = 'data/bridge-fg.png'}
 
68
                   }
 
69
                end
53
70
   }
54
71
}
55
72
 
56
73
GameView = View:extend {
57
 
   level = 'forest1', --default level
 
74
   level = 'shore', --default level
58
75
   onNew = function (self)
59
76
              --print('loading level: '..self.level)
60
77
              for _, obj in ipairs(levels[self.level].objects()) do
61
78
                 self:add(obj)
62
79
              end
63
80
              for _, obj in ipairs(svg_objects[self.level]) do
64
 
                 self:add(obj)
 
81
                 if not the.inventory.items[obj.name] then
 
82
                    self:add(obj)
 
83
                 end
65
84
              end
66
85
 
67
86
              self:add(the.inventory)
77
96
             love.graphics.print('version:' .. VERSION, 20, 570)
78
97
          end,
79
98
   onUpdate = function (self, dt)
80
 
                 if the.keys:justPressed('a') then
81
 
                    the.app.view = GameView:new{level = 'forest1'}
82
 
                 elseif the.keys:justPressed('b') then
83
 
                    the.app.view = GameView:new{level = 'shore'}
84
 
                 end
85
99
              end
86
100
}
87
101