SOS! Dt issues!
Posted: Wed Mar 25, 2015 1:04 pm
Help! I'm trying to do a tutorial, but whenever I try to move my 'player', I always get the same error message - 'main.lua:9: attempt to perform arithmetic on global 'dt' (a nil value)' What does this mean and how can I fix it? Here is my code --
function love.load()
player = { x = 200, y = 710, speed = 150, img = love.graphics.newImage('assets/plane.png') }
end
function love.update()
if love.keyboard.isDown('escape') then
love.event.quit()
elseif love.keyboard.isDown('left', 'a') then
player.x = player.x - player.speed * dt
elseif love.keyboard.isDown('right', 'd') then
player.x = player.x + player.speed * dt
end
end
function love.draw()
love.graphics.draw(player.img, player.x, player.y)
end
function love.load()
player = { x = 200, y = 710, speed = 150, img = love.graphics.newImage('assets/plane.png') }
end
function love.update()
if love.keyboard.isDown('escape') then
love.event.quit()
elseif love.keyboard.isDown('left', 'a') then
player.x = player.x - player.speed * dt
elseif love.keyboard.isDown('right', 'd') then
player.x = player.x + player.speed * dt
end
end
function love.draw()
love.graphics.draw(player.img, player.x, player.y)
end