/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 18:01:54 UTC
  • Revision ID: josh@9ix.org-20130428180154-k9g0f2yxrm4fheul
level tweaks & fixes

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
require 'player'
10
10
require 'transition'
11
11
require 'displacer'
 
12
require 'inventory'
 
13
require 'flower'
 
14
 
12
15
require 'svg_levels'
13
16
 
14
17
levels = {
21
24
                      Tile:new{image = 'data/forest1-fg.png'}
22
25
                   } end,
23
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
   },
24
35
   shore = {
25
36
      objects = function() return {
26
37
                      Tile:new{image = 'data/shore-bg.png'},
47
58
                                 image = 'data/village-player.png'},
48
59
                   }
49
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
50
70
   }
51
71
}
52
72
 
53
73
GameView = View:extend {
54
 
   level = 'forest1', --default level
 
74
   level = 'shore', --default level
55
75
   onNew = function (self)
56
76
              --print('loading level: '..self.level)
57
77
              for _, obj in ipairs(levels[self.level].objects()) do
58
78
                 self:add(obj)
59
79
              end
60
80
              for _, obj in ipairs(svg_objects[self.level]) do
61
 
                 self:add(obj)
 
81
                 if not the.inventory.items[obj.name] then
 
82
                    self:add(obj)
 
83
                 end
62
84
              end
63
85
 
 
86
              self:add(the.inventory)
 
87
 
64
88
              self:flash({0,0,0})
65
89
 
66
90
              --self.focus = the.player
68
92
           end,
69
93
   draw = function (self, x, y)
70
94
             View.draw(self, x, y)
71
 
             love.graphics.print('FPS:' .. love.timer.getFPS(), 20, 20)
 
95
             --love.graphics.print('FPS:' .. love.timer.getFPS(), 20, 20)
72
96
             love.graphics.print('version:' .. VERSION, 20, 570)
73
97
          end,
74
98
   onUpdate = function (self, dt)
75
 
                 if the.keys:justPressed('a') then
76
 
                    the.app.view = GameView:new{level = 'forest1'}
77
 
                 elseif the.keys:justPressed('b') then
78
 
                    the.app.view = GameView:new{level = 'shore'}
79
 
                 end
80
99
              end
81
100
}
82
101