Game Development Reference
In-Depth Information
Accelerometers Sometimes Don
'
t Know Which Way Is Up
Being at Red Fly for a few years gave me a special appreciation for coders
who had to deal with motion controls, especially those on the Wii
Remote. All of our games, most recently including Star Wars: The Force
Unleashed II and Thor: God of Thunder on the Wii had quick-time
sequences where you finished off bosses with a slam to the left, right,
up, or down. If you play these games, you
ll quickly realize that left and
right are equivalent, as are up and down. The reason why we did this has
to do with how different players move the Wii Remote.
'
Watch someone when he performs a
slam left
movement, and you
'
ll
see that more often than not, he
ll begin with a slight leftward motion,
then go toward the right as he builds up speed, and end with a big slam
back to the left. This creates quite a bit of madness for the coder trying to recognize this motion,
especially since not all players will do it the same way. It turned out that the best course of action was
to simply watch the left-right accelerometer and just register the slam correctly if they didn
'
'
t move it
(much) in a vertical direction and did so within the time limit.
Working with Two-Axis Controls
Two-axis controls include the mouse, touch screen, or joystick. I ' m not going to talk
about basic topics like grabbing WM_MOUSEMOVE and pulling screen coordinates out
of the LPARAM . Many topics have been written to cover these programming techni-
ques. If you need a primer on Win32 and GDI, I suggest you read Charles Petzold
'
s
classic book Programming Windows: The Definitive Guide to the Win32 API. Instead,
what follows are things you
'
ll need to do after you get those coordinates.
Capturing the Mouse on Desktops
I
t make inside jokes
about capturing the mouse. At least we can still laugh at it. If you
'
m always surprised that programming documentation doesn
'
'
ve never pro-
grammed a user interface before, you probably don
t know what capturing the
mouse means or why any programmer in his right mind would want to do this.
Catching a mouse isn
'
'
'
s high on your list.
To see what you ' ve been missing, go to a desktop machine right now and bring up a
dialog box. A Windows or Mac will do. Move the mouse over a button, hopefully not
one that will erase your hard drive, and click the mouse button that will activate the
button and hold it down. You should see the button graphic depress. Move the
mouse pointer away from the button, and you
t probably something that
ll notice the button graphic pop back
up again. Until you release the mouse button, you can move the mouse all you want,
but only the button on the dialog will get the messages. If you don
'
'
t believe me, open
 
 
 
Search WWH ::




Custom Search