【发布时间】:2021-08-29 09:07:59
【问题描述】:
当我按下 d 和 a 按钮时,我试图让我的桨上下移动。 当我按下 d 和 a 按钮时,什么都没有发生……他们只是坐在那里…… 无论如何,如果您知道,请告诉我代码如下。谢谢 我知道缩进是错误的,如果这篇文章我必须更改:)
window_width = 580
window_height = 420
playerScore = 0
enemyScore = 0
pSpeed = 200
player1Y = 100
player2Y = -20
function love.load()
love.window.setMode(window_width, window_height)
end
function love.draw()
love.graphics.printf('hello pong', 0, window_height / 2 - 6, window_width, 'center')
love.graphics.rectangle("fill", 500, player1Y , 10, 50)
love.graphics.rectangle("fill", 40, 220, 10, 50)
love.graphics.rectangle("fill", 100, 230, 7, 5)
end
function update(dt)
if love.keyboard.isDown('d') then
player1Y = player1Y + pSpeed * dt
elseif love.keyboard.isDown('a') then
player1Y = player1Y + -pSpeed * dt
end
end
【问题讨论】: