Reframing the problem

logo

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.

Like, Share, Subscribe, or Tweet us!

Check us out on Youtube or Deviantart!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s