Scoring Points

10 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.24
List Price:  €93.20
You save:  €27.96
£55.93
List Price:  £79.91
You save:  £23.97
CA$95.58
List Price:  CA$136.56
You save:  CA$40.97
A$107.13
List Price:  A$153.05
You save:  A$45.92
S$95.25
List Price:  S$136.08
You save:  S$40.82
HK$547.90
List Price:  HK$782.75
You save:  HK$234.85
CHF 63.85
List Price:  CHF 91.21
You save:  CHF 27.36
NOK kr770.13
List Price:  NOK kr1,100.23
You save:  NOK kr330.10
DKK kr486.51
List Price:  DKK kr695.05
You save:  DKK kr208.53
NZ$117.65
List Price:  NZ$168.07
You save:  NZ$50.42
د.إ257.06
List Price:  د.إ367.25
You save:  د.إ110.18
৳7,679.19
List Price:  ৳10,970.75
You save:  ৳3,291.55
₹5,834.32
List Price:  ₹8,335.10
You save:  ₹2,500.78
RM333.81
List Price:  RM476.90
You save:  RM143.08
₦91,422.33
List Price:  ₦130,608.93
You save:  ₦39,186.60
₨19,487.31
List Price:  ₨27,840.21
You save:  ₨8,352.89
฿2,585.90
List Price:  ฿3,694.31
You save:  ฿1,108.40
₺2,277.50
List Price:  ₺3,253.72
You save:  ₺976.21
B$361.10
List Price:  B$515.88
You save:  B$154.78
R1,320.17
List Price:  R1,886.05
You save:  R565.87
Лв127.48
List Price:  Лв182.13
You save:  Лв54.64
₩96,293.43
List Price:  ₩137,567.94
You save:  ₩41,274.51
₪266.53
List Price:  ₪380.78
You save:  ₪114.24
₱4,038.21
List Price:  ₱5,769.12
You save:  ₱1,730.90
¥10,975.59
List Price:  ¥15,680.08
You save:  ¥4,704.49
MX$1,206.90
List Price:  MX$1,724.22
You save:  MX$517.31
QR255.26
List Price:  QR364.68
You save:  QR109.41
P965.80
List Price:  P1,379.77
You save:  P413.97
KSh9,448.65
List Price:  KSh13,498.65
You save:  KSh4,050
E£3,352.63
List Price:  E£4,789.68
You save:  E£1,437.04
ብር3,985.10
List Price:  ብር5,693.24
You save:  ብር1,708.14
Kz58,489.70
List Price:  Kz83,560.30
You save:  Kz25,070.60
CLP$66,385.51
List Price:  CLP$94,840.51
You save:  CLP$28,455
CN¥507.19
List Price:  CN¥724.59
You save:  CN¥217.40
RD$4,111.01
List Price:  RD$5,873.12
You save:  RD$1,762.11
DA9,398.61
List Price:  DA13,427.17
You save:  DA4,028.55
FJ$158.17
List Price:  FJ$225.97
You save:  FJ$67.79
Q544.39
List Price:  Q777.73
You save:  Q233.34
GY$14,639.41
List Price:  GY$20,914.34
You save:  GY$6,274.92
ISK kr9,791.60
List Price:  ISK kr13,988.60
You save:  ISK kr4,197
DH708.11
List Price:  DH1,011.63
You save:  DH303.52
L1,243.72
List Price:  L1,776.81
You save:  L533.09
ден4,016.98
List Price:  ден5,738.79
You save:  ден1,721.81
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,575.16
List Price:  C$3,678.96
You save:  C$1,103.79
रु9,316.74
List Price:  रु13,310.19
You save:  रु3,993.45
S/261.07
List Price:  S/372.97
You save:  S/111.90
K269.52
List Price:  K385.04
You save:  K115.52
SAR262.50
List Price:  SAR375.02
You save:  SAR112.51
ZK1,842.03
List Price:  ZK2,631.59
You save:  ZK789.55
L324.63
List Price:  L463.78
You save:  L139.14
Kč1,640.70
List Price:  Kč2,343.96
You save:  Kč703.26
Ft25,605.88
List Price:  Ft36,581.40
You save:  Ft10,975.51
SEK kr762.91
List Price:  SEK kr1,089.92
You save:  SEK kr327.01
ARS$61,153.48
List Price:  ARS$87,365.86
You save:  ARS$26,212.38
Bs484.56
List Price:  Bs692.26
You save:  Bs207.70
COP$275,828.59
List Price:  COP$394,057.74
You save:  COP$118,229.14
₡35,172.98
List Price:  ₡50,249.28
You save:  ₡15,076.29
L1,727.65
List Price:  L2,468.18
You save:  L740.53
₲519,796.34
List Price:  ₲742,598.03
You save:  ₲222,801.68
$U2,684.12
List Price:  $U3,834.62
You save:  $U1,150.50
zł281.95
List Price:  zł402.81
You save:  zł120.85
Already have an account? Log In

Transcript

