Discuss Scratch

dancecentralgirl
New Scratcher
14 posts

How do I get my sprite to walk forever without getting stuck at the end of the backdrop?

Hi i know there is probably a obvious answer but i can't figure it out for the life of me! I would love some advice on ways to move the character forever.
Thank you for reading. ps i haven't posted anything yet.
P444
Scratcher
500+ posts

How do I get my sprite to walk forever without getting stuck at the end of the backdrop?

Hi and welcome to scratch!
There are a few options you could use. You can either change x and y positions of a sprite, or use the move block.
You should stick to the move block for now. Simply, put it in a forever loop.
when green flag clicked
forever
move (5) steps//speed
end
By default, the sprite will be moving to the right side of the screen, so you can use a point in direction block to change direction.
point in direction (0 v)
0 = Up
180 = down
90 = Right
-90 = Left

And if you want the sprite to only turn left-right (not spin around), use the set rotation style block.
set rotation style [left-right v]

So, once you have reached one end, say the left most one, simply reset the position.
so, the scripts would be:
when green flag clicked
go to x: (-240) y: (0)//left edge
forever
move (5) steps
if <(x position) > [240]> then
set x to (-240)
end
end
Good luck and scratch on!

Last edited by P444 (Oct. 20, 2016 18:52:10)

dancecentralgirl
New Scratcher
14 posts

How do I get my sprite to walk forever without getting stuck at the end of the backdrop?

Thank you that is really helpful! i can't wait to try the scripts: out!, and ps love your profile picture
5HRSte
Scratcher
1 post

How do I get my sprite to walk forever without getting stuck at the end of the backdrop?

Deez
abcde1234qwe
Scratcher
500+ posts

How do I get my sprite to walk forever without getting stuck at the end of the backdrop?

5HRSte wrote:

Deez
Please don't necropost.
Hari_Lister
Scratcher
1 post

How do I get my sprite to walk forever without getting stuck at the end of the backdrop?

Nutz (super helpful to)

Last edited by Hari_Lister (Oct. 16, 2023 14:47:30)

Powered by DjangoBB