Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

love.keyboard.isDown is incorrect after dragging the game window #2071

Open
challacade opened this issue May 16, 2024 · 0 comments
Open

love.keyboard.isDown is incorrect after dragging the game window #2071

challacade opened this issue May 16, 2024 · 0 comments
Labels
bug Something isn't working library dependency Related to a library used by LÖVE Windows

Comments

@challacade
Copy link

From what I understand, LOVE games will freeze on Windows if you drag/move the game window. Once the user stops dragging the window, the game resumes. None of this is a problem. However, an issue occurs if the user is holding down a keyboard key, starts dragging the window, and then releases the key while dragging the window. When the game resumes after freezing, it incorrectly believes the key is still held down once the game resumes. This leads to my character continuing to run in a direction, and the only way to stop it is to press and release the key that's stuck. Not a big problem, but it is something I encounter a lot when playing my own game. Here's a short main.lua that I was using to demonstrate - the love.keyboard.isDown calls are true after releasing while dragging.

function love.load()
    player = {}
    player.x = 400
    player.y = 200
    player.speed = 2
    message = ""
end

function love.update(dt)
    message = ""

    if love.keyboard.isDown("right") then
        message = message .. "Right "
        player.x = player.x + player.speed
    end

    if love.keyboard.isDown("left") then
        message = message .. "Left "
        player.x = player.x - player.speed
    end

    if love.keyboard.isDown("down") then
        message = message .. "Down "
        player.y = player.y + player.speed
    end

    if love.keyboard.isDown("up") then
        message = message .. "Up "
        player.y = player.y - player.speed
    end
end

function love.draw()
    love.graphics.circle("fill", player.x, player.y, 40)
    love.graphics.print(message, 0, 0)
end
@slime73 slime73 added bug Something isn't working library dependency Related to a library used by LÖVE Windows labels May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working library dependency Related to a library used by LÖVE Windows
Projects
None yet
Development

No branches or pull requests

2 participants