
Noah H. answered 10/29/21
AP Computer Science and College Level Computer Science and Math Tutor
I don't know what exactly how to do this in whatever framework you are using but you usually would need some sort of bounding box collision detection. Like say we have a class Mouse and a class Box which describe the mouse and box objects. Then we can do something like