Making a grid
Author: | David Evans
|
Submitted: | 27th October, 2002
|
Views: | 5208
| Rated: |
|
|
Making a snap-to grid is easy.
simply write:
Object x pos = ( object x pos / gridsize ) * gridsize
Object y pos = ( object y pos / gridsize ) * gridsize
This method relies on the fact that TGF and MMF cannot use decimals and round DOWN instead of to the nearest.
Making a visual grid is a bit harder...
First you need 2 objects - one which represents the horizantal lines (called horiz) and one for the vertical (called vert).
Both objects must be set to wipe screen with colour of grid
In the code write:
Always: horiz y pos = horiz y pos + gridsize
Always: vert x pos = vert x pos + gridsize
If horiz y pos > height of grid: Horiz y pos = grid y pos
If vert x pos > width of grid: Vert x pos = grid x pos
The end.
|
|
|