Learn Create Your Own Split Screen

Next Page

So we just need to figure out what goes inside add_pipe.

We'll do this in a couple of steps.

We'd already decided that each top and each bottom would be a separate MySprite that will get added to the pipes array. So let's put that much in.

function add_pipe(x_pos, top_of_gap, gap_width) { // First the top pipe var top_pipe = new MySprite(); pipes.push(top_pipe); // Then the bottom pipe var bottom_pipe = new MySprite(); pipes.push(bottom_pipe ); }

Normally, MySprites are created given the url of an image, but in this case our plan is to reuse the same image for all the pipes. So we haven't given the url of an image.