/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: 2015-09-05 20:31:29 UTC
  • Revision ID: josh@9ix.org-20150905203129-0gb7gax8re47zf7m
inculde lovebird in build if it's required

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
   fill = {0,0,255},
15
15
   collisions = {},
16
16
   onStartFrame = function(self)
17
 
                     if the.keys:pressed('left') then
18
 
                        self.velocity.x = -200 * the.activeMaze.moveMod
19
 
                     elseif the.keys:pressed('right') then
20
 
                        self.velocity.x = 200 * the.activeMaze.moveMod
21
 
                     else
22
 
                        self.velocity.x = 0
23
 
                     end
24
 
 
25
 
                     if the.keys:pressed('up') then
26
 
                        self.velocity.y = -200 * the.activeMaze.moveMod
27
 
                     elseif the.keys:pressed('down') then
28
 
                        self.velocity.y = 200 * the.activeMaze.moveMod
29
 
                     else
30
 
                        self.velocity.y = 0
31
 
                     end
32
 
                  end,
 
17
     local mouseup, mousedn, mousert, mouselt
 
18
     if the.mouse:pressed() then
 
19
       local x, y = love.mouse.getPosition()
 
20
       local w, h = love.window.getMode()
 
21
 
 
22
       local theta = math.atan2(y - h/2, x - w/2)
 
23
       --local theta = math.atan2(y - self.y * the.app.scale,
 
24
       --                         x - self.x * the.app.scale)
 
25
 
 
26
       -- 1/8 = .125, 7/8 = .875
 
27
       if theta > math.pi * .125 and theta < math.pi * .875 then
 
28
         mousedn = true
 
29
       elseif theta < -math.pi * .125 and theta > -math.pi * .875 then
 
30
         mouseup = true
 
31
       end
 
32
 
 
33
       -- 3/8 = .375, 5/8 = .625
 
34
       if math.abs(theta) < math.pi * .375 then
 
35
         mousert = true
 
36
       elseif math.abs(theta) > math.pi * .625 then
 
37
         mouselt = true
 
38
       end
 
39
 
 
40
       --print('mouse pressed: ' .. theta)
 
41
     end
 
42
 
 
43
     if the.keys:pressed('left') or mouselt then
 
44
       self.velocity.x = -200 * the.activeMaze.moveMod
 
45
     elseif the.keys:pressed('right') or mousert then
 
46
       self.velocity.x = 200 * the.activeMaze.moveMod
 
47
     else
 
48
       self.velocity.x = 0
 
49
     end
 
50
 
 
51
     if the.keys:pressed('up') or mouseup then
 
52
       self.velocity.y = -200 * the.activeMaze.moveMod
 
53
     elseif the.keys:pressed('down') or mousedn then
 
54
       self.velocity.y = 200 * the.activeMaze.moveMod
 
55
     else
 
56
       self.velocity.y = 0
 
57
     end
 
58
   end,
33
59
   update = function(self, elapsed)
34
60
               self.visible = DEBUG and the.console.visible
35
61
 
72
98
                                                 yOverlap = yOverlap })
73
99
               end
74
100
 
75
 
}
 
 
b'\\ No newline at end of file'
 
101
}