Anyway, of course I'm working on a Wolfenstein-style game engine and I want to implement mouse movement. i.e. "MouseLook" but I'm having a problem figuring out if it's possible to do well or at all in Löve.
I tried locking the mouse to the window, then constantly moving the mouse to the center of the window and checking if the mouse moves to the left or the right. Not having much luck making it work well at all.
Basically I need to figure out how to, not detect where on the screen the mouse is going, but what direction it is moving and how fast it is moving. Then use that to return the values I need for speed.
Currently I have this:
Code: Select all
if love.mouse.getX() < oldMouseX then
local sp = (oldMouseX - love.mouse.getX()) / 50
if sp < -1 then sp = -1 end
player.dir = -sp
elseif love.mouse.getX() > oldMouseX then
local sp = (love.mouse.getX() - oldMouseX) / 50
if sp > 1 then sp = 1 end
player.dir = sp
else
player.dir = 0
end
if love.mouse.getX() < 100 or love.mouse.getX() > windowWidth - 100 then
love.mouse.setPosition(windowWidth / 2, windowHeight / 2)
end
oldMouseX = love.mouse.getX()