Discuss Scratch

EliasShalohm
New to Scratch
4 posts

How Do I Add A Long Jump? (Help)

I have a jump script with collision and all that, and it works. But, I want to add a separate type of jump along with the normal jump where when you hold W and press space, you will jump a short distance in the air and float there for a small amount of time before going back down. So far I have not found a way to implement this into the program.

deck26
Scratcher
1000+ posts

How Do I Add A Long Jump? (Help)

So how are you handling a normal jump? Share what you have so we can tell you how to adjust it.
ParadoxScratching
Scratcher
100+ posts

How Do I Add A Long Jump? (Help)

if <<[(y vel] < [4]> or <key [up arrow v] pressed?>> then 
change [y vel v] by (-1)
else
change [y vel v] by (-2)
end

Use this to replace the gravity script. This is all I could give you unless you share the project.

Did I help? If so, consider following me!

Forums not helping out your scripts? Want me to answer your questions in particular? Put your projects you have a question of in this studio! I would try my best to answer you. I care more about understanding the problem than knowing how to fix the problem.
https://scratch.mit.edu/studios/4636701/
EliasShalohm
New to Scratch
4 posts

How Do I Add A Long Jump? (Help)

https://scratch.mit.edu/projects/207822631/
That is the project. In the actual tank/player are the jump scripts.

(Resolved Y Prolonged is the part where I want to add the longjump/float part although if i have to remove it im ok with that.

Last edited by EliasShalohm (March 6, 2018 14:56:44)

deck26
Scratcher
1000+ posts

How Do I Add A Long Jump? (Help)

Not sure you need a separate custom block. Something along the lines of setting a variable to 10 (adjust as required) when w is pressed (unless it is already more than 0) and reducing it by 1 when jumping. When it gets to 0 you start falling from the jump. When not jumping it is set to 0 so pressing w without the space doesn't do anything.

Haven't time to work out the coding at the moment but something like that should work.
EliasShalohm
New to Scratch
4 posts

How Do I Add A Long Jump? (Help)

Im still trying to experiment around with the script to find a way to add a float-jump, but so far no luck.
deck26
Scratcher
1000+ posts

How Do I Add A Long Jump? (Help)

I strongly suspect you need to start again with the movement scripts. It's confusing having x and y changing in the main loop and in the Resolve scripts.

I'd aim for the main loop detecting what keys are being pressed but only changing x and y velocity and checking the current state - eg most projects won't allow jumping in mid-air so the jump key can only work when y-velocity is 0 (or a variable ‘jumping’ is 0). So your w key is dealt with in a similar way - it only has an effect in limited circumstances and sets a variable to indicate it has been pressed - holding w presumably can't keep them in the air indefinitely for example.

Once you've checked all the keys and set your velocities you can move the sprite - generally you'll move as far as the velocities dictate but less if you hit an object or land on the ground.

Save the current version of the sprite to the backpack or duplicate in the project but disable the scripts so you can always go back to it.
EliasShalohm
New to Scratch
4 posts

How Do I Add A Long Jump? (Help)

I am not trying to allow it to jump in midair, im trying to get it to jump, float there for a short period of time then fall back down.
Vortexore
Scratcher
20 posts

How Do I Add A Long Jump? (Help)

Hi this might help you out a little bit!!



when green flag clicked
if <> then
define (List set to X position of sprite)
end


And then just fill in the blanks this is just a quick thing I made just for you and Its just a basic lay out for you to base your/the code of off I hope this helps you and thanks!

Last edited by Vortexore (March 7, 2018 17:37:34)

Powered by DjangoBB

Standard | Mobile