diff --git a/love/tommy/Readme.txt b/love/tommy/Readme.txt index e0d47cb..7613169 100644 --- a/love/tommy/Readme.txt +++ b/love/tommy/Readme.txt @@ -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. diff --git a/love/tommy/main.lua b/love/tommy/main.lua index bd8092a..bcdfb46 100644 --- a/love/tommy/main.lua +++ b/love/tommy/main.lua @@ -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()