diff --git a/main.lua b/main.lua index 5e3cc84..50c97cc 100644 --- a/main.lua +++ b/main.lua @@ -11,6 +11,8 @@ function love.load() shipRadius = 30 bullets = {} + bulletTimerLimit = 0.5 + bulletTimer = bulletTimerLimit end function love.update(dt) @@ -43,16 +45,18 @@ function love.update(dt) bullet.y = (bullet.y + math.sin(bullet.angle) * bulletSpeed * dt) % arenaHeight end end -end -function love.keypressed(key) - if key == 's' then - table.insert(bullets, { - x = shipX + math.cos(shipAngle) * shipRadius, - y = shipY + math.sin(shipAngle) * shipRadius, - angle = shipAngle, - timeLeft = 4, - }) + bulletTimer = bulletTimer + dt + if love.keyboard.isDown('s') then + if bulletTimer >= bulletTimerLimit then + bulletTimer = 0 + table.insert(bullets, { + x = shipX + math.cos(shipAngle) * shipRadius, + y = shipY + math.sin(shipAngle) * shipRadius, + angle = shipAngle, + timeLeft = 4, + }) + end end end