Enemies
Space is filled with more dangers than just rocks. In this section, you’ll create an enemy spaceship that will periodically appear and shoot at the player.
Following a path
When the enemy appears, it should follow a path across the screen. It’ll also look better if it’s not just a straight line. To keep it from looking too repetitive, you can create multiple paths and randomly choose one when the enemy appears.
Create a new scene and add a Node
. Name it EnemyPaths
and save it. To draw the path, add a Path2D
node. As you saw earlier, this node allows you to draw a series of connected points. Selecting this node displays a new menu bar:
Figure 3.23: Path drawing options
These buttons let you draw and modify the path’s points. Click the one with the green + symbol to add points. Click to start the path somewhere just outside the game window, and then click a few more points to make a curve. Note that the arrows...