/traderous

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

« back to all changes in this revision

Viewing changes to cursor.lua

  • Committer: Josh C
  • Date: 2013-05-14 17:49:03 UTC
  • Revision ID: josh@9ix.org-20130514174903-790agtxqfvz8lnzv
player death

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
   inTargetArea = function(self)
4
4
                     -- TODO: memoize this per-tick
5
5
 
6
 
                     local mouseAngle = math.atan2(
7
 
                        love.mouse.getY() - the.app.height/2,
8
 
                        love.mouse.getX() - the.app.width/2
9
 
                     )
 
6
                     local mouseAngle = math.atan2(self.vector.y, self.vector.x)
10
7
                     local mouseVsShipAbs = math.abs(the.player.rotation - mouseAngle)
11
8
                     local mouseVsShip = math.min(2*math.pi - mouseVsShipAbs,
12
9
                                                  mouseVsShipAbs)
13
10
 
14
11
                     return mouseVsShip < 0.75
15
12
                  end,
 
13
   onStartFrame = function(self)
 
14
                     self.vector = vector.new(
 
15
                        love.mouse.getX() - the.app.width/2,
 
16
                        love.mouse.getY() - the.app.height/2
 
17
                     )
 
18
                  end,
16
19
   onUpdate = function(self)
17
 
                 if self:inTargetArea() then
 
20
                 if self.vector:len2() > 64^2 then
18
21
                    self.image = 'data/cursor-target.png'
19
22
                 else
20
23
                    self.image = 'data/cursor.png'
21
24
                 end
 
25
 
 
26
                 -- if self:inTargetArea() then
 
27
                 --    self.image = 'data/cursor-target.png'
 
28
                 -- else
 
29
                 --    self.image = 'data/cursor.png'
 
30
                 -- end
22
31
              end,
23
32
   onEndFrame = function(self)
24
33
                   self.x = love.mouse.getX() + 8 + the.player.x - the.app.width / 2