• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Setting x and y to closest tile

samspade

Member
Yes, but there isn't enough information in your question to really help. Generally you snap to a grid, which is what I think you are asking about, with something like x = x div grid_size;, but that isn't the only way, and some of it depends on the rest of your code.
 

TheouAegis

Member
Will (x,y) be the top-left corner of the tile or the middle-center of the tile? If it's top-left corner, you just do x = x div grid_size * grid_size. If it's the middle of the tile, add grid_size/2 to that.
 
Top