Discuss Scratch

Pikmanfan2002
Scratcher
21 posts

Hold Up To Jump Higher

I'm working on a game where if you hold Up down for longer you jump higher, and tapping it will make it not jump as high. Any thoughts?
Jump Script:
whenclickedsety speedto0 foreverifkeyup arrowpressed?andyspeed=0 thensety speedto7.9 repeatuntiltouchingcolor?changeybyyspeedchangey speedby-0.5sety speedto0 end
asivi
Scratcher
1000+ posts

Hold Up To Jump Higher

.

Last edited by asivi (May 2, 2016 18:40:34)

Pikmanfan2002
Scratcher
21 posts

Hold Up To Jump Higher

asivi wrote:

Hve you tried with ?
yspeed>0
Now I can't jump… and I tried changing it to -1 and nothing works :\
Pikmanfan2002
Scratcher
21 posts

Hold Up To Jump Higher

nvm let me try adding it with and…
still does nothing new
fezzinate
Scratcher
100+ posts

Hold Up To Jump Higher

I made an example project that demonstrates jumping higher when you hold down the jump key. It has a bunch of comments inside to explain everything. The basic idea, and my favorite way of solving the problem, is to cut the velocity of the player in half once you let go of the jump key. This makes sure that whether you do a quick jump or a long jump, you get a nice arch.

https://scratch.mit.edu/projects/107620043/

hope that helps!
-Dan
Pikmanfan2002
Scratcher
21 posts

Hold Up To Jump Higher

fezzinate wrote:

I made an example project that demonstrates jumping higher when you hold down the jump key. It has a bunch of comments inside to explain everything. The basic idea, and my favorite way of solving the problem, is to cut the velocity of the player in half once you let go of the jump key. This makes sure that whether you do a quick jump or a long jump, you get a nice arch.

https://scratch.mit.edu/projects/107620043/

hope that helps!
-Dan
I put this in my game but there's just one problem. It makes it so that when you jump, you fall inside the platform itself, and to fix this I made:
whenclickediftouchingcolor?thenchangeyby2
Which allows me to not fall through the world, but when I insert your code, my code counters it and creates, in the end,
whenclickedforeversetJumpingtoTrue
Any more thoughts?
asivi
Scratcher
1000+ posts

Hold Up To Jump Higher

.

Last edited by asivi (May 2, 2016 18:41:04)

Pikmanfan2002
Scratcher
21 posts

Hold Up To Jump Higher

asivi wrote:

Do yo like this? https://scratch.mit.edu/projects/107851343
whenclickedsety veltosetx veltoforeversetx veltoxvel*0.9ifabsofxvel<.2thensetx veltochangexbyxvelifkeyright arrowpressed?thenifyvel=0thenchangex velby1.2elsechangex velby0.3ifkeyleft arrowpressed?thenifyvel=0thenchangex velby-1.2elsechangex velby-0.3iftouchingedge?thensetx veltoxvel*-1whenup arrowkeypressedifyvel=0thensety velto10repeatuntilyvel<0ornotkeyup arrowpressed?changeybyyvelchangey velby-0.17repeatuntiltouchingcolor?changeybyyvelchangey velby-1goupgroundsety veltodefinegoupgroundsetytofloorofypositionrepeatuntilnottouchingcolor?changeyby1
Now when I press the up arrow, I jump and then the YVel is stuck at -18 and never goes back to 0.
Note that I did put the “set YVel to 0” in there.
fezzinate
Scratcher
100+ posts

Hold Up To Jump Higher

Pikmanfan2002 wrote:

I put this in my game but there's just one problem. It makes it so that when you jump, you fall inside the platform itself, and to fix this I made:
whenclickediftouchingcolor?thenchangeyby2
Which allows me to not fall through the world, but when I insert your code, my code counters it and creates, in the end,
whenclickedforeversetJumpingtoTrue
Any more thoughts?

The code for touching the ground is in my example. You just have to make sure it's checking for the right color. But It seems to me you didn't take the time to study the code to see how it works. Just copying the code won't help you much. Really try to read through the code and the comments I left in there to understand what's going on so you know how to do it yourself

-Dan
asivi
Scratcher
1000+ posts

Hold Up To Jump Higher

.

Last edited by asivi (May 2, 2016 18:41:34)

Pikmanfan2002
Scratcher
21 posts

Hold Up To Jump Higher

asivi wrote:

Pikmanfan2002 wrote:

Now when I press the up arrow, I jump and then the YVel is stuck at -18 and never goes back to 0.
Note that I did put the “set YVel to 0” in there.
Can you share your project in order to see how the ground detection is done?
https://scratch.mit.edu/projects/107394482/
asivi
Scratcher
1000+ posts

Hold Up To Jump Higher

I've seen your project.
Pikmanfan2002
Scratcher
21 posts

Hold Up To Jump Higher

asivi wrote:

I've seen your project.
What? Can't I just make what I want to make? To me, I love the battle mechanic. But I wouldn't say it's “super amazing and if you don't like it you should be ashamed.” I just like the game. But back to the topic, any ideas on how I can jump using
whenclickedforeveriftouchingcolor?thenchangeyby2
asivi
Scratcher
1000+ posts

Hold Up To Jump Higher

¿Como dice usted, caballero?
Pikmanfan2002
Scratcher
21 posts

Hold Up To Jump Higher

asivi wrote:

¿Como dice usted, caballero?
Yo digo que me gusta el juego, pero no estoy totalmente parte de la base de fans y quisiera ayuda en lo que puse en el foro de ayuda con guiones… solo digo .
asivi
Scratcher
1000+ posts

Hold Up To Jump Higher

Bien, no es que me haya gustado el juego (cuando lo acabes estaré encantado de poder probarlo), pero lo que ví me pareció una tomadura de pelo, ahora mismo no puedo darte detalles al respecto pero esa fué la impresión que me dió. Si no es así me disculpo y te deseo buena suerte.
Pikmanfan2002
Scratcher
21 posts

Hold Up To Jump Higher

I found out the problem. In my “goupground” block, I had it

definegoupgoundforeveriftouchingcolor?thenchangeyby2

I had a forever block in there. That was the problem. Thanks for all the help getting me for this conclusion!

Last edited by Pikmanfan2002 (May 3, 2016 14:00:42)

Powered by DjangoBB