Creating enemies
Enemies are other instances of the Aircraft
class. They appear at the top of the screen and move downwards, until they fly past the bottom of the screen. Most properties are the same for the player and enemies, so we only explain the new aircraft functionality.
Movement patterns
By default, enemies fly downwards in a straight line. But it would be nice if different enemies moved differently, giving the feeling of a very basic artificial intelligence (AI). Thus, we introduce specific movement patterns. Such a pattern can be described as a sequence of directions to which the enemy airplane heads. A direction consists of an angle and a distance.
struct Direction { Direction(float angle, float distance); float angle; float distance; };
Our data table for aircraft gets a new entry for the sequence of directions as shown in following code:
struct AircraftData { int hitpoints; float ...