Flappy Bird Class Creation

7 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$69.99
List Price:  $99.99
You save:  $30
€65.26
List Price:  €93.23
You save:  €27.97
£55.95
List Price:  £79.94
You save:  £23.98
CA$95.75
List Price:  CA$136.79
You save:  CA$41.04
A$107.23
List Price:  A$153.20
You save:  A$45.96
S$95.15
List Price:  S$135.94
You save:  S$40.78
HK$547.94
List Price:  HK$782.80
You save:  HK$234.86
CHF 63.91
List Price:  CHF 91.30
You save:  CHF 27.39
NOK kr766.40
List Price:  NOK kr1,094.90
You save:  NOK kr328.50
DKK kr486.75
List Price:  DKK kr695.39
You save:  DKK kr208.64
NZ$117.46
List Price:  NZ$167.81
You save:  NZ$50.35
د.إ257.06
List Price:  د.إ367.25
You save:  د.إ110.18
৳7,670.29
List Price:  ৳10,958.03
You save:  ৳3,287.74
₹5,832.01
List Price:  ₹8,331.80
You save:  ₹2,499.79
RM334.37
List Price:  RM477.70
You save:  RM143.32
₦88,678.72
List Price:  ₦126,689.32
You save:  ₦38,010.60
₨19,457.85
List Price:  ₨27,798.13
You save:  ₨8,340.27
฿2,591.43
List Price:  ฿3,702.20
You save:  ฿1,110.77
₺2,274.88
List Price:  ₺3,249.97
You save:  ₺975.09
B$360.25
List Price:  B$514.66
You save:  B$154.41
R1,330.75
List Price:  R1,901.16
You save:  R570.40
Лв127.68
List Price:  Лв182.41
You save:  Лв54.73
₩96,191.02
List Price:  ₩137,421.64
You save:  ₩41,230.61
₪265.67
List Price:  ₪379.55
You save:  ₪113.87
₱4,044.82
List Price:  ₱5,778.57
You save:  ₱1,733.74
¥10,886.62
List Price:  ¥15,552.99
You save:  ¥4,666.36
MX$1,193.70
List Price:  MX$1,705.36
You save:  MX$511.66
QR254.90
List Price:  QR364.16
You save:  QR109.26
P969.33
List Price:  P1,384.82
You save:  P415.49
KSh9,413.65
List Price:  KSh13,448.65
You save:  KSh4,035
E£3,352.26
List Price:  E£4,789.16
You save:  E£1,436.89
ብር3,973.96
List Price:  ብር5,677.33
You save:  ብር1,703.36
Kz58,616.62
List Price:  Kz83,741.62
You save:  Kz25,125
CLP$66,678.07
List Price:  CLP$95,258.47
You save:  CLP$28,580.40
CN¥507.14
List Price:  CN¥724.52
You save:  CN¥217.38
RD$4,110.44
List Price:  RD$5,872.31
You save:  RD$1,761.87
DA9,401.90
List Price:  DA13,431.87
You save:  DA4,029.96
FJ$160.42
List Price:  FJ$229.18
You save:  FJ$68.76
Q543.26
List Price:  Q776.12
You save:  Q232.86
GY$14,630.45
List Price:  GY$20,901.55
You save:  GY$6,271.09
ISK kr9,795.80
List Price:  ISK kr13,994.60
You save:  ISK kr4,198.80
DH709.23
List Price:  DH1,013.23
You save:  DH303.99
L1,246.59
List Price:  L1,780.93
You save:  L534.33
ден4,020.35
List Price:  ден5,743.61
You save:  ден1,723.25
MOP$563.94
List Price:  MOP$805.67
You save:  MOP$241.72
N$1,340.22
List Price:  N$1,914.68
You save:  N$574.46
C$2,572.43
List Price:  C$3,675.06
You save:  C$1,102.63
रु9,316.74
List Price:  रु13,310.19
You save:  रु3,993.45
S/259.29
List Price:  S/370.43
You save:  S/111.14
K265.67
List Price:  K379.55
You save:  K113.87
SAR262.50
List Price:  SAR375.02
You save:  SAR112.51
ZK1,825.88
List Price:  ZK2,608.51
You save:  ZK782.63
L324.76
List Price:  L463.96
You save:  L139.20
Kč1,644.30
List Price:  Kč2,349.11
You save:  Kč704.80
Ft25,615.12
List Price:  Ft36,594.60
You save:  Ft10,979.47
SEK kr760.35
List Price:  SEK kr1,086.27
You save:  SEK kr325.91
ARS$61,118.20
List Price:  ARS$87,315.45
You save:  ARS$26,197.25
Bs482.97
List Price:  Bs689.99
You save:  Bs207.01
COP$272,384.35
List Price:  COP$389,137.18
You save:  COP$116,752.82
₡35,055.79
List Price:  ₡50,081.85
You save:  ₡15,026.05
L1,725.31
List Price:  L2,464.83
You save:  L739.52
₲519,197.15
List Price:  ₲741,742.01
You save:  ₲222,544.85
$U2,684.12
List Price:  $U3,834.62
You save:  $U1,150.50
zł281.58
List Price:  zł402.27
You save:  zł120.69
Already have an account? Log In

Transcript

Hello, welcome to the ninth tutorial in the cocoa studio Flappy Bird c++ tutorial series. And in this part when we looked at the Flappy Bird class creation, we're going to be using the source code from the previous tutorial as we have been doing in that one and in the world before running or before, so if you don't have it, there'll be a link in the description. Now we are going to add the bird class, which will create and grow the Flappy Bird, or it's actually called fabbi and the bird name is happy. We can duplicate the pipe class and refactor it for ease of use. So if we just right click Show in Finder, and then duplicate these two and maybe just need to rename or rename them to bird. And now we just need to add them to our project.

Add them below point wherever you want to really add to my project or not And if we just go to a bird, ah, first of all, what we're going to do is we'll leave these and we'll get rid of this. Okay, let's work our way down. So bear that way more efficient, less likely to miss something. Changes to changes to bird as well. This looks a okay now go to a bird dot cpp include the bird. h file, we're going to need the definition file.

So let's assume that they're saying that to birching that we can delete this function entirely up to Linux, we don't have a spawn pipe, obviously. And yeah, then we've gotten that from the header. And now what we're gonna do is go back to a bird age. We're gonna add a sprite here, which will basically be our bird or circle, in my case, Coco's to the cotton combs. To write code on Flappy Bird semicolon, now we can go to our bird dot cpp. And now in our file here, we're going to do Flappy Bird equals droid colon colon create.

And in here, we're going to initialize it with this image right here where the border PNG or dot P and G and then the Flappy Bird. And we'll just set it to the center of the screen. So physical size dot width divided by two plus origin dot x. Now, both sides are divided by two plus origin dot y. And the next thing to do is do auto body when they create the physics body for our birds. Equals physics by the Create circle, we're going to use a circle because our believes in a ball so it is a circle.

If you have more rectangular locations, just decrease the box or if you have something a bit more custom, maybe like Flappy Bird, then you could maybe use a circle or just use something like physics editor and create your own custom fix body. So for this, we're just gonna specify the radius which is nappy bird. Okay, content size dot width divided by two. Now we're gonna do Flappy Bird set with the body and we'll set the body that is created right here. I will just copy and paste it will get selected. And now forgot to do one thing in the bird constructor, it's gone.

Intake layer we're going to be adding it from the construct and not from like a draw or spawn method that we had in the pipeline is going to have the one bird I can talk about just one bird Have you played that Flappy Bird clone to somebody else but online where there's you've got one bird, but you can see everybody else's birds as well. And stuff like that on board planning but you're not really affected by them or at least not directly, because they do get in your way sometimes just visually, so you do crash with them. That is an interesting concept that is layer and short old, Eric Thomas a layer over layer from Cisco, they just sell it that layer on top 100 so it's on top because we want this on top of everything just to make sure. Now let's create an object of the bird in the ganti head plus We will also need to include the bird header so we can be accessed.

Just go to games in the height cache, including the page. There here will be what's called a bird slot. Yeah. Forgot, you're going to get an error. And the reason is we need to create a pointer simply because it doesn't have a default constructor. And then we need to initialize specifically with the other constructor which will be passing in and layer.

And if we go to our game scene dot cpp Where did we initially is the other part we've got, we didn't need to initialize it. And now we can see here that we've got equal new bird. After the lie I was gonna pass this. So now if we run this world Have a circle. Okay, that's what's going to be our bird in the center of the screen with a physics buddy and you'll see what happens. Now let's let it run.

Here we go the splash screen. So click play. We got our bird before them and it bounces. Obviously students have enjoyed God. Collision Detection hasn't been activated. If you were to collide with the pipeline with top or bottom, it will go to the gaming scene, aka die.

But in the next part of this series, we're going to be looking at collision detection. So we can attack this the birds glider with either the top or the bottom pipe or the edges. If you have any questions feel free to message us or support our solar system colleague, Dakota UK the email will be in the description. Some comment on this video was directly messaged via YouTube, whether filing 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.