Discuss Scratch

_-_-_-_Hi_-_-_-_
Scratcher
11 posts

How to limit a certain ammount of jumps to a character until it is on a platform

I'm tryna figure out how to limit a sprites jumps until it touches a platform so it can jump again any ideas? (I'm also a new scratches)
Catscratcher07
Scratcher
1000+ posts

How to limit a certain ammount of jumps to a character until it is on a platform

the implementation of this will vary by project, but in general, store the number of jumps the player has in a variable, constantly set to the max while on the ground; the script for jumping should have this condition.
<<(jumps) > [0]> and <(jump cooldown) < [0]>>
whenever you jump, set jump cooldown to (you will have to play around with this number), at some other point in the script that regularly gets ran, reduce that value. you need this to avoid the player having to tap the jump button for just one frame to avoid wasting jumps.

trouble with clones? view my clone id toolbox! I also have built the bases of a tower defence game link here.
If someone on help with scripts is saying that something can't be done, they should be suspected of being a team limit grunt.
_-_-_-_Hi_-_-_-_
Scratcher
11 posts

How to limit a certain ammount of jumps to a character until it is on a platform

Thank you so much!
_-_-_-_Hi_-_-_-_
Scratcher
11 posts

How to limit a certain ammount of jumps to a character until it is on a platform

But what kind of block do I put this in an If then block or If else?
Could you tell me where in my code for my game where to put it?
It's called ultimate adventures

Last edited by _-_-_-_Hi_-_-_-_ (March 23, 2024 15:02:02)

Catscratcher07
Scratcher
1000+ posts

How to limit a certain ammount of jumps to a character until it is on a platform

if-than, in place of your regular jump script.

trouble with clones? view my clone id toolbox! I also have built the bases of a tower defence game link here.
If someone on help with scripts is saying that something can't be done, they should be suspected of being a team limit grunt.
_-_-_-_Hi_-_-_-_
Scratcher
11 posts

How to limit a certain ammount of jumps to a character until it is on a platform

oh thanks!
But i'm still not sure where to put it
Could you check my script and then tell me where to put it?

Last edited by _-_-_-_Hi_-_-_-_ (March 23, 2024 15:03:50)

Catscratcher07
Scratcher
1000+ posts

How to limit a certain ammount of jumps to a character until it is on a platform

_-_-_-_Hi_-_-_-_ wrote:

oh thanks!
But i'm still not sure where to put it
Could you check my script and then tell me where to put it?
Not without a link to the project! do you have basic collisions and gravity implemented yet? if not, you will have to implement those before we can go any further. Our script will go where the jump script would go in a standard platformer engine.

trouble with clones? view my clone id toolbox! I also have built the bases of a tower defence game link here.
If someone on help with scripts is saying that something can't be done, they should be suspected of being a team limit grunt.
_-_-_-_Hi_-_-_-_
Scratcher
11 posts

How to limit a certain ammount of jumps to a character until it is on a platform

I did put gravity and I will put the link to the project
https://scratch.mit.edu/projects/988251079/
Catscratcher07
Scratcher
1000+ posts

How to limit a certain ammount of jumps to a character until it is on a platform

inside the “key up arrow pressed ” loop would be where you put it, but you will have to replace all the “change y by”s with
   
change [y momentum v] by (...)

and change y by y momentum the in the “not touching ground” loop.

trouble with clones? view my clone id toolbox! I also have built the bases of a tower defence game link here.
If someone on help with scripts is saying that something can't be done, they should be suspected of being a team limit grunt.
_-_-_-_Hi_-_-_-_
Scratcher
11 posts

How to limit a certain ammount of jumps to a character until it is on a platform

Thanks!
_-_-_-_Hi_-_-_-_
Scratcher
11 posts

How to limit a certain ammount of jumps to a character until it is on a platform

So this is what the 2 things look like right?
Start
Forever loop
If not touching Ground then
change y by y momentum



& the second one looks like
When green flag hit
Forever
If key up arrow pressed then
if jumps greater then 0 and jump cooldown less than 0 then
Repeat 5
Change y momentum by 5
here's link if anything wrong
https://scratch.mit.edu/projects/988251079/editor/

Last edited by _-_-_-_Hi_-_-_-_ (March 23, 2024 15:44:17)

Catscratcher07
Scratcher
1000+ posts

How to limit a certain ammount of jumps to a character until it is on a platform

y should be the actual y value, not a variable named y.

trouble with clones? view my clone id toolbox! I also have built the bases of a tower defence game link here.
If someone on help with scripts is saying that something can't be done, they should be suspected of being a team limit grunt.
_-_-_-_Hi_-_-_-_
Scratcher
11 posts

How to limit a certain ammount of jumps to a character until it is on a platform

Thx!

Powered by DjangoBB