Mech Retriever Dev Blog
As I’m working on the JoyStickEntity, and trying to make the code sufficiently generic so as to be reusable, I find myself re-examining the nature of what I’m doing.
A lot of times that’s critical to writing good code–rethinking how you’re characterizing the problem. In my case, for a while I had been thinking about it in terms of responding to drag events, but actually it was better to think about “locking” a certain point on the joystick to the cursor, and then restricting it to a set of bounds.
This led to me creating a useful extension method on the Point class, ClampIn, which takes a rectangle as an argument.
May you build the ultimate giant robot.