/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 02:02:58 UTC
  • Revision ID: josh@9ix.org-20130428020258-u7iwtprl6maa4634
village, lake

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
 
 
15
12
require 'svg_levels'
16
13
 
17
14
levels = {
24
21
                      Tile:new{image = 'data/forest1-fg.png'}
25
22
                   } end,
26
23
   },
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
 
   },
35
24
   shore = {
36
25
      objects = function() return {
37
26
                      Tile:new{image = 'data/shore-bg.png'},
62
51
}
63
52
 
64
53
GameView = View:extend {
65
 
   level = 'shore', --default level
 
54
   level = 'forest1', --default level
66
55
   onNew = function (self)
67
56
              --print('loading level: '..self.level)
68
57
              for _, obj in ipairs(levels[self.level].objects()) do
69
58
                 self:add(obj)
70
59
              end
71
60
              for _, obj in ipairs(svg_objects[self.level]) do
72
 
                 if not the.inventory.items[obj.name] then
73
 
                    self:add(obj)
74
 
                 end
 
61
                 self:add(obj)
75
62
              end
76
63
 
77
 
              self:add(the.inventory)
78
 
 
79
64
              self:flash({0,0,0})
80
65
 
81
66
              --self.focus = the.player
83
68
           end,
84
69
   draw = function (self, x, y)
85
70
             View.draw(self, x, y)
86
 
             --love.graphics.print('FPS:' .. love.timer.getFPS(), 20, 20)
 
71
             love.graphics.print('FPS:' .. love.timer.getFPS(), 20, 20)
87
72
             love.graphics.print('version:' .. VERSION, 20, 570)
88
73
          end,
89
74
   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
90
80
              end
91
81
}
92
82