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