apply ship velocity to bullets
This commit is contained in:
parent
5bcf22a6f8
commit
13bec1a0aa
1 changed files with 3 additions and 1 deletions
|
|
@ -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 })
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue