Game Development Reference
In-Depth Information
case LEFT: left = false; break;
case RIGHT: right = false; break;
case W:
up
= false; break;
case S:
down = false; break;
case A:
left = false; break;
case D:
right = false; break;
}
});
Now that you have added another set of player movement control keys for your
player to use to control the game play, your code is error free, and has a simple, effect-
ive structure, as is shown in Figure 9-14 . We are handling the events one time at the
very top of the Scene object named scene, not involving any Scene Graph Node objects
in this event handling “calculation,” and are using only a few bytes of memory to hold
eight Boolean (on/off) values.
Figure 9-14 . Add the case statements for ASDW keys to give users two key options, or to allow two-handed game
play
 
 
Search WWH ::




Custom Search