var _cell_size = 32;
var _x = floor(x/_cell_size)*_cell_size;
var _y = floor(y/_cell_size)*_cell_size;
@bodilliam fyi the div keyword will automatically floor it so this code is doing the same thing as my code, only difference is the flooring is happening internally by yoyo.I do it like
GML:x = tilesize * (x div tilesize)
@bodilliam This code works too but it only works based on the objects built in instance variables so if you want to snap something that doesn't involve those then you will have to use my code or @Roman P.There ismove_snap(32, 32)
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.@bodilliam fyi the div keyword will automatically floor it so this code is doing the same thing as my code, only difference is the flooring is happening internally by yoyo.
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.