tommy: added engine kill switch
This commit is contained in:
parent
d9c349b1c0
commit
d178307d1e
@ -5,3 +5,5 @@ arrow keys to move
|
||||
's' to save
|
||||
|
||||
'l' to load
|
||||
|
||||
'k' to kill engines to ignore "gravity" Any movement will re-engage engines.
|
||||
|
@ -47,6 +47,9 @@ function love.load()
|
||||
player.current_speed.right = 0
|
||||
player.current_speed.up = 0
|
||||
player.current_speed.down = 0
|
||||
player.current_speed.x = 0
|
||||
player.current_speed.y = 0
|
||||
player.kill_engines = false
|
||||
--Must be less than 1
|
||||
--if I understand correctly, the second number should be how many frames
|
||||
--it takes to get to top speed
|
||||
@ -70,44 +73,68 @@ function love.keyreleased(key)
|
||||
end
|
||||
end
|
||||
|
||||
if key == "z" then
|
||||
if player.kill_engines == false then
|
||||
player.kill_engines = true
|
||||
else
|
||||
player.kill_engines = false
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function love.update(dt)
|
||||
|
||||
--Move character left or right
|
||||
if love.keyboard.isDown("right") then
|
||||
player.kill_engines = false
|
||||
player.current_speed.right = move(true, player.current_speed.right, "right")
|
||||
print ("RIGHT ".. player.current_speed.right)
|
||||
|
||||
elseif love.keyboard.isDown("left") then
|
||||
player.kill_engines = false
|
||||
player.current_speed.left = move(true, player.current_speed.left, "left")
|
||||
print (player.current_speed.left)
|
||||
print ("LEFT ".. player.current_speed.left)
|
||||
-- player.x = player.x - player.current_speed.left*dt
|
||||
end
|
||||
|
||||
if not love.keyboard.isDown("right") then
|
||||
player.current_speed.right = move(false, player.current_speed.right, "right")
|
||||
end
|
||||
if not love.keyboard.isDown("left") then
|
||||
player.current_speed.left = move(false, player.current_speed.left, "left")
|
||||
end
|
||||
player.x = player.x + (player.current_speed.right + player.current_speed.left)*dt
|
||||
|
||||
player.x = player.x + (player.current_speed.right + player.current_speed.left)*dt
|
||||
|
||||
--Also able to move or up down at the same time as one of the above
|
||||
|
||||
if love.keyboard.isDown("up") then
|
||||
player.kill_engines = false
|
||||
player.current_speed.up = move(true, player.current_speed.up, "up")
|
||||
elseif love.keyboard.isDown ("down") then
|
||||
player.killengines = false
|
||||
player.current_speed.down = move(true, player.current_speed.down, "down")
|
||||
end
|
||||
|
||||
if not love.keyboard.isDown("up") then
|
||||
player.current_speed.up = move(false, player.current_speed.up, "up")
|
||||
end
|
||||
if not love.keyboard.isDown("down") then
|
||||
player.current_speed.down = move(false, player.current_speed.down, "down")
|
||||
end
|
||||
|
||||
|
||||
player.y = player.y + (player.current_speed.up + player.current_speed.down)*dt
|
||||
|
||||
|
||||
-- Decel
|
||||
|
||||
if not player.kill_engines then
|
||||
if not love.keyboard.isDown("up") then
|
||||
player.current_speed.up = move(false, player.current_speed.up, "up")
|
||||
end
|
||||
if not love.keyboard.isDown("down") then
|
||||
player.current_speed.down = move(false, player.current_speed.down, "down")
|
||||
end
|
||||
|
||||
if not love.keyboard.isDown("right") then
|
||||
player.current_speed.right = move(false, player.current_speed.right, "right")
|
||||
end
|
||||
if not love.keyboard.isDown("left") then
|
||||
player.current_speed.left = move(false, player.current_speed.left, "left")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
function love.draw()
|
||||
|
Loading…
x
Reference in New Issue
Block a user