문제

I am writting a game in Lua LÖVE framework, for the LudumDare26. I can't seem to figure out why my "player" won't move when I press WASD.

function love.draw()

    playerX = 10
    playerY = 10

    if love.keyboard.isDown ("w") then
        playerY = playerY - 1
    elseif love.keyboard.isDown ("s") then
        playerY = playerY + 1
    elseif love.keyboard.isDown ("a") then
        playerX = playerX - 1
    elseif love.keyboard.isDown ("d") then
        playerX = playerX + 1
    end

    local x = love.mouse.getX()
    local y = love.mouse.getY()

    love.graphics.setColor(0, 200, 255, 100)
    love.graphics.rectangle("fill", 0, 0, 800, 300)

    love.graphics.setColor(255, 255, 255, 255)
    love.graphics.rectangle("fill", xCloud, 128, 128, 50)

    love.graphics.setColor(50, 160, 80, 255)
    love.graphics.rectangle("fill", 0, 300, 800, 300)

    love.graphics.setColor(255, 0, 0, 255)
    love.graphics.draw(corsair, x - 16, y - 16, 0, 1, 1, 0, 0)

    love.graphics.draw(player, playerX, playerY)

    love.graphics.line(playerX, playerY, x, y)
end
도움이 되었습니까?

해결책

Take these lines out of love.draw() method:

playerX = 10
playerY = 10
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top