This is a self-explanatory post.
(keep in mind that you have to account other higher platforms too)
https://studio.code.org/projects/gamelab/E6F7oSjocy1VkV53JS1eF35ScWdv3GY8bmkk8F96p1g/

If you want to control the height of your jump with how long you hold the jump button, you could use keyWentUp to set your speed to 0 (but that would be a little jarring, so maybe with a minimum velocity thing that would be good)
Or if you just want the down arrow to stop your upward momentum, you could first check if your moving up, if so set it to 0, then have it so you start falling after

i cannot jump while on platform
i personally would add all the sprite to a group, then make it so if touching said group then set a variable called jump_allowed to true, and when you jump, jump_allowed is switched to false

like this
var jump_allowed = false;
var anything_you_can_jump_off = createGroup();
var player = createSprite(200, 200);
function draw() {
if (anything_you_can_jump_off.collide(player)) {
jump_allowed = true;
} else {
jump_allowed = false;
}
if (keyWentDown("up") || keyWentDown("space")) {
jumping&gravity_function();
}
}

ah... so you posted here to, well i saw this in the CDO teachers forum... my answers there if you plan on using it

sum groundcheck that might work Where floors in the GroundCheck function is a group
`var Groundcheck = false;

function draw(){

GroundCheck();
}

function PlayerJump(){
if (GroundCheck){
.. Player.velocityY -= 8;
. }
}

function GroundCheck(){
Player.y += 1;
Groundcheck = Player.isTouching(Floors);
Player.y -= 1;
}
`

Try making 3 varibles.
"Jump availible"(true by defalt)
"jumping"(false by defalt)
"jumptime"(0)
attach jumptime to an invisible sprite at 0, (Y=whatever u want)
Make it so when jumpAvailable is true, if space bar is pressed, Jumping=true, and if Jumping is true, jumpavailable= false player velocity y= whatever speed jumping is at.
If jumping is true, Jumptime's sprite velocity is 1. When the sprite's X coordinate is large enough, jumptime is set to 0, the sprite is sent back to 0, and jumping is false.
When player touches a platform and is above it, jumpavailable is set back to true.

person
Very well I will make my own original approach

So first you’re going to want to set up an array with some nested arrays inside of it. Next, you need to make a function to define blocks that the player will collide with.
For collisions with rectangles, you can use some trig to find the outline of a rectangle. However, you can get around this by setting the background to white after defining each block, drawing the block once, and using two 400x for loops to loop through each x and y value. Also, you’ll need another set of nested arrays to record if a spot is rectangle or background after you use get.
It’ll look something like this:
function defineBlock(x,y,blahblahblah){
background(255,255,255);
var b = new block(x,y,blahblahblah);
drawBlock(b);
checkOutline();
}
function checkOutline(){
var arr = [];
for(var i=0; i<400; i++){
arr.push([]);
for(var q=0; q<400; q++){
arr[i].push([]);
}
}
for(var i=0; i<400; i++){
for(var q=0; q<400; q++){
if(get(q,i) === rgb(255,255,255)){
arr[q][i] = false;
}else{
arr[q][i] = true;
}
}
}
}

Now, the only problem with this is if the block is more than 400 wide or more than 400 tall. To solve this we'll use a while loop to keep repeating this sequence of checking the outline of the block until none of the outline is on the side.
It should look something like this:
var touchingEdge = false;
while(touchingEdge === true){
touchingEdge = false;

push();
img = get();
translate(random(-100000,100000),random(-100000,100000));
scale(random(0,1));
image(img,0,0);
checkOutline();
pop();

for(var i = 0; i < arr.length; i++){
if(arr[ i ][0] arr[ i ][arr[ i ].length-1]){
touchingEdge = true;
}
}
for(var i = 0; i < arr[0].length; i++){
if(arr[0][ i ] || arr[arr.length-1][ i ]){
touchingEdge = true;
}
}

}
Now, the only thing that could possibly go wrong with this is the random() not moving the screen enough in the event you have a really big block.To solve this, you can change random(-100000,100000); to random(-100000000,100000000);
or whatever you think is big enough to fit all of your rectangles

Ok now, onto collisions.
You should now have a 400x400 array containing a bunch of true's and false's. To actually utilize this array, we're going to utilize a little thingy I like to call the utilizer. Here's how it works:
var array = [/* un-utilized gobbledygook in here */];
function utilize(e){
var plusPlusExp = new RegExp("__env__\\.InfiniteLoopCount\\+\\+;\\n", "g"), ifClauseExp = new RegExp("\\n\\s*if \\(__env__\\.InfiniteLoopCount > 1000\\) {[\\s]+__env__\\.InfiniteLoopProtect\\('[^']*'\\);[^}]+}", "g"),newExp = new RegExp("__env__\\.PJSCodeInjector\\.applyInstance\\((\\S+), '\\S+'\\)", "g"),envExp = new RegExp("__env__\\.", "g"),noBreakSpace = "\u00a0";return [];
}
array = utilize(array);

It always works, no matter the circumstance.

Ok now, time to apply this stuff in order to answer your question. In order to prevent the player from jumping in mid air, you need to first disable all jumping while the player isn't touching any part of a block.
To do this we need to calculate all possible trajectories that could be created by player input. To do this, all we need to do is have the player input all possible trajectories. Then, once you have all of those trajectories, go through and determine in which ones the player should be able to jump and in which ones the player shouldn't.

I know, now that' i've explained it, it's all so simple.
No need to thank me, I do stuff like this all the time. It's like second nature to me.

btw does anybody know how to upload sound because all the mp3 files i upload sound ablsolutly silent

    person the only causes I can think of right now is either the file is large and takes a while to load, or you renamed a non mp3 file into an mp3, which doesn't work well

    person also also... playSound does http(s)// requests! so if it's to big for the assets page you can always host it somewhere else

    Chat