bullet sound

This commit is contained in:
Donald Ball 2025-11-15 20:46:59 -05:00
parent d498c7c78a
commit ba00a4b8dd
2 changed files with 6 additions and 2 deletions

View file

@ -10,6 +10,7 @@ local function initGame()
radius = 5,
speed = 500,
time = 4,
sound = love.sound.newSoundData('resources/bullet.mp3'),
},
-- 99x75
sprite = love.graphics.newImage('resources/ship.png'),
@ -158,12 +159,15 @@ function love.gamepadpressed(joystick, button)
end
if button == "b" then
-- debounce, perhaps
table.insert(state.bullets, {
local bullet = {
x = state.ship.x + math.cos(state.ship.angle) * game.ship.radius,
y = state.ship.y + math.sin(state.ship.angle) * game.ship.radius,
angle = state.ship.angle,
timeLeft = game.ship.bullet.time,
})
sound = love.audio.newSource(game.ship.bullet.sound),
}
table.insert(state.bullets, bullet)
bullet.sound:play()
end
end