From 11a4fe98260af7c6eade92d2c2c361f4aa9ac339 Mon Sep 17 00:00:00 2001 From: Donald Ball Date: Sat, 15 Nov 2025 20:54:47 -0500 Subject: [PATCH] bullet recoil --- asteroids/main.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/asteroids/main.lua b/asteroids/main.lua index 7e2d872..61c1a0b 100644 --- a/asteroids/main.lua +++ b/asteroids/main.lua @@ -8,6 +8,7 @@ local function initGame() radius = 30, bullet = { radius = 5, + recoil = -10, speed = 500, time = 4, sound = love.sound.newSoundData('resources/bullet.mp3'), @@ -168,6 +169,8 @@ function love.gamepadpressed(joystick, button) } table.insert(state.bullets, bullet) 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