This commit is contained in:
Donald Ball 2025-11-14 16:22:01 -05:00
parent 419f858b1b
commit 5e47a5773c

View file

@ -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