I'm making an Agar.io clone and struggling with something
Posted: Sat Sep 03, 2022 6:33 pm
Hey people,
How can I make the player go diagonally?
When I'm holding 2 keys at once only the first one pressed is functioning.
Ignore my bad coding skills I'm still learning and doing my best, if you have any tips for feel free to share them
this is my code:
How can I make the player go diagonally?
When I'm holding 2 keys at once only the first one pressed is functioning.
Ignore my bad coding skills I'm still learning and doing my best, if you have any tips for feel free to share them
How can I make the player go diagonally?
When I'm holding 2 keys at once only the first one pressed is functioning.
Ignore my bad coding skills I'm still learning and doing my best, if you have any tips for feel free to share them
this is my code:
Code: Select all
function love.load()
player = {}
baseCircleRadius = 20
score = 0
player.radius = baseCircleRadius + (score/3)
player.x = love.graphics.getWidth()/2
player.y = love.graphics.getHeight()/2
player.speed = 200 - player.radius + 100
end
function love.update(dt)
if love.keyboard.isDown('d') then player.x = player.x + (player.speed * dt)
elseif love.keyboard.isDown('a') then player.x = player.x - (player.speed * dt)
elseif love.keyboard.isDown('w') then player.y = player.y - (player.speed * dt)
elseif love.keyboard.isDown('s') then player.y = player.y + (player.speed * dt)
end
end
function love.draw()
love.graphics.setColor(0, 1, 1)
love.graphics.circle("fill", player.x, player.y, player.radius)
end
When I'm holding 2 keys at once only the first one pressed is functioning.
Ignore my bad coding skills I'm still learning and doing my best, if you have any tips for feel free to share them