In this chapter, we will show you how your game program can react to mouse clicks and button presses. In order to do this, we need an instruction called if that executes an instruction (or a group of instructions) if a condition is met. We will show you how to formulate conditions for these instructions using Boolean values. We will also introduce enumerated types as another kind of primitive type. We will use the if-instruction to deal with keyboard and gamepad input in the Painter game.
Unable to display preview. Download preview PDF.