/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 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:
1
1
Player = Tile:extend {
2
 
   image = 'data/player-null.png',
 
2
   image = 'data/player1.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()
13
4
           end,
14
5
   onStartFrame = function(self)
15
 
                     local ms = self.movementScale
16
 
                     if DEBUG and the.console.visible then
17
 
                        ms = ms * 4
18
 
                     end
19
 
 
20
6
                     if the.keys:pressed('up') then
21
 
                        self.velocity.y = -100 * ms
 
7
                        self.velocity.y = -100
22
8
                     elseif the.keys:pressed('down') then
23
 
                        self.velocity.y = 100 * ms
 
9
                        self.velocity.y = 100
24
10
                     else
25
11
                        self.velocity.y = 0
26
12
                     end
27
13
 
28
14
                     if the.keys:pressed('right') then
29
 
                        self.velocity.x = 100 * ms
 
15
                        self.velocity.x = 100
30
16
                     elseif the.keys:pressed('left') then
31
 
                        self.velocity.x = -100 * ms
 
17
                        self.velocity.x = -100
32
18
                     else
33
19
                        self.velocity.x = 0
34
20
                     end
35
 
                  end,
36
 
   onUpdate = function(self, dt)
37
 
                 self:collide(the.view)
38
 
              end,
39
 
   onEndFrame = function(self)
40
 
                   if self.y < self.minY then
41
 
                      self.y = self.minY
42
 
                   end
43
 
                   if self.y > self.maxY then
44
 
                      self.y = self.maxY
45
 
                   end
46
 
                end
 
21
                  end
47
22
}
 
 
b'\\ No newline at end of file'