Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How do you make a sprite jump in the air(like in mario)?
- cs641311
-
Scratcher
100+ posts
How do you make a sprite jump in the air(like in mario)?
How do you make a sprite jump in the air like mario
This is what I have been doing:
This is what I have been doing:
when [ up arrow] key pressed
point in direction ( up)
move (100) steps
wait (.5) secs
point in direction ( down)
move (100) steps
point in direction ( right)
Last edited by cs641311 (Jan. 30, 2017 17:29:21)
- learncsscratch
-
Scratcher
100+ posts
How do you make a sprite jump in the air(like in mario)?
Actually jumping looks a lot better if you simulate gravity…
Check this out for a coding example
There is also a Mario game that uses the same algorithm Here
Check this out for a coding example
There is also a Mario game that uses the same algorithm Here
- FiveCubed
-
Scratcher
100+ posts
How do you make a sprite jump in the air(like in mario)?
See how this works:
when gf clicked
set [i v] to (10)
repeat (10)
change y by (i)
change [i v] by (-1)
end
repeat (10)
change y by ((0) - (i))
change [i v] by (1)
end
- HurculesAnimator
-
Scratcher
21 posts
How do you make a sprite jump in the air(like in mario)?
when green flag clicked
go to x: (0) y: (0)
glide (1.0) secs to x: (0) y: (7)
glide (1.0) secs to x: (0) y: (0)
- KittyHawk1
-
Scratcher
13 posts
How do you make a sprite jump in the air(like in mario)?
when [ v] key pressed
change y by ()
- cs641311
-
Scratcher
100+ posts
How do you make a sprite jump in the air(like in mario)?
See how this works:when gf clicked
set [i v] to (10)
repeat (10)
change y by (i)
change [i v] by (-1)
end
repeat (10)
change y by ((0) - (i))
change [i v] by (1)
end
Actually,the last repeat is repeat 11 times not ten.
- Deftonestef
-
Scratcher
2 posts
How do you make a sprite jump in the air(like in mario)?
when green flag clicked forever if key up or space pressed repeat 10 change y by number (optional) repeat 10 change y by -number (optional)
- noob159
-
Scratcher
6 posts
How do you make a sprite jump in the air(like in mario)?
when green flag clicked forever if key up or space pressed repeat 10 change y by number (optional) repeat 10 change y by -number (optional)Do you mean
when green flag clickedAnd dont forget left and right movment
forever
if <key [up arrow v] pressed?> then
repeat (10)
change y by (optional)
end
repeat (10)
change y by (optional)
end
end
end
when green flag clicked
forever
if <key [right arrow v] pressed?> then
change x by (optional)
end
end
when green flag clicked
forever
if <key [left arrow v] pressed?> then
change x by (optional)
end
end
- Atari765
-
Scratcher
10 posts
How do you make a sprite jump in the air(like in mario)?
I encourage you to research Acceleration and Velocity, all games use this concept to emulate jumping, running, falling, etc.
https://www.youtube.com/watch?v=I16utd8d6JM&vl=en
https://www.youtube.com/watch?v=JLm3JrCPtWs&feature=youtu.be
https://www.youtube.com/watch?v=0kQrz4dfxDw&feature=youtu.be
I've provided three videos above that my physics teacher sent out to us, they explain the concept well and will hopefully give you an understanding of how to make your character jump.
Here's the basic logic
Variables
1.) Acceleration = -9.81 (the magnitude of gravity)
2.) Velocity = 0 (the rate at which your character moves)
When (jump)
Velocity = 15 (this would be your starting velocity)
Velocity += acceleration (drags character down due to gravity)
if colliding with floor
Velocity = 0 (acceleration doesn't change)
https://www.youtube.com/watch?v=I16utd8d6JM&vl=en
https://www.youtube.com/watch?v=JLm3JrCPtWs&feature=youtu.be
https://www.youtube.com/watch?v=0kQrz4dfxDw&feature=youtu.be
I've provided three videos above that my physics teacher sent out to us, they explain the concept well and will hopefully give you an understanding of how to make your character jump.
Here's the basic logic
Variables
1.) Acceleration = -9.81 (the magnitude of gravity)
2.) Velocity = 0 (the rate at which your character moves)
When (jump)
Velocity = 15 (this would be your starting velocity)
Velocity += acceleration (drags character down due to gravity)
if colliding with floor
Velocity = 0 (acceleration doesn't change)
- Asteroids9
-
Scratcher
10 posts
How do you make a sprite jump in the air(like in mario)?
The I in the change y by?
Last edited by Asteroids9 (April 4, 2020 03:08:57)
- Eoxygen
-
Scratcher
24 posts
How do you make a sprite jump in the air(like in mario)?
Platformer scripts:
WITH WALL JUMPING
when green flag clicked
go to x: (-200) y: (0)
forever
broadcast [tick v]
when I receive [tick v]
if <key [right arrow v] pressed?> then
change [Xv v] by (1)
end
if <key [left arrow v] pressed?> then
change [Xv v] by (-1)
end
change x by (Xv)
set [Xv v] to [((Xv) * (0.88))]
change [Yv v] by (-1.3)
if <touching [platforms v] ?> then
repeat (1)
change y by (1)
end
end
if <touching [platforms v] ?> then
change x by ((Xv) * (-1))
if <key [up arrow v] pressed?> then
set [Yv v] to [14.5]
if <(Xv) > [0]> then
set [Xv v] to [-7]
else
set [Xv v] to [7]
end
else
set [Xv v] to [0]
end
end
change y by (Yv)
if <touching [platforms v] ?> then
change y by ((Yv) - ((Yv) * (2)))
end
if <<key [up arrow v] pressed?> and <touching [platforms v] ?>> then
set [Yv v] to [15]
end
end
- Eoxygen
-
Scratcher
24 posts
How do you make a sprite jump in the air(like in mario)?
CHECK MY "THE WHITE WINDFALL" PLATFORMER AND USE THE SCRIPT
ALSO LOVE, FAVE, AND FOLLOW!!
- Eoxygen
-
Scratcher
24 posts
How do you make a sprite jump in the air(like in mario)?
when I receive [MJM3 has 500 followers v]
repeat (5+ years)
MJM3 is the best coder on Scratch!!
end
- Eoxygen
-
Scratcher
24 posts
How do you make a sprite jump in the air(like in mario)?
Platformer scripts:
WITH
WALL
JUMPING
when
clicked
go
to
x:
-200
y:
0
forever
broadcast
tick
when
I
receive
tick
if
key
right arrow
pressed?
then
change
Xv
by
1
if
key
left arrow
pressed?
then
change
Xv
by
-1
change
x
by
Xv
set
Xv
to
((Xv) * (0.88))
change
Yv
by
-1.3
if
touching
platforms
?
then
repeat
1
change
y
by
1
if
touching
platforms
?
then
change
x
by
Xv
*
-1
if
key
up arrow
pressed?
then
set
Yv
to
14.5
if
Xv
>
0
then
set
Xv
to
-7
else
set
Xv
to
7
else
set
Xv
to
0
change
y
by
Yv
if
touching
platforms
?
then
change
y
by
Yv
-
Yv
*
2
if
key
up arrow
pressed?
and
touching
platforms
?
then
set
Yv
to
15
end
- Asteroids9
-
Scratcher
10 posts
How do you make a sprite jump in the air(like in mario)?
Actually make it Change I by 1
- cookiemonster984
-
Scratcher
43 posts
How do you make a sprite jump in the air(like in mario)?
thanks you,this was very helpful for my upcoming platformer (please look for it,it will be called scratch run-part one)
- Paigeri
-
Scratcher
500+ posts
How do you make a sprite jump in the air(like in mario)?
Please don't necropost!
If you have a problem, feel free to create your own thread!
If you have a problem, feel free to create your own thread! - Discussion Forums
- » Help with Scripts
-
» How do you make a sprite jump in the air(like in mario)?
