Discord
Login
Community
DARK THEME

When I jump and hold it wont stop flying

When I hold my jump key it will just keep flying in the air instead of just jumping a certain amount and falling even if I still holding it

init = function() Quick.init() Quick.addMap("map1", 0,0,400,200) player = Quick.addSprite("player_idle",-150,-50,20) Quick.background = "rgb(70,8,49)" Quick.gravity = 30 Quick.ground = -10000 end

update = function() Quick.update()

if keyboard.RIGHT then player.vx = 100 player.name = "player_run" else if keyboard.LEFT then player.vx = -100 player.name = "player_run_left" else player.vx = 0 player.name = "player_idle" end end

if keyboard.SPACE or keyboard.W then player.vy = 100 end

if not player.grounded then player.name = "player_jump" end

if player.y<-200 then gameover = 1 end

Quick.camera.move(player.x,player.y) end

draw = function() if gameover then screen.clear() screen.drawText("GAME OVER",0,0,50,"rgb(255,255,255)") else Quick.draw() end end

You have to change if keyboard.SPACE or keyboard.W then to if (keyboard.SPACE or keyboard.W) and player.grounded

The if checks first, if one of the keys has been pressed, due to the brackets, and then checks if the player is grounded.

Hope that solves your problem!

Post a reply

Progress

Status

Preview
Cancel
Post
Validate your e-mail address to participate in the community