Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How to Set X and Y Limits w/ Random Position
- lunar_red-ribbon
-
1 post
How to Set X and Y Limits w/ Random Position
For a game I'm making, I'm trying to code it so the target has a limit for how it can go but I don't know how to do it.
- GAMS2
-
1000+ posts
How to Set X and Y Limits w/ Random Position
If you are looking to limit how far the x and y can go when randomized here's some code for that:
For example if you only want it to go between -10 and 10 x and -10 and 10 y:
For example if you only want it to go between -10 and 10 x and -10 and 10 y:
Last edited by GAMS2 (March 25, 2025 16:37:03)
- geramihasfood
-
100+ posts
How to Set X and Y Limits w/ Random Position
you could code a variable called limit For a game I'm making, I'm trying to code it so the target has a limit for how it can go but I don't know how to do it.
then set it to the limit you want it to be at
after that you can use the variable and use it in this
and you'll get this script
an example of the script could be
I hope this helped.
Last edited by geramihasfood (March 25, 2025 18:29:06)
- Discussion Forums
- » Help with Scripts
-
» How to Set X and Y Limits w/ Random Position