bzr branch
http://9ix.org/bzr/spacey
8
by Josh C
targeting cursor (manual switch to start) |
1 |
Cursor = Tile:extend { |
2 |
image = 'data/cursor.png', |
|
14
by Josh C
only fire if cursor is in target area. change cursor to reflect this. |
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, |
|
8
by Josh C
targeting cursor (manual switch to start) |
16 |
onUpdate = function(self) |
14
by Josh C
only fire if cursor is in target area. change cursor to reflect this. |
17 |
if self:inTargetArea() then |
8
by Josh C
targeting cursor (manual switch to start) |
18 |
self.image = 'data/cursor-target.png' |
14
by Josh C
only fire if cursor is in target area. change cursor to reflect this. |
19 |
else |
8
by Josh C
targeting cursor (manual switch to start) |
20 |
self.image = 'data/cursor.png' |
21 |
end |
|
22 |
end, |
|
23 |
onEndFrame = function(self) |
|
12
by Josh C
fullscreen. (there must be a more subtle way...) |
24 |
self.x = love.mouse.getX() + 8 + the.player.x - the.app.width / 2 |
25 |
self.y = love.mouse.getY() + 8 + the.player.y - the.app.height / 2 |
|
8
by Josh C
targeting cursor (manual switch to start) |
26 |
end |
27 |
} |