08. Arrow,Jump,Tiles
3.4,摆烂,海斗,继续 Sheepolution 的教程。
Angle
lua
function love.update(dt)
local mx, my = love.mouse.getPosition()
arrow.angle = math.atan2(my - arrow.y, mx - arrow.x)
dx = math.cos(arrow.angle)
dy = math.sin(arrow.angle)
local dist = math.sqrt((mx - arrow.x) ^ 2 + (my - arrow.y) ^ 2)
if dist > 20 then
arrow.x = arrow.x + dx * arrow.speed * dt
arrow.y = arrow.y + dy * arrow.speed * dt
end
end
function love.draw()
love.graphics.draw(
arrow.image,
arrow.x, arrow.y,
arrow.angle,
1, 1,
arrow.originX, arrow.originY
)
end