Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Snap to grid help
- NightmareMoonChan
-
Scratcher
100+ posts
Snap to grid help
I am making a PLants vs zombie game and I have a snap to grid and I was wondering how i could focus the snap to grid on a certain bit of area so it can't get dragged out of the certain area
- nyankatpro
-
Scratcher
500+ posts
Snap to grid help
Only let the sprite snap to the grid if you're within the bounds of the area. The exact x and y values depend on how big the grid is in your project. Like this:
if <<<(x position) < [pos x limit]> and <(x position) > [neg x limit]>> and <<(y position) < [pos y limit]> and <(y position) > [neg y limit]>>> thenEdit: the script gets cut off, just repeat the same process with the y position.
... //snap to grid code here
end
Last edited by nyankatpro (April 27, 2021 16:01:39)
- kajtolmation
-
Scratcher
100+ posts
Snap to grid help
go to x: ((round ((mouse x) / (30))) * (30)) y: ((round ((mouse y) / (30))) * (30))
Another way to do it
- thf-217
-
Scratcher
8 posts
Snap to grid help
is great!!! thxgo to x: ((round ((mouse x) / (30))) * (30)) y: ((round ((mouse y) / (30))) * (30))
Another way to do it

- Discussion Forums
- » Help with Scripts
-
» Snap to grid help





