TGC Codebase Backup



snap to grid formula by thebulk71

29th Jul 2007 15:45
Summary

this is a function to snap to grid, in any dimension.



Description

simply enter the value you want to snap, and how wide the grid is and it will return a value for you... quite simple really.



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    do
cls



circle snap_to_grid(mousex(),20),snap_to_grid(mousey(),20),5

loop



function snap_to_grid(value,grid)
snap=floor(value/grid)*grid
endfunction snap