/!\ Can crash on mobile /!\ (because contains an 8000x8000 costume) Move your cursor around the stage. Blue arrow = (mouse x), (mouse y) and [point towards (mouse-pointer)] blocks Pink arrow = detector output
How does this work? The <touching (mouse-pointer)?> block works even if the mouse is not over the stage. The detector sprite (X-mouse) first tests the sign of the mouse coordinates by rotating and testing the mouse. The following happens if both coordinates are positive (and something similar if not): The detector gets an upper bound for the coordinates by going every time 2x as far from (0, 0) than before until it doesn't touch the mouse. The lower bound for the coordinates start at 0. Then it performs a binary search: it repeatedly goes to the average of the upper and the lower bound, tests the mouse there and updates the upper or the lower bound depending on whether it touches the mouse. This is repeated until the difference is at most 1. These are done for the X and Y coordinates separately. Then it picks one of the lower and the upper bound and sets the X-mouse variable to that. Credits: Inspired by the special button detector projects I have seen. The arrows are built-in Scratch costumes.