/ld27

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

« back to all changes in this revision

Viewing changes to player.lua

  • Committer: Josh C
  • Date: 2013-08-24 17:02:07 UTC
  • Revision ID: josh@9ix.org-20130824170207-8fzjr3j0t2rpfb5s
goal... thing

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
   image = 'data/player.png',
4
4
   maxVelocity = {x=velLimit,y=velLimit},
5
5
   minVelocity = {x=-velLimit, y=-velLimit},
6
 
   onNew = function(self)
7
 
              self.collider = PlayerCollider:new()
8
 
              the.view:add(self.collider)
9
 
           end,
10
6
   onStartFrame = function(self)
11
7
                     if the.keys:pressed('left') then
12
 
                        self.velocity.x = -200 * the.activeMaze.moveMod
 
8
                        self.velocity.x = -200
13
9
                     elseif the.keys:pressed('right') then
14
 
                        self.velocity.x = 200 * the.activeMaze.moveMod
 
10
                        self.velocity.x = 200
15
11
                     else
16
12
                        self.velocity.x = 0
17
13
                     end
18
14
 
19
15
                     if the.keys:pressed('up') then
20
 
                        self.velocity.y = -200 * the.activeMaze.moveMod
 
16
                        self.velocity.y = -200
21
17
                     elseif the.keys:pressed('down') then
22
 
                        self.velocity.y = 200 * the.activeMaze.moveMod
 
18
                        self.velocity.y = 200
23
19
                     else
24
20
                        self.velocity.y = 0
25
21
                     end
26
22
                  end,
27
 
   onUpdate = function(self, dt)
28
 
                 self.collider.x = self.x + self.width / 2 * (1 - self.scale)
29
 
                 self.collider.y = self.y + self.height / 2 * (1 - self.scale)
30
 
              end,
31
 
}
32
 
 
33
 
PlayerCollider = Fill:extend{
34
 
   fill = {0,0,255},
35
 
   onUpdate = function(self, dt)
36
 
                 self.visible = DEBUG and the.console.visible
37
 
              end,
38
23
   onCollide = function(self, other)
39
 
                  local p = the.player
40
 
 
41
24
                  other:displace(self)
42
 
                  p.x = self.x - p.width / 2 * (1 - p.scale)
43
 
                  p.y = self.y - p.height / 2 * (1 - p.scale)
44
25
               end
45
26
}
 
 
b'\\ No newline at end of file'