Sidequest

Preface

Now that we have a functional bird with collision detection, it's time to add the pipes. We'll start by focusing on what goes into rendering the top and bottom pipes. Once we've created the pipe class, we'll move on to the pipe manager that will spawn pairs of pipes at a set interval.

The scene will look something like this:

Pipes diagram
Pipes diagram

The pipe manager will spawn a top and bottom pipe at the same time with a small gap in between for the bird to fly through. Each pair of pipes will have the same gap between them, but spawn at a different position relative to the vertical center of the canvas. The horizontal line represents the current spawn position along the y-axis.

Goals

Our goal for this chapter will be to two draw two pipes. Both pipes will be positioned in the center along the x-axis, and will be spaced apart vertically along the y-axix by a distance of 50 pixels in both directions (up and down).

Let's get to it!