Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How do I get my sprite to walk forever without getting stuck at the end of the backdrop?
- 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.

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.
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.
So, once you have reached one end, say the left most one, simply reset the position.
so, the scripts would be:

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 clickedBy 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.
forever
move (5) steps//speed
end
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 clickedGood luck and scratch on!
go to x: (-240) y: (0)//left edge
forever
move (5) steps
if <(x position) > [240]> then
set x to (-240)
end
end

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


, 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?
DeezPlease 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)
- Discussion Forums
- » Help with Scripts
-
» How do I get my sprite to walk forever without getting stuck at the end of the backdrop?