/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:
3
3
 
4
4
require 'zoetrope'
5
5
 
6
 
TERM_VEL = 400
7
 
 
8
6
Player = Tile:extend {
9
7
   image = 'data/player.png',
10
 
   onNew = function (self)
11
 
              self.velocity.y = 0
12
 
           end,
13
 
   onStartFrame = function (self)
14
 
                     -- this is all in startframe so it happens before
15
 
                     -- physics calc at beginning of update
16
 
 
 
8
   onUpdate = function (self)
17
9
                 self.velocity.x = 0
18
 
                 -- TODO: this can be replaced with sprite.maxVel.y    
19
 
                 if self.velocity.y >= TERM_VEL then
20
 
                    self.velocity.y = TERM_VEL
21
 
                    self.acceleration.y = 0
22
 
                 else
23
 
                    self.acceleration.y = 800
24
 
                 end
 
10
                 self.velocity.y = 0
25
11
 
26
12
                 if the.keys:pressed('left') then
27
13
                    self.velocity.x = -200
28
14
                 elseif the.keys:pressed('right') then
29
15
                    self.velocity.x = 200
30
16
                 end
31
 
 
32
 
                 if the.keys:justPressed('up') then
33
 
                    self.velocity.y = -400
34
 
                 end
35
 
              end,
36
 
   onUpdate = function (self)
37
 
                 -- this is called after physics, so this makes sense here
38
 
                 the.view.map:subdisplace(self)
39
17
              end
40
18
}
41
19
 
44
22
              self:loadLayers('data/map.lua')
45
23
              self.focus = the.player
46
24
              self:clampTo(self.map)
47
 
           end
 
25
           end,
 
26
 
 
27
   onUpdate = function (self, dt)
 
28
                 self.map:subdisplace(the.player)
 
29
              end
48
30
}
49
31
 
50
32
the.app = App:new {