One thing worth of note is that the code is from: https://michagamedev.wordpress.com/2014 ... mp-height/ and it was the only code that worked for me (thanks micha). I modified it a bit (off course) to try to add double jumping, and I commented a lot of the code to give you the idea of what I was trying, hopefully this helps.
Thanks in advance. ~bluedude
Code: Select all
function mode_jump(mode)
--Sets jump
if mode == 'ground' then
player.mode = 'jump'
player.yvel = -400
end
--Idea is to double jump with this
if mode == 'double jump' then
player.mode = 'dJump'
player.yvel = player.y - 400
end
end
function player.jump(dt)
player.yvel = player.yvel + gravity * dt
-- player.mode is set to ground, when space is pressed it runs mode_jump('ground')
if love.keyboard.isDown(' ') and player.mode == 'ground' then
mode_jump('ground')
end
--the idea of this script is to grant the ability to double jump
--checks if player is in the air
if player.mode == 'jump' and player.yvel > 0 then
player.mode = 'air'
--if player is in the air
if player.mode == 'air' then
--idea is to let them jump again while player.dJump = true
--my idea is to make double jump a power-up
if love.keyboard.isDown(' ') and player.dJump == true then
mode_jump('double jump')
end
end
--resets player.mode so you can jump again
elseif player.mode == 'air' or 'dJump' and player.y == ground_level - player.height and player.yvel >= 0 then
player.mode = 'ground'
end
player.x = player.x + player.xvel * dt
player.y = player.y + player.yvel * dt
end