bullet recoil

This commit is contained in:
Donald Ball 2025-11-15 20:54:47 -05:00
parent ba00a4b8dd
commit 11a4fe9826

View file

@ -8,6 +8,7 @@ local function initGame()
radius = 30, radius = 30,
bullet = { bullet = {
radius = 5, radius = 5,
recoil = -10,
speed = 500, speed = 500,
time = 4, time = 4,
sound = love.sound.newSoundData('resources/bullet.mp3'), sound = love.sound.newSoundData('resources/bullet.mp3'),
@ -168,6 +169,8 @@ function love.gamepadpressed(joystick, button)
} }
table.insert(state.bullets, bullet) table.insert(state.bullets, bullet)
bullet.sound:play() bullet.sound:play()
state.ship.speed.x = state.ship.speed.x + math.cos(state.ship.angle) * game.ship.bullet.recoil
state.ship.speed.y = state.ship.speed.y + math.sin(state.ship.angle) * game.ship.bullet.recoil
end end
end end