/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 18:39:03 UTC
  • Revision ID: josh@9ix.org-20130427183903-3uc24myj115nckj0
scale movement with player size

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
Player = Tile:extend {
2
 
   image = 'data/player1.png',
 
2
   image = 'data/player-null.png',
3
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()
4
13
           end,
5
14
   onStartFrame = function(self)
 
15
                     local ms = self.movementScale
 
16
 
6
17
                     if the.keys:pressed('up') then
7
 
                        self.velocity.y = -100
 
18
                        self.velocity.y = -100 * ms
8
19
                     elseif the.keys:pressed('down') then
9
 
                        self.velocity.y = 100
 
20
                        self.velocity.y = 100 * ms
10
21
                     else
11
22
                        self.velocity.y = 0
12
23
                     end
13
24
 
14
25
                     if the.keys:pressed('right') then
15
 
                        self.velocity.x = 100
 
26
                        self.velocity.x = 100 * ms
16
27
                     elseif the.keys:pressed('left') then
17
 
                        self.velocity.x = -100
 
28
                        self.velocity.x = -100 * ms
18
29
                     else
19
30
                        self.velocity.x = 0
20
31
                     end