add throttle
This commit is contained in:
parent
38af0bcaa1
commit
e2fe2499d4
2 changed files with 6 additions and 4 deletions
|
|
@ -17,6 +17,7 @@ local function initGame()
|
|||
sound = love.sound.newSoundData('resources/bullet.mp3'),
|
||||
},
|
||||
sprite = love.graphics.newImage('resources/playerShip1_blue.png'),
|
||||
maxThrust = 200,
|
||||
},
|
||||
asteroids = {
|
||||
stages = {
|
||||
|
|
@ -29,7 +30,6 @@ local function initGame()
|
|||
controls = {
|
||||
ship = {
|
||||
turnRate = 10,
|
||||
maxThrust = 200,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
@ -94,9 +94,10 @@ end
|
|||
|
||||
function love.update(dt)
|
||||
if state.controls.joystick ~= nil then
|
||||
local thrust = state.controls.joystick:getGamepadAxis('triggerright') * game.controls.ship.maxThrust
|
||||
if thrust > 0 then
|
||||
phys.apply(state.ship, { speed = thrust * dt, angle = state.ship.facing })
|
||||
state.ship.throttle = state.controls.joystick:getGamepadAxis('triggerright')
|
||||
if state.ship.throttle > 0 then
|
||||
local speed = state.ship.throttle * state.ship.maxThrust * dt
|
||||
phys.apply(state.ship, { speed = speed, angle = state.ship.facing })
|
||||
end
|
||||
|
||||
local spin = state.controls.joystick:getGamepadAxis('leftx') * game.controls.ship.turnRate
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue