diff --git a/asteroids/main.lua b/asteroids/main.lua index 1f50818..0c80ed7 100644 --- a/asteroids/main.lua +++ b/asteroids/main.lua @@ -34,6 +34,7 @@ local function initGame() } end +-- The constant properties of the game. local game = initGame() local function initState() @@ -79,6 +80,7 @@ local function initState() } end +-- The varying properties of a game being played. local state = {} local function reset() @@ -168,7 +170,6 @@ function love.gamepadpressed(joystick, button) end if button == "b" then -- debounce, perhaps - -- include ship velocity, perhaps local bullet = { x = state.ship.x + math.cos(state.ship.facing) * game.ship.radius, y = state.ship.y + math.sin(state.ship.facing) * game.ship.radius, @@ -178,6 +179,7 @@ function love.gamepadpressed(joystick, button) timeLeft = game.ship.bullet.time, sound = love.audio.newSource(game.ship.bullet.sound), } + phys.apply(bullet, state.ship) table.insert(state.bullets, bullet) bullet.sound:play() phys.apply(state.ship, { speed = game.ship.bullet.recoil, angle = state.ship.facing + phys.tau / 2 })