/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:51:02 UTC
  • Revision ID: josh@9ix.org-20130428185102-2gekwj8pzvlnwvhb
collision tweaks

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