Pipe Class Creation

8 minutes
Share the link to this page
Copied
  Completed
Let's create our pipe class.

Transcript

Hello and welcome to the sixth tutorial in the cocoa studio x Flappy Bird c++ tutorial series. And in this part we'll be looking at pipe class creation, we're going to be creating the pipe class, we're not going to be fully implementing it yet. We'll also be using the source code from the previous part of this series. And as usual, we're going to is going to keep using the source code from the previous part. So there'll be a link in the description to that source code if you don't have it. So we will now create class that was born the post but first we will set up the update function that will be called every frame.

This tutorial will just cover creating the class and its methods, not the actual parts which we which will come in the next tutorial. So let's go ahead and open up our project. Okay, so what we're going to do is go to our definition file, when the critical your definition has defined Pipe on the scores on this call frequency 0.005. And the reason is 0.05 is not going to spawn in every 0.005 seconds. The reason that number so low is due to the faculty factoring in their screen resolution, hence it's going to move you obviously see in a moment. So let's go ahead and go to our games you need to create a function group will be coding Floyd, spawn type Hello, dt.

And in our game scene, what we're gonna be doing is we're sorry, we just need to schedule this method for implementing it. This schedule What we're gonna do, we're gonna be using this one right here then wonder kid you on the course selector and for the selector will again seen code on cola. I'm going to put the method that we just created so spawn point and for the interval can do is pipe on the score bone need to include the definition file first hash define hash include depth initial, sorry about that. So, high frequency, tongue by visible size where I was factoring in the screen size, so we spawn in relative to if you have iPad retina, it will spawn Less or you're seeing less and if you have an iPad or seem more or Yeah, that's how it will be. So the next step is to actually just implement our function.

So under void games in code of commerce on pipe flow d t we're not going to actually do anything here for now let's create the pod class I was going to call it pipe for D that was gonna build this make sure everything running a Okay Okay, so what we're gonna do is go to a classic folder, select select these two classes will duplicate them in the name this pipe de haitch not only poked us up pay these to our classic folder. I did Matt target Why not? an F we go to a pipe dot Hage we can get rid of actually, what we can do, we can get rid of most of it, we'll get rid of all of this change is to click on the score haitch. Copy and paste that here. And here as well can rename this to point. It's not inherited from anything at all is going to have a pod constructor is going to have a function to convert quotes on pipe.

This is going to take code costs to the layer I'm gonna have some Are you the very last level into calculus to play on a separate line, focus today sois the ball size costs to the Vic two origin, we're just putting them in the head so we can use them. later on. We will review them all over the place in the pipe class instead of just in this in the constructor. And now what we can do is go to our pointer CPP and what we will do literally delete everything, but ones that remain will leave the definition in there. We'll need that later on. Get rid of the main many scene and change the last thing to pipe the height.

And now what we're going to do first is do the constructors of pipe, colon colon pipe. And in here, we're just going to simply initial visible signs to director get instance. Get visible size their origin equal director common common get instance get so it's get visible in Orange Orange with origin was in orange before I'm sorry, but I think often I said he wants. Now what we're going to do is implement the spawn point method so not implemented just created here and not gonna implement it yet class to layer and in here we're going to see see log Finally, we will create a pipe object and call it within this bomb pipe method that has been scheduled to do that in the game scene. So we need to include the pipe header. So pipe H, we're going to create pipe pipe as well.

Now against in our CPP in here. What we're going to do is just do pipe dot spawn pipe and we're going to pass in this now if we run it or happened is when we go to the game screen, nothing will be spawning, but we'll get a cc log saying spawn pipe, spawn pipe, spawn pipe, and I'll just be where we can go from here to actually spawn physical splash screen, click play. It will slow down. He has gone pipe, bomb pipe, Pompeii, Pompeii, et cetera. That is it for this part of the series. In the next part we'll be looking at actually exporting the pipes.

If you have any questions feel free to message us at support at solar systems. Dakota UK the email will be in the description can comment on this video or just directly messages via YouTube, or the require links for source code will also be in the description. And as usual, thanks for watching and I hope you have a great day.

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.