Optimal way to track mouse-hover/touch over a tile position ?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
User avatar
BrotSagtMist
Party member
Posts: 661
Joined: Fri Aug 06, 2021 10:30 pm

Re: Optimal way to track mouse-hover/touch over a tile position ?

Post by BrotSagtMist »

Bobble68 wrote: Tue Oct 10, 2023 11:01 am Just out of curiousity, what would those two lines be?
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.
obey
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot] and 3 guests