double jump
I tried some ways to make double jump, but, no one of they work, so, plis help me
Link of my game: https://microstudio.io/rianstar/joyultraadventure/
THANKS FOR THE HELP.
I tried some ways to make double jump, but, no one of they work, so, plis help me
Link of my game: https://microstudio.io/rianstar/joyultraadventure/
THANKS FOR THE HELP.
Joy = class
constructor = function( sprite )
this.sprite = sprite
this.hp = 4
this.canDoubleJump = false
this.jumpKeyReleased = true
end
update = function()
particles.update()
if keyboard.RIGHT then
this.sprite.vx = 100
this.sprite.name = "joy_run"
this.sprite.hflip = 0
else
if keyboard.LEFT then
this.sprite.vx = -100
this.sprite.name = "joy_run"
this.sprite.hflip = -1
else
this.sprite.vx = 0
this.sprite.name = "joy_idle"
end
end
if keyboard.X or keyboard.UP then
if this.jumpKeyReleased then
particles.add(this.sprite.x+(random.next()-.5)*20,this.sprite.y-10)
particles.add(this.sprite.x+(random.next()-.5)*20,this.sprite.y-10)
particles.add(this.sprite.x+(random.next()-.5)*20,this.sprite.y-10)
particles.add(this.sprite.x+(random.next()-.5)*20,this.sprite.y-10)
if this.sprite.grounded then
this.sprite.vy = 250
this.sprite.grounded = 0
this.canDoubleJump = true
elsif this.canDoubleJump then
print("double jump")
this.sprite.vy = 250
this.canDoubleJump = false
end
this.jumpKeyReleased = false
end
else
this.jumpKeyReleased = true
end
if not this.sprite.grounded then
this.sprite.name = "joy_jump"
else
this.canDoubleJump = false
end
end
draw = function()
particles.draw()
end
end
@Loginus the bug then i related yesterday was because of example in tutorials, and when i tried used him in my other game happened the same thing then happened in joyultraadventure, i don't have a sure but the menuscreen example probably is old.
@Loginus how can i put the double jump sprite in this code????
file joy
function update
//.....................................
if keyboard.X or keyboard.UP then
if this.jumpKeyReleased then
particles.add(this.sprite.x+(random.next()-.5)*20,this.sprite.y-10)
particles.add(this.sprite.x+(random.next()-.5)*20,this.sprite.y-10)
particles.add(this.sprite.x+(random.next()-.5)*20,this.sprite.y-10)
particles.add(this.sprite.x+(random.next()-.5)*20,this.sprite.y-10)
if this.sprite.grounded then
this.sprite.vy = 250
this.sprite.grounded = 0
this.canDoubleJump = true
this.isJump = true
elsif this.canDoubleJump then
print("double jump")
this.sprite.vy = 250
this.canDoubleJump = false
this.isDouble = true
this.isJump = false
end
this.jumpKeyReleased = false
end
else
this.jumpKeyReleased = true
end
if this.isJump then
this.sprite.name = "joy_jump"
elsif this.isDouble then
this.sprite.name = "joy_double_jump"
end
if this.sprite.grounded then
this.isJump = false
this.isDouble = false
end
//......................................