/zoeplat

To get this branch, use:
bzr branch http://9ix.org/bzr/zoeplat

« back to all changes in this revision

Viewing changes to main.lua

  • Committer: Josh C
  • Date: 2013-03-04 23:27:03 UTC
  • Revision ID: josh@9ix.org-20130304232703-nob2mg5wbo5co5is
basic tiles, map, player, movement

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 
6
6
Player = Tile:extend {
7
7
   image = 'data/player.png',
8
 
   onNew = function (self)
9
 
              self.velocity.y = 0
10
 
              self.maxVelocity.y = 400
11
 
           end,
12
 
   onStartFrame = function (self)
13
 
                     -- this is all in startframe so it happens before
14
 
                     -- physics calc at beginning of update
15
 
 
 
8
   onUpdate = function (self)
16
9
                 self.velocity.x = 0
17
 
                 self.acceleration.y = 800
 
10
                 self.velocity.y = 0
18
11
 
19
12
                 if the.keys:pressed('left') then
20
13
                    self.velocity.x = -200
21
14
                 elseif the.keys:pressed('right') then
22
15
                    self.velocity.x = 200
23
16
                 end
24
 
 
25
 
                 if the.keys:justPressed('up') then
26
 
                    self.velocity.y = -400
27
 
                 end
28
 
              end,
29
 
   onUpdate = function (self)
30
 
                 -- this is called after physics, so this makes sense here
31
 
                 the.view.map:subdisplace(self)
32
17
              end
33
18
}
34
19
 
37
22
              self:loadLayers('data/map.lua')
38
23
              self.focus = the.player
39
24
              self:clampTo(self.map)
40
 
           end
 
25
           end,
 
26
 
 
27
   onUpdate = function (self, dt)
 
28
                 self.map:subdisplace(the.player)
 
29
              end
41
30
}
42
31
 
43
32
the.app = App:new {