/ld26

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

« back to all changes in this revision

Viewing changes to player.lua

  • Committer: Josh C
  • Date: 2013-04-27 19:17:32 UTC
  • Revision ID: josh@9ix.org-20130427191732-b04lkepq9cz8e1n7
player min/maxY on a level

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Player = Tile:extend {
 
2
   image = 'data/player-null.png',
 
3
   onNew = function(self)
 
4
              the.player = self
 
5
 
 
6
              self.movementScale = self.height / 32
 
7
              print(self.movementScale)
 
8
 
 
9
              --self.scale = self.scaleHeight / self.height
 
10
              --self.width = self.height * .826
 
11
              --self.width = self.width * self.scale
 
12
              --self:updateQuad()
 
13
           end,
 
14
   onStartFrame = function(self)
 
15
                     local ms = self.movementScale
 
16
 
 
17
                     if the.keys:pressed('up') then
 
18
                        self.velocity.y = -100 * ms
 
19
                     elseif the.keys:pressed('down') then
 
20
                        self.velocity.y = 100 * ms
 
21
                     else
 
22
                        self.velocity.y = 0
 
23
                     end
 
24
 
 
25
                     if the.keys:pressed('right') then
 
26
                        self.velocity.x = 100 * ms
 
27
                     elseif the.keys:pressed('left') then
 
28
                        self.velocity.x = -100 * ms
 
29
                     else
 
30
                        self.velocity.x = 0
 
31
                     end
 
32
                  end,
 
33
   onEndFrame = function(self)
 
34
                   if self.y < self.minY then
 
35
                      self.y = self.minY
 
36
                   end
 
37
                   if self.y > self.maxY then
 
38
                      self.y = self.maxY
 
39
                   end
 
40
                end
 
41
}
 
 
b'\\ No newline at end of file'