/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 20:42:07 UTC
  • Revision ID: josh@9ix.org-20130507204207-yavvb4hhzhrjnw1e
fullscreen.  (there must be a more subtle way...)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
Cursor = Tile:extend {
2
2
   image = 'data/cursor.png',
3
 
   inTargetArea = function(self)
4
 
                     -- TODO: memoize this per-tick
5
 
 
6
 
                     local mouseAngle = math.atan2(
7
 
                        love.mouse.getY() - the.app.height/2,
8
 
                        love.mouse.getX() - the.app.width/2
9
 
                     )
10
 
                     local mouseVsShipAbs = math.abs(the.player.rotation - mouseAngle)
11
 
                     local mouseVsShip = math.min(2*math.pi - mouseVsShipAbs,
12
 
                                                  mouseVsShipAbs)
13
 
 
14
 
                     return mouseVsShip < 0.75
15
 
                  end,
16
3
   onUpdate = function(self)
17
 
                 if self:inTargetArea() then
 
4
                 if the.keys:justPressed('t') then
18
5
                    self.image = 'data/cursor-target.png'
19
 
                 else
 
6
                 end
 
7
                 if the.keys:justPressed('c') then
20
8
                    self.image = 'data/cursor.png'
21
9
                 end
 
10
 
22
11
              end,
23
12
   onEndFrame = function(self)
24
13
                   self.x = love.mouse.getX() + 8 + the.player.x - the.app.width / 2