Align something to a grid
How would you align something to a grid?
I need to know this because i am making a level editor for my game, and i want the map to be in a 16 by 16 grid, so when the user places a tile it need's to be aligned with a grid.
How would you do it?
snapPosition = Vector2<int>( static_cast<int>( std::floor( mouseX / tileSize ) ), static_cast<int>( floor( mouseY / tileSize ) ) );
Something like that ...
Something like that ...
You probably want to use `round', not `floor'. If you don't have `round', you can write it like this:
double round(double x) { return std::floor(x+.5);}
It depends... Are the tiles' centers snapped to grid intersections (round) or are the tiles' top-left corner is snapped to grid intersections (floor)?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement