/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'},
58
47
                                 image = 'data/village-player.png'},
59
48
                   }
60
49
                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
70
50
   }
71
51
}
72
52
 
73
53
GameView = View:extend {
74
 
   level = 'shore', --default level
 
54
   level = 'forest1', --default level
75
55
   onNew = function (self)
76
56
              --print('loading level: '..self.level)
77
57
              for _, obj in ipairs(levels[self.level].objects()) do
78
58
                 self:add(obj)
79
59
              end
80
60
              for _, obj in ipairs(svg_objects[self.level]) do
81
 
                 if not the.inventory.items[obj.name] then
82
 
                    self:add(obj)
83
 
                 end
 
61
                 self:add(obj)
84
62
              end
85
63
 
86
 
              self:add(the.inventory)
87
 
 
88
64
              self:flash({0,0,0})
89
65
 
90
66
              --self.focus = the.player
92
68
           end,
93
69
   draw = function (self, x, y)
94
70
             View.draw(self, x, y)
95
 
             --love.graphics.print('FPS:' .. love.timer.getFPS(), 20, 20)
 
71
             love.graphics.print('FPS:' .. love.timer.getFPS(), 20, 20)
96
72
             love.graphics.print('version:' .. VERSION, 20, 570)
97
73
          end,
98
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
99
80
              end
100
81
}
101
82