我对 Lua 和 Love2D 完全陌生,可能根本不理解这些概念。嗯,这是一个 Love2D 教程,我想改变它,例如,当我在键盘上按“a”时,对象将交换(从仓鼠到汽车)等等。
你能帮我吗?
-- Tutorial 1: Hamster Ball
-- Add an image to the game and move it around using
-- the arrow keys.
-- compatible with löve 0.6.0 and up
function love.load()
hamster = love.graphics.newImage("hamster.png")
auto = love.graphics.newImage("auto.png")
x = 50
y = 50
speed = 300
end
function love.update(dt)
if love.keyboard.isDown("right") then
x = x + (speed * dt)
end
if love.keyboard.isDown("left") then
x = x - (speed * dt)
end
if love.keyboard.isDown("down") then
y = y + (speed * dt)
end
if love.keyboard.isDown("up") then
y = y - (speed * dt)
end
if love.keyboard.isDown("escape") then
love.event.quit()
end
if love.keyboard.isDown("a") then
love.draw(auto,x,y)
end
end
function love.draw()
love.graphics.draw(hamster, x, y)
end