Hi guys I am somewhat new to GM, and was wondering if there was a easy way to make a snap to grid. There is on Construct 3 and I was just interested in knowing. Thanks!
var _cell_size = 32; var _x = floor(x/_cell_size)*_cell_size; var _y = floor(y/_cell_size)*_cell_size;
x = tilesize * (x div tilesize)
True. I just figured it out that way first, tbh I always forget which side of div takes what lol so might switch. Wonder if there's much performance difference.
There wouldn't be a substantial performance difference. It's just a matter of preference/habit which one you use. Sometimes the yoyo internal stuff can throw you off and cause issues down the road in your project that can be hard to troubleshoot though. For example, hypothetically if you didn't know that the div keyword floored to an integer and you used it expecting it to only act as a "/" symbol, then down the road you could have unexpected behavior in your game that could take time to troubleshoot. That's the main knock on the internally handled code from the game engine anyhow.True. I just figured it out that way first, tbh I always forget which side of div takes what lol so might switch. Wonder if there's much performance difference.