Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Jumping: How?
- picopaper
- Scratcher
500+ posts
Jumping: How?
I am new to Scratch. Would someone please give me some pointers as to how
I should go about making a character jump? Platypi forever!
I should go about making a character jump? Platypi forever!
if <(platypus) = [platypus]> then
set [platypus v] to [platypus]
Pigs with Jetpacks! (a game of porcine combat)
What is with all these kumquat sig– *gulp*
- firedrake969_test
- Scratcher
500+ posts
Jumping: How?
scratch.gameType.platformer = &jump;
http://wiki.scratch.mit.edu/wiki/Jumping#Advanced_Jumping should work.
http://wiki.scratch.mit.edu/wiki/Jumping#Advanced_Jumping should work.
Last edited by firedrake969_test (Oct. 3, 2013 21:46:59)
Alt account of Firedrake969.
Rocket II: A black and white bitmap space game!
I seek not fame, but education.
;
- FalconGunner99
- Scratcher
1000+ posts
Jumping: How?
Best one I have made so far is:
When [space] key pressed
Repeat (10)
Change y by (3)
End
Repeat (5)
Change y by (2)
End
Repeat (3)
Change y by (1)
End
Repeat (3)
Change y by (-1)
End
Repeat (5)
Change y by (-2)
End
Repeat (10)
Change y by (-3)
End
Last edited by FalconGunner99 (Oct. 4, 2013 01:02:49)
; Oh this? This is just my semicolon. I got it a long time ago, it's quite innocuous. Don't worry about it.
You —> http://i.imgur.com/iVHfwLc.gifv
- turkey3_test
- Scratcher
1000+ posts
Jumping: How?
An easier solution is: Best one I have made so far is:
When [space] key pressed
Repeat (10)
Change y by (3)
End
Repeat (5)
Change y by (2)
End
Repeat (3)
Change y by (1)
End
Repeat (3)
Change y by (-1)
End
Repeat (5)
Change y by (-2)
End
Repeat (10)
Change y by (-3)
End
when key [space v] pressed
set [y velocity v] to (5)
repeat (10)
change y by (y velocity)
change [y velocity v] by (-1)
- firedrake969_test
- Scratcher
500+ posts
Jumping: How?
nobody got my joke scratch.gameType.platformer = &jump;
http://wiki.scratch.mit.edu/wiki/Jumping#Advanced_Jumping should work.
But the wiki article has from the jumpy (no pun intended) to the smooth.
Alt account of Firedrake969.
Rocket II: A black and white bitmap space game!
I seek not fame, but education.
;
- HeroBrineNZK
- Scratcher
82 posts
Jumping: How?
An easier solution is: Best one I have made so far is:
When [space] key pressed
Repeat (10)
Change y by (3)
End
Repeat (5)
Change y by (2)
End
Repeat (3)
Change y by (1)
End
Repeat (3)
Change y by (-1)
End
Repeat (5)
Change y by (-2)
End
Repeat (10)
Change y by (-3)
Endwhen key [space v] pressed
set [y velocity v] to (5)
repeat (10)
change y by (y velocity)
change [y velocity v] by (-1)
Go to the project http://scratch.mit.edu/projects/12250964/#editor and have a look
when green flag clicked
say [My name is HeroBrineNZK]
set (Second Account) to [@Nixinova]
set (YouTube) to [Nixinova]
set (Twitter) to [@Nixinova]
set (Reddit) to [/u/Nixinova]
set (Likes1) to [Minecraft]
set (Likes2) to [Pokemon]
set (Likes3) to [Portal]
set (Sibling1) to [@minecraftcreepers23]
set (Sibling2) to [@CloudyCloudDoggie]
set (Friend) to [@SubduedNut]
- cwrivera99
- Scratcher
500+ posts
Jumping: How?
I have a good one that I use for platformers.
This not only allows for jumping, but also creates gravity. If you are creating a platformer, this would be a really good script to use.
When I Receive [Start Game v]
Repeat Until <Game Over>
If <<Not <Touching Color (Ground Color)>> and <(Jumping?) = [0]>>
Change Y by [-4]
End
End
When Key (Jump Key) Pressed
Set [Jumping? v] to [1]
Repeat [30]
Change Y by [4]
End
Set [Jumping? v] to [0]
This not only allows for jumping, but also creates gravity. If you are creating a platformer, this would be a really good script to use.
when this block is clicked::sensing hat//FYI, this is my old account that I no longer use. My current account is @DaSpudLord.If you are reading this… Then congratulations! You have found the part of my signature that was eaten by a kumquat! (On a side note, you are probably in a kumquat's stomach.) Now get out of the kumquat's stomach and go do something productive with your life. Like playing this game over and over again. Very productive.
forever {do (a [scratch v]::events ring)::sound}::extension cstart
say [what the...?] in (the language of [the moon people v]::red)::control
create [spontaneous v] explosion in [a flea's stomach]::motion
That's not right...::cend
- picopaper
- Scratcher
500+ posts
Jumping: How?
Thanks! I managed to use one of these jump sequences to make My First Project, http://scratch.mit.edu/projects/12911352/#player .
Thanks again… Platypi Forever, Dragons Supreme!
Thanks again… Platypi Forever, Dragons Supreme!
if <(platypus) = [platypus]> then
set [platypus v] to [platypus]
Pigs with Jetpacks! (a game of porcine combat)
What is with all these kumquat sig– *gulp*
- Locomule
- Scratcher
1000+ posts
Jumping: How?
My favorite platformer/side-scroller jump method is the Cosine method. Suprised I didn't see it at the Wiki.
This is a super-easy way to get a smooth, natural style jump that can be used with gravity, scrolling, or whatever you desire…
Make a variable to use as a counter.
Set Counter variable to zero.
Follow that with a “repeat 44” block.
Inside that, put a “change Counter by 4” block.
Lastly, add a “change y by 7 * cos of Counter” block right after the last block, inside the repeat loop.
That is it. This will create a smooth jump that starts fast, slows at the top, and speeds up when falling but always lands exactly where it started. Very handy.
To adjust the jump….
height -Adjust the “7” amount multiplied against the cosine function. An amount of 3.5 will jump half as high.
speed-Change the “44” repeat amount and the “4” amount that the Counter gets changed by. The trick works like this… Use amounts that multiply out to 180, then subtract 1 from the number of repeats. The formula I provided was 45 repeats * change amount of 4 = 180 then minus 1 repeat = 44 repeats with a change amount of 4.
If I make it 89 repeats with a change amount of 2, I get a much slower jump with finer movement.
Hope that helps. This is an old-school method, tried and true
This is a super-easy way to get a smooth, natural style jump that can be used with gravity, scrolling, or whatever you desire…
Make a variable to use as a counter.
Set Counter variable to zero.
Follow that with a “repeat 44” block.
Inside that, put a “change Counter by 4” block.
Lastly, add a “change y by 7 * cos of Counter” block right after the last block, inside the repeat loop.
That is it. This will create a smooth jump that starts fast, slows at the top, and speeds up when falling but always lands exactly where it started. Very handy.
To adjust the jump….
height -Adjust the “7” amount multiplied against the cosine function. An amount of 3.5 will jump half as high.
speed-Change the “44” repeat amount and the “4” amount that the Counter gets changed by. The trick works like this… Use amounts that multiply out to 180, then subtract 1 from the number of repeats. The formula I provided was 45 repeats * change amount of 4 = 180 then minus 1 repeat = 44 repeats with a change amount of 4.
If I make it 89 repeats with a change amount of 2, I get a much slower jump with finer movement.
Hope that helps. This is an old-school method, tried and true
- Locomule
- Scratcher
1000+ posts
Jumping: How?
ps.. If your project uses gravity, you can also use half as many repeats to jump up then let gravity pull you back down.
- MagnetMan4
- Scratcher
4 posts
Jumping: How?
Check out my project gravity for movement and how to make a person jump
- picopaper
- Scratcher
500+ posts
Jumping: How?
Thanks for everything guys! I've made quite a few platformers with these jumping scripts. Thanks again!
if <(platypus) = [platypus]> then
set [platypus v] to [platypus]
Pigs with Jetpacks! (a game of porcine combat)
What is with all these kumquat sig– *gulp*
- Discussion Forums
- » Help with Scripts
- » Jumping: How?