Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Keep Sprite From Going Off Screen Random Block
- TheElementGuy_Test
-
16 posts
Keep Sprite From Going Off Screen Random Block
Hello, I am using
go to (random position v)to make a sprite go somewhere random. I know the width and height, so how can I keep it onstage?
- Eagle138
-
500+ posts
Keep Sprite From Going Off Screen Random Block
You could make 2 variables called pos_x and pos_y. Then, do this:
Hope this helps!![](//cdn.scratch.mit.edu/scratchr2/static/__631147950d9c399250074fc214591758__/djangobb_forum/img/smilies/smile.png)
set [pos_x v] to (pick random [min screen height] to [max screen height])
set [pos_y v] to (pick random [min screen height] to [max screen height])
go to x: (pos_x) y: (pos_y)
Hope this helps!
![](http://cdn.scratch.mit.edu/scratchr2/static/__631147950d9c399250074fc214591758__/djangobb_forum/img/smilies/smile.png)
Last edited by Eagle138 (Feb. 26, 2022 04:11:19)
~ Eagle38
coder/artist/noob animator :: he/they :: unconventional :: comment ‘e’ on my profile if you see this
just call me Eagle
fancy signature banner coming…one day
- flofoom
-
4 posts
Keep Sprite From Going Off Screen Random Block
This is how you do it
when green flag clicked
if <touching [ edge] ?> then
repeat until <not <touching [ edge] ?>>
if on edge, bounce
end
point in direction ( 90)
end
- Discussion Forums
- » Help with Scripts
-
» Keep Sprite From Going Off Screen Random Block