Re: Optimal way to track mouse-hover/touch over a tile position ?
Posted: Wed Oct 11, 2023 3:55 am
As always, i am only half serious, yes in the end it really is micro optimization in this case.
But my mind gets a little stroke seeing the tile position created and compared new every frame.
And it totally itches me to wrap this into a check if the mouse has even moved at all first.
So the lines i would ad are either "if oldx~=mousex then oldx=mousex and the rest of the block here" or i would use love.mousemoved to actually create mouseX/mouseY, check if they exist to run the block and then nil them.
BUT i am also pretty sure most of this block is subjected to jit optimization making this entirely unnecessary because its skipped anyway. In this case at least, if the check would be more complicated, say youre probing which pixel is touched in a picture instead finding a tile, it would have a greater impact.