Creating a complete game: Breakout
This document has been updated for use with GapiDraw 4.0 or later.
Step 11 : Button input
We will now add button input to the application so that the player can control the bat. For this we will use the following two functions in CGapiApplication:
On some devices multiple keys can be pressed simultaneously, so take this into consideration when designing your button handler.
When handling the button input on Windows Mobile devices you can only count on one thing: nothing is standardized. Long ago Microsoft tried to standardize the button codes for three standard keys on Pocket PC devices, but few manufacturers followed those guidelines so today the codes received will vary from device to device. Your best option is to provide a settings screen shown during startup that allows the user to configure the buttons in your application to match the device.
For our simple game we will capture two hardware keys and two directional keys.
Add the following code to myapplication.cpp:
As you can see, depending on the current game mode the buttons do different things.
No let's go on and add sound to our application.