player={} player.x=0 player.y=0 player.speed=0.2 player.direction=0 player.lastMoveTime=0 player.weapon={} function player.update(dt) local now=love.timer.getTime() if (player.direction~=0) and (now-player.lastMoveTime>=player.speed) then player.move(player.x+player.direction) end -- check direction end -- update function player.move(dx) player.lastMoveTime=love.timer.getTime() if dx<0 or dx>game.field.width then -- boundary shit goes here else player.x=dx love.audio.setPosition(player.x, player.y, 0) end -- if boundary end