Highscore

5 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$49.99
List Price:  $69.99
You save:  $20
€46.58
List Price:  €65.22
You save:  €18.63
£40.03
List Price:  £56.04
You save:  £16.01
CA$68.63
List Price:  CA$96.09
You save:  CA$27.45
A$76.02
List Price:  A$106.44
You save:  A$30.41
S$67.81
List Price:  S$94.93
You save:  S$27.12
HK$390.69
List Price:  HK$547
You save:  HK$156.30
CHF 45.46
List Price:  CHF 63.65
You save:  CHF 18.19
NOK kr546.43
List Price:  NOK kr765.05
You save:  NOK kr218.61
DKK kr347.46
List Price:  DKK kr486.48
You save:  DKK kr139.01
NZ$83.33
List Price:  NZ$116.68
You save:  NZ$33.34
د.إ183.60
List Price:  د.إ257.06
You save:  د.إ73.45
৳5,489.47
List Price:  ৳7,685.71
You save:  ৳2,196.23
₹4,174.55
List Price:  ₹5,844.71
You save:  ₹1,670.15
RM236.99
List Price:  RM331.80
You save:  RM94.81
₦70,298.43
List Price:  ₦98,423.43
You save:  ₦28,125
₨13,909.88
List Price:  ₨19,474.95
You save:  ₨5,565.06
฿1,846.13
List Price:  ฿2,584.73
You save:  ฿738.60
₺1,610.66
List Price:  ₺2,255.06
You save:  ₺644.39
B$254.49
List Price:  B$356.31
You save:  B$101.82
R927.79
List Price:  R1,298.99
You save:  R371.19
Лв91.12
List Price:  Лв127.57
You save:  Лв36.45
₩68,531.94
List Price:  ₩95,950.21
You save:  ₩27,418.26
₪186.70
List Price:  ₪261.40
You save:  ₪74.69
₱2,868.05
List Price:  ₱4,015.50
You save:  ₱1,147.44
¥7,794.14
List Price:  ¥10,912.42
You save:  ¥3,118.28
MX$847.82
List Price:  MX$1,187.01
You save:  MX$339.19
QR181.98
List Price:  QR254.79
You save:  QR72.81
P683.14
List Price:  P956.45
You save:  P273.31
KSh6,548.69
List Price:  KSh9,168.69
You save:  KSh2,620
E£2,366.87
List Price:  E£3,313.80
You save:  E£946.93
ብር2,871.93
List Price:  ብር4,020.93
You save:  ብር1,149
Kz41,809.30
List Price:  Kz58,536.36
You save:  Kz16,727.06
CLP$46,797.13
List Price:  CLP$65,519.73
You save:  CLP$18,722.60
CN¥361.26
List Price:  CN¥505.79
You save:  CN¥144.53
RD$2,902.73
List Price:  RD$4,064.05
You save:  RD$1,161.32
DA6,738.30
List Price:  DA9,434.16
You save:  DA2,695.86
FJ$113.87
List Price:  FJ$159.43
You save:  FJ$45.56
Q388.63
List Price:  Q544.12
You save:  Q155.48
GY$10,470.35
List Price:  GY$14,659.33
You save:  GY$4,188.98
ISK kr7,002.59
List Price:  ISK kr9,804.19
You save:  ISK kr2,801.60
DH501.40
List Price:  DH702
You save:  DH200.60
L883.29
List Price:  L1,236.68
You save:  L353.38
ден2,870.60
List Price:  ден4,019.08
You save:  ден1,148.47
MOP$402.76
List Price:  MOP$563.89
You save:  MOP$161.13
N$930.61
List Price:  N$1,302.92
You save:  N$372.31
C$1,841.31
List Price:  C$2,577.98
You save:  C$736.67
रु6,683.63
List Price:  रु9,357.62
You save:  रु2,673.98
S/186.29
List Price:  S/260.83
You save:  S/74.53
K193.80
List Price:  K271.34
You save:  K77.53
SAR187.48
List Price:  SAR262.49
You save:  SAR75
ZK1,366.70
List Price:  ZK1,913.50
You save:  ZK546.79
L231.77
List Price:  L324.50
You save:  L92.73
Kč1,164.46
List Price:  Kč1,630.34
You save:  Kč465.87
Ft18,093.17
List Price:  Ft25,331.89
You save:  Ft7,238.71
SEK kr546.34
List Price:  SEK kr764.93
You save:  SEK kr218.58
ARS$44,079.30
List Price:  ARS$61,714.55
You save:  ARS$17,635.24
Bs345.59
List Price:  Bs483.86
You save:  Bs138.26
COP$194,670.18
List Price:  COP$272,553.83
You save:  COP$77,883.65
₡25,602.51
List Price:  ₡35,845.57
You save:  ₡10,243.05
L1,236.05
List Price:  L1,730.57
You save:  L494.52
₲373,702.36
List Price:  ₲523,213.21
You save:  ₲149,510.84
$U1,931.55
List Price:  $U2,704.33
You save:  $U772.77
zł200.15
List Price:  zł280.23
You save:  zł80.07
Already have an account? Log In

Transcript

Havior In this lecture, we will implement a high score system in our game. First of all, I'll go to objects and open or manager. I'll open a creative and here I need to add a variable. So I'll create a variable called high score. So as you can tell, this will show the high score of the player, the high score will be loaded into this variable when the game ends. And now I'll add another variable, its name will be new high score, and its value will be false.

This variable will store whether the player has made a new high score. So for that, we can use what is called a boolean variable. A Boolean variable can be either true, which is one or false, which is zero. So right now it's at false, but if the player makes a new high school, we'll change it to true. So later, we can use an if condition to check if this variable is true. Now we'll open alarm to Which is where the game ends.

So here's what we will do in this event, we load the i&i file, we read the high score and compare it with the new score, we write the high score back into the i&i file, and then we'll close the file. So also file here, I'll add the opener and I file action. I'll change its name to save data and I now we need to load the highest score. So I'll add the reader and I file action here. I'll change the type to number, the section for the high score will be game and the key will of course be high score. If a high score is not found, the default value will be zero, and the target will be the high score variable.

Now we need to compare the high score with the score to check if the player has made a new high score. So for that, I'll search if score and add that action. This action basically checks the score against a condition. So we want to check whether the score is greater Then the highest score. So if it is greater, it means that the player has beaten their previous high score. So in that case, we're going to make the highest score equal to the new score.

For that I need the GED score action, I'll attach it to the condition. This action applies the score value to another variable. So for that target, I'll enter high score. So with this action, the high score will become equal to the score. Now I'll add the variable action. I'll set the new high score variable to true.

Now the high score needs to be saved back into the i&i file in case the player has made a new high score, soul search file and add the right to an action I added after this condition. I'll change the type to number the section is game and the key is high score and the value we are saving is the high score. Finally I close the i&i file. Now I'll open Oh game I'll open the drawers UI events. I'll go to the bar where the score is drawn here I'll draw the high score as well. So I'll add another draw value action after this one.

In the caption, I'll enter high score in the value Atlanta, the high score variable, but this variable belongs to all manager. So I'll click on the arrow here and apply this action to that object. Now the X for this will be the room where it divided by two and the y will be the room height multiplied by 0.4. Now we need to let the player know if they made a new high score. So for that, I'll add this expression action. Using this action you can check if a variable is true, so I'll add it here.

First, I'll apply this action to or manager. Now I'll check if the variable new high score is true. You know that this is true when the player has made a new high score. You can also see the country addition in the overview, so if it is true, we'll draw some text, I'll add the action to the condition. The caption will simply be a new high score. The X will again be the room weight divided by two and the y will be the room height multiplied by 0.1.

Now we'll make a small change. I'll go to the part where the ENTER and escape messages are drawn. I'll delete the escape one. I'll enter the info for both keys in this one message to make it look cleaner. I'll also change the y position from 0.6 to 0.9. Now I'll run the game.

I'll quickly make some score and I and you can see that I made a new high score. I can also see my high score here. Now I'll play again and make a higher score. And you can see that I beat my previous high score. Now I quit. The game and run it again.

I lose again. And you can see that my previous high score was loaded from the file. So that's it for the high score. In the next lecture we'll add music and sound effects in our game.

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.