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