Hello and welcome to the 12th tutorial in the caucus to the x floppy versatile plus series. And in this part we're gonna be looking at scoring points. We'll be using the source code as usual from the previous part. So if you don't have it, don't worry, there'll be a link in the description to the source code, we essentially have a basic working game without any scoring system, our scoring system will just be like Flappy Bird in that when the bird or soliloquy in our game, passing in between the pipes, the player gets a point which is added on to their score. Firstly, we will create a hash define the definitions head out for the school collision bitmap. So if we go to our definitions here that you can copy and paste this will change obstacle to point.

It's made it unique by changing the two to three at the end. Now let's create an empty node and a body to attach to it. We'll be doing this in the pipe dot cpp because you'll be rendered with the pipe. So what we're going to do is Auto print node equals the reason we're just doing that empty no Norris broad anything because we're not going to see in this not just going to use it to detect if the player has a path for the pipes and then we're going to create a body so our physics bodies appoint body people physically physics body colon colon create and we're going to use the crate box function and for the size we're going to specify size and the width we're just going to have add one we want the minimum we're going to use broy colon colon create and what with what we're going to do here is we're going to get the point of the ball or the player whatever it is get content size, dot height, and what we're gonna do is time that ball in the pipe gap and if you remember, we had a pod gap in the definition header which at the moment said Which is basically the gap between the pipes is 10 times the height of the bird or the player or whatever you want to call it.

And let's set up the body so it isn't dynamic like the pipe, assign the collision bitmask and set the contact tested mask to true. So collision can be detected. So point body navman, two, point body. Collision bitmask. One thing I do want to mention, though, we're doing this in a very particular way, there's no right or wrong way as long as the result is what you intended to be. So experiment with the code 20. try and do things differently.

You may want to use gravity more or actually we're not using gravity at all the drawing system you might want to use then you may be able to make you better by ease and then more efficient. So experiment with it. Not logs no really wrong right wait there are better ways though. So just again just experiment. Okay the physical body in their setup and can be attached to the point node. And the point now will be positioned in between the pipe and added to the chart to the left.

So point note set physics body this will specify the point body that we're going to point to node vision online, new the one way you do point but that's just personal preference again, it's whatever you feel comfortable with. And for this for the position and do top pipe get position okay. And therefore why would the top pipe get dish y minus top pipe get content sois the hype deploy to so now this position the at the moment in the y axis just literally at the bottom of the top pipe aka the middle part of the point no but we want the top part of the point knows that what we need to do is minus and in here, we're going to be doing and quite complex please bear with me break con con create from the thing that we just did before so board clean G and then here get content sois dot white, torn boy pipe the app but we're just gonna do void this by two, because we only want half of a position there because if we have the entire thing position down, it won't be directly in between the points.

And now, what we're going to do is actually add the other child to the layer. So layer, add child, and we'll do point to no final thing to do. Final thing to add in the pipe class is the action to move the point note similar to the pipe action. So auto point no action equals move by the column column create. And this is academic exact same as this so we can we can literally just copy and paste it no point taking the risk of making a mistake. What we're going to do now is point to node run action Pointing no action.

And now if we run this you'll actually want to stop running. And I want to run it in an iPad run. One thing I found is they are the other night but even do this that on Xcode when you probably similar to fanatical recording in server 20. Often I'll be using the old iPhone simulator aka the 3.5 inch or non retina, I found that they can scale it. So this is I'm using iPad on scaling it down to 50%, which is great because on the old droid power or the like the lowest device simulator was really laggy whereas on this, it's not that laggy and comply a little better. So we've been up and down and there we go.

That is right there is the scoring section that we created and it's died. Okay, so the next thing to do is we're going to create a score integer variable in the game scene header and initialize it to zero so games seen what here, but then on sign in because we know it's not going to go below zero, but you may want some sort of different scoring system again, you'll have to customize it to your game and we're gonna it's gonna find it with a society here, though, score equals zero, not part of this tutorial is to add the collision check condition and increment the score. Plus for the purpose of this tutorial, we will just print out the score when the player hits an obstacle and dies, but we will eventually implement the score in the game overseen in the next few tutorials. So the uncontacted begin what he will do else if and what we can do.

To make it easier we can copy and paste This, the only one thing that we're going to change the literally the only thing we're going to change instead of obstacle, Queen. Point to Point and in here, first of all we're going to see see log and point scored. Then we need to increment score. So score plus class. And in here when we actually die alone and do it safely cc log. For this we're going to go through the total score that the player has obtained for the course of the game.

And we'll specify the score variable. So now if we run this the plan is we can go in between the pipes endpoints, and when we do an appoint score or A log appearing here as a school and when you die, your total score will be displayed in here. Click Play. Point scored. Yay. Okay, so I make this one as well and understand our purpose.

Now as you can see it scored four. And so yeah that is it really the reason they did to Khalid try to switch the scene twice it collided affably with the pipe and the grammar. That's not much of an issue. That's it for this tutorial. In the next part of this series, we're gonna be looking at implementing the game overseen. If you have any questions, feel free to message us or support us on our systems coda UK.

The email will be in the description. You can comment on this video or just directing messages via YouTube. The requirements 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.