/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'},
51
40
                   }
52
41
                end
53
42
   },
54
 
   -- village = {
55
 
   --    objects = function() return {
56
 
   --                    Tile:new{image = 'data/village-bg.png'},
57
 
   --                    Player:new{x = 121, y = 440,
58
 
   --                               image = 'data/village-player.png'},
59
 
   --                 }
60
 
   --              end
61
 
   -- },
62
 
   bridge = {
 
43
   village = {
63
44
      objects = function() return {
64
 
                      Tile:new{image = 'data/bridge-bg.png'},
 
45
                      Tile:new{image = 'data/village-bg.png'},
65
46
                      Player:new{x = 121, y = 440,
66
 
                                 image = 'data/bridge-player.png'},
67
 
                      Tile:new{image = 'data/bridge-fg.png'}
 
47
                                 image = 'data/village-player.png'},
68
48
                   }
69
49
                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
 
              if not levels[self.level] then
78
 
                 error('no such level: '..self.level)
79
 
              end
80
57
              for _, obj in ipairs(levels[self.level].objects()) do
81
58
                 self:add(obj)
82
59
              end
83
60
              for _, obj in ipairs(svg_objects[self.level]) do
84
 
                 if not the.inventory.items[obj.name] then
85
 
                    self:add(obj)
86
 
                 end
 
61
                 self:add(obj)
87
62
              end
88
63
 
89
 
              self:add(the.inventory)
90
 
 
91
64
              self:flash({0,0,0})
92
65
 
93
66
              --self.focus = the.player
95
68
           end,
96
69
   draw = function (self, x, y)
97
70
             View.draw(self, x, y)
98
 
             --love.graphics.print('FPS:' .. love.timer.getFPS(), 20, 20)
 
71
             love.graphics.print('FPS:' .. love.timer.getFPS(), 20, 20)
99
72
             love.graphics.print('version:' .. VERSION, 20, 570)
100
73
          end,
101
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
102
80
              end
103
81
}
104
82