Cursor = Tile:extend { image = 'data/cursor.png', inTargetArea = function(self) -- TODO: memoize this per-tick local mouseAngle = math.atan2(self.vector.y, self.vector.x) local mouseVsShipAbs = math.abs(the.player.rotation - mouseAngle) local mouseVsShip = math.min(2*math.pi - mouseVsShipAbs, mouseVsShipAbs) return mouseVsShip < 0.75 end, onStartFrame = function(self) self.vector = vector.new( love.mouse.getX() - the.app.width/2, love.mouse.getY() - the.app.height/2 ) end, onUpdate = function(self) if self.vector:len2() > 64^2 then self.image = 'data/cursor-target.png' else self.image = 'data/cursor.png' end -- if self:inTargetArea() then -- self.image = 'data/cursor-target.png' -- else -- self.image = 'data/cursor.png' -- end end, onEndFrame = function(self) self.x = love.mouse.getX() + 8 + the.player.x - the.app.width / 2 self.y = love.mouse.getY() + 8 + the.player.y - the.app.height / 2 end }