3
3
inTargetArea = function(self)
4
4
-- TODO: memoize this per-tick
6
local mouseAngle = math.atan2(
7
love.mouse.getY() - the.app.height/2,
8
love.mouse.getX() - the.app.width/2
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,
14
11
return mouseVsShip < 0.75
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
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'
20
23
self.image = 'data/cursor.png'
26
-- if self:inTargetArea() then
27
-- self.image = 'data/cursor-target.png'
29
-- self.image = 'data/cursor.png'
23
32
onEndFrame = function(self)
24
33
self.x = love.mouse.getX() + 8 + the.player.x - the.app.width / 2