/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-27 17:56:22 UTC
  • Revision ID: josh@9ix.org-20130427175622-ksu8aap9zjpcicvx
add shore, first pass level switching

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
 
11
11
GameView = View:extend {
12
12
   onNew = function (self)
13
 
              bg = Tile:new{image = 'data/forest1-bg.png'}
14
 
              fg = Tile:new{image = 'data/forest1-fg.png'}
15
 
              the.player = Player:new{x = 196, y = 350}
16
 
              self:add(bg)
17
 
              self:add(the.player)
18
 
              self:add(fg)
 
13
              self:newLevel('forest1')
19
14
 
20
15
              --self:loadLayers('data/map.lua')
21
16
              --self.focus = the.player
25
20
             View.draw(self, x, y)
26
21
             love.graphics.print('FPS:' .. love.timer.getFPS(), 20, 20)
27
22
             love.graphics.print('version:' .. VERSION, 20, 570)
28
 
          end
 
23
          end,
 
24
   onUpdate = function (self, dt)
 
25
                 if the.keys:justPressed('a') then
 
26
                    self:newLevel('forest1')
 
27
                 elseif the.keys:justPressed('b') then
 
28
                    self:newLevel('shore')
 
29
                 end
 
30
              end,
 
31
   newLevel = function (self, level)
 
32
                 self.sprites = {}
 
33
                 bg = Tile:new{image = 'data/' .. level .. '-bg.png'}
 
34
                 fg = Tile:new{image = 'data/' .. level .. '-fg.png'}
 
35
                 the.player = Player:new{x = 196, y = 350}
 
36
                 self:add(bg)
 
37
                 self:add(the.player)
 
38
                 self:add(fg)
 
39
              end
29
40
}
30
41
 
31
42
the.app = App:new {