diff --git a/main.lua b/main.lua index 4687779..05f112c 100644 --- a/main.lua +++ b/main.lua @@ -13,15 +13,6 @@ function love.load() bullets = {} end -function love.keypressed(key) - if key == 's' then - table.insert(bullets, { - x = shipX + math.cos(shipAngle) * shipRadius, - y = shipY + math.sin(shipAngle) * shipRadius, - }) - end -end - function love.update(dt) local turnSpeed = 10 if love.keyboard.isDown('right') then @@ -40,6 +31,22 @@ function love.update(dt) shipX = (shipX + shipSpeedX * dt) % arenaWidth shipY = (shipY + shipSpeedY * dt) % arenaHeight + + for bulletIndex, bullet in ipairs(bullets) do + local bulletSpeed = 500 + bullet.x = (bullet.x + math.cos(bullet.angle) * bulletSpeed * dt) % arenaWidth + bullet.y = (bullet.y + math.sin(bullet.angle) * bulletSpeed * dt) % arenaHeight + 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, + }) + end end function love.draw()