How To: Snap To A Grid (simple)

Ever wanted blocks on a grid? Now you can!
##1. Create a text object and put this code in.


##2. Make a new value (in this case, it’s ‘X’). Make a new rule in the same text object with this code.

##3. Now make another text object and new value (here, the second value is ‘Y’)


##4. To have something drag to a grid, add this rule to the object dragged.

##Of course now,##
you can change things up. The “100” in the first rules is how wide the squares of the grid are. You can change them to any other, but make sure all of the numbers are all equal.
##Happy Hopscotchin’ :wink:##
Note: This works because Hopscotch doesn’t get too precise when measuring sizes of objects.

12 Likes

couldn't you just directly set X and Y to last touch X and Y /100?

1 Like

If it was
last touch X/Y ÷ 100 × 100
it would make a regular drag effect (object right under finger).
With this code, it make a grid effect because the size block automatically rounds to the nearest whole number.
(So yeah, try it out)

5 Likes

Yey revive.
good topic guitar of the fishy.

1 Like

Thanks AwesomeNachos :D

With the update adding in the round operation block, I was planning to improve this tutorial but never got around to it. I probably should lol

2 Likes

Figtars the old

The old

Omg

I am old lol

I've been here since August 6th, the first time the forum was out of beta testing or whatever

1 Like