/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-07 22:24:32 UTC
  • Revision ID: josh@9ix.org-20130507222432-74d3ul1p8ffq40s5
only fire if cursor is in target area.  change cursor to reflect this.

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