This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2012-05-08 19:44:37

berberberber
Scratcher
Registered: 2012-03-08
Posts: 1000+

Grids

I HAVE CONFUSION!
How do you lock an item onto a grid? I know it has to do with rounding, but thats all I know.


http://i47.tinypic.com/2iaa73k.png

Offline

 

#2 2012-05-08 21:59:05

MoreGamesNow
Scratcher
Registered: 2009-10-12
Posts: 1000+

Re: Grids

set x to (((round (((x position) + (off_set_x)) / (grid_width))) * (grid_width)) - (off_set_x))
set y to (((round (((y position) + (off_set_y)) / (grid_width))) * (grid_width)) - (off_set_y))
off_set_x and off_set_y shift the grid  smile

Edit: the blocks are kind of big.  Here is is without the off_set_x:

set x to ((round ((x position) / (grid_width))) * (grid_width))
set y to ((round ((y position) / (grid_width))) * (grid_width))

Last edited by MoreGamesNow (2012-05-08 22:00:34)


http://images2.layoutsparks.com/1/218929/rubiks-cube-animated-rotating.gif
"Cogito ergo sum" --  I think, therefore I am

Offline

 

Board footer