Discuss Scratch

898372a
New Scratcher
6 posts

Code to roll the ball while moving

I am having trouble making my soccer ball roll as it moves side to side. I put the glide command to go back and forth, but I don't know how to make it roll while moving from one end to another end. Please help me! Thank you.
mstone326
Scratcher
1000+ posts

Code to roll the ball while moving

First, welcome to Scratch. You mention you use the “glide command” but the project shared on your account has no glide blocks. Is there another project you haven't shared that uses glide instead of repeat 10 blocks? I want to make sure I am helping on the right project.
898372a
New Scratcher
6 posts

Code to roll the ball while moving

Sorry, I forgot to share mine. The one that I am having trouble with is “Rolling Ball”. So I want to make the ball move left and right a little bit in front of the soccer player, and rolling at the same time. Thank you!
mstone326
Scratcher
1000+ posts

Code to roll the ball while moving

Is this for a class project? If so, did they give directions?

Do you want the ball to move and roll when the player touches it? or just stay a bit in front of the player and roll?
Tutor-42
Scratcher
100+ posts

Code to roll the ball while moving

First let us put the ball in the correct position.
———————————————————–
The player moves from 160,-5 to -220,-5.

In the Scratch editor, use
gotox:160y:-5
to put the player in position at the end of the first glide.
Now drag the ball to be just in front of the player.

You can see that the end position for the ball to glide should be close to 203,-50.
Similarly the end position for the ball for the second glide should be close to -177,-49.

Update the ball glide blocks with these ball positions.

Now let us make the ball roll
————————————–
Add an extra Green Flag script to the ball sprite as follows:

whenclickedsetrotationstyleall aroundforeverturn20degrees

Last edited by Tutor-42 (Oct. 29, 2019 03:48:21)

898372a
New Scratcher
6 posts

Code to roll the ball while moving

I want the ball to move a little bit in the front of the player, while rolling. And also, where should i put the block, “go to x 160, y -5”? Thanks for the help.
898372a
New Scratcher
6 posts

Code to roll the ball while moving

So I tried that, but I want the ball to move as well. Is there anyway I can make that happen? I myself am going to try some different blocks and see if it works. I will get back to you later on how the ball is moving.
898372a
New Scratcher
6 posts

Code to roll the ball while moving

Never mind, it works. Thank you so much!!!

Powered by DjangoBB