Jump to content


Photo
* * * * * 2 votes

Custom High Score Tutorial


  • Please log in to reply
26 replies to this topic

#1 Noele

Noele

    GMC Mentor

  • GMC Member
  • 3413 posts
  • Version:GM:Studio

Posted 05 March 2012 - 10:44 PM

Overview
  • Title: Custom High Score Tutorial
  • Description: How to add a custom high score to your game
  • GM Version: GM Studio
  • Registered: No
  • File Type: ZIP
  • File Size: 1.9Mb
  • File Links:Highscore Tutorial GM Studio GMZ Version
  • Required Extension: None
  • Required DLL: None
Summary
Game Maker Studio  includes a built in high score system to record the top 10 places. Sometimes however it is desirable to store more than just a Name and a Score or customize the display to be more in keeping with your game.
 
This tutorial was created specifically for GM Studio to achieve just this and more.

HiscoreNew.png

The illustration above depicts a Custom High Score layout showing Name, Money and Score. It is easy to customize and add to your games and does not freeze the game action. It can also add a thousands separator to the scores (to make them easier to read) and allows you to set decimal places for the additional score date (useful for collecting money amounts). The best part is you don't need to be a "wiz" to learn how.

Description
This tutorial will teach you how to make and add a custom high score system to your game. It is aimed primarily at novice GM learners but experienced users may find it simpler than writing their own from scratch.

The High Score Example supplied with this tutorial shows how the Custom High Score System operates by simulating a game. It allows for a Name, Amount and a Score, the headings for each can be easily changed to suit your game. You can also specify the number of decimal places to display for the amount (useful for currency values) and whether to add commas as a thousands separator to the score.

The Example serves to illustrate how it works, allowing you to experiment with it before adding it to your game. The default image sets are unlikely to be in keeping with your game and alternative image sets are also supplied which you can edit or replace with your own.

The download also includes an example game together with a tutorial with step by step instructions to explain how to replace the example game's default high score system with the custom one. Knowledge of GML is an advantage but not a requirement; customizations can be done without coding knowledge.

The default GM high score system only saves a name and the score attained; this Custom display permits you to save an extra numeric field which can be used as a level counter, money earned, rank attained etc. It uses the default Game Maker high score system to store the top ten scores in the registry, so they are still maintained between game runs without the need to save any files.

This uses data structures and files to save data and is in-keeping with sandbox policies. (Compatible with GM S:Versions1.2 and 1.3)

No credit required. Free to use for personal or commercial games.

Feedback and comments always welcomed.

Edited by Noele, 14 October 2014 - 04:46 PM.

  • 7

#2 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • GMC Elder
  • 16301 posts
  • Version:GM:Studio

Posted 05 March 2012 - 11:57 PM

Please remove GM7 from the header, the 2 gmks in the zip are both GM8
  • 0

#3 NukeTheCat

NukeTheCat

    Isaiah 11:6

  • GMC Member
  • 556 posts
  • Version:GM:Studio

Posted 31 March 2012 - 10:11 AM

I got a problem. Your game works fine but when I try to follow the tutorial for my game I keep on getting error messages like:
Unknown Variable or Array out of bound- hiscore_name[i]
  • 0

#4 Noele

Noele

    GMC Mentor

  • GMC Member
  • 3413 posts
  • Version:GM:Studio

Posted 31 March 2012 - 08:23 PM

Did you forget to initialize all elements of the array? It is easily done.
All arrays start at zero.
If you get problems, PM me and I will help you out.
  • 0

#5 Whittenator

Whittenator

    GMC Member

  • New Member
  • 1 posts
  • Version:GM:Studio

Posted 30 November 2012 - 12:56 AM

If I was to send my game to friends. Would their high scores pop up on each others game for instance? Or would i need a server for this?
  • 0

#6 Noele

Noele

    GMC Mentor

  • GMC Member
  • 3413 posts
  • Version:GM:Studio

Posted 30 November 2012 - 05:44 PM

The high scores are for each game so are independent of each other. The custom part refers to the amount of data stored against each entry and the way it is displayed in the game. The GM default stores a name against each score. This allows you to record additional data and display it without halting the game.

You can implement an all time high score as well but you would need a server and a little PHP and MySQL knowledge. Those playing the game would need to permit the game Internet access in order to retrieve and / or record the scores.
  • 0

#7 Potices

Potices

    GMC Member

  • GMC Member
  • 11 posts
  • Version:GM8.1

Posted 14 December 2012 - 05:28 PM

Thanks for the tutorial! I tried it and it's just so good I think... Cause everytime i run it, it keeps showing me Error messages. Can someone help me?


___________________________________________
ERROR in
action number 1
of Create Event
for object obj_highscore_control:

Error in function real().

___________________________________________
ERROR in
action number 1
of Create Event
for object obj_highscore_control:

Error in function real().

___________________________________________
ERROR in
action number 1
of Create Event
for object obj_highscore_control:

Error in function real().

___________________________________________
ERROR in
action number 1
of Create Event
for object obj_highscore_control:

Error in function real().

___________________________________________
ERROR in
action number 1
of Create Event
for object obj_highscore_control:

Error in function real().

___________________________________________
ERROR in
action number 1
of Create Event
for object obj_highscore_control:

Error in function real().

___________________________________________
ERROR in
action number 1
of Draw Event
for object obj_highscore_control:

Error in code at line 10:
draw_sprite_ext(spr_hiscore,0,xx,yy,1,1,0,c_white,alpha);
^
at position 18: Unknown variable spr_hiscore

___________________________________________
ERROR in
action number 1
of Draw Event
for object obj_highscore_control:

Error in code at line 10:
draw_sprite_ext(spr_hiscore,0,xx,yy,1,1,0,c_white,alpha);
^
at position 18: Unknown variable spr_hiscore
  • 0

#8 Noele

Noele

    GMC Mentor

  • GMC Member
  • 3413 posts
  • Version:GM:Studio

Posted 14 December 2012 - 06:54 PM

Are you sure you initialized the high score system when the game starts?
hiscore_initialize();
This is one of two scripts. It creates the variables the high score system will use and also allows you to customize things like the type of extra data and headings that get displayed when showing the scores.
  • 0

#9 Potices

Potices

    GMC Member

  • GMC Member
  • 11 posts
  • Version:GM8.1

Posted 15 December 2012 - 01:55 PM

No I'm not... I will check the tut in a minute.

But can I make it like, when I die, it's just go to the Highscore room, and then it works like a highscore? I tried, but everytime I died, all the Error messages came up.
  • 0

#10 Noele

Noele

    GMC Mentor

  • GMC Member
  • 3413 posts
  • Version:GM:Studio

Posted 15 December 2012 - 02:16 PM

The example game which comes with the tutorial does exactly that.
  • 0

#11 Potices

Potices

    GMC Member

  • GMC Member
  • 11 posts
  • Version:GM8.1

Posted 21 December 2012 - 01:46 PM

Noele. What about if I want it to be three different rooms? One for the 'Easy level', one for medium and one for hard?
  • 0

#12 Noele

Noele

    GMC Mentor

  • GMC Member
  • 3413 posts
  • Version:GM:Studio

Posted 16 January 2013 - 08:21 AM

It will cope with three rooms but not 3 different sets of high scores. This still uses the default GM high scores from the registry so it can still only store 10 scores. To allow more than one high score you would need to create a high score store for each and use those instead of the GM high score functions.
  • 1

#13 xYorYx

xYorYx

    Vampire

  • GMC Member
  • 112 posts
  • Version:GM8

Posted 12 May 2013 - 12:33 PM

Thanks for the tutorial! I tried it and it's just so good I think... Cause everytime i run it, it keeps showing me Error messages. Can someone help me?


___________________________________________
ERROR in
action number 1
of Create Event
for object obj_highscore_control:

Error in function real().

___________________________________________

 

 

Are you sure you initialized the high score system when the game starts?

hiscore_initialize();
This is one of two scripts. It creates the variables the high score system will use and also allows you to customize things like the type of extra data and headings that get displayed when showing the scores.

 

 

I am getting same "Error in function real()" error, but I have initialized the high score system at the start of my game. When I do it like in the example (making the Start game event call the hiscore_initialize script) I get tons of errors that the variables are not defined and this is why I putted the code into my loader object, but then I get the Error in function real().


  • 0

#14 bluetrack

bluetrack

    GMC Member

  • New Member
  • 7 posts
  • Version:GM:Studio

Posted 28 September 2013 - 08:29 AM

Hi, thanks for the tutorial. I am running the "CustomHiScore.gmz" file. I read in the .pdf instructions: "As supplied the Custom High Score will run as-is so if you have not
done so already, import the GMZ into Studio and run it to see it in action". When i do run it without changing anything I get the following error:

 

 

 

___________________________________________
############################################################################################
FATAL ERROR in
action number 1
of Other Event: Game Start
for object obj_loader:

Push :: Execution Error - Variable Get -7.def_value(100019, -1)
 at gml_Script_scr_hiscore_config (line 22) -   if(is_string(def_value)){
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Script_scr_hiscore_config (line 0)
called from - gml_Script_scr_hiscore_initialize (line 6) - decimals = 0;                   // extra score decimal places
called from - gml_Object_obj_loader_Other_2 (line 5) - // Called to zero scores and set custom data
 

Any clues?

Thanks.


  • 0

#15 bluetrack

bluetrack

    GMC Member

  • New Member
  • 7 posts
  • Version:GM:Studio

Posted 30 January 2014 - 05:00 PM

OK, so i managed to get rid of the errors. Now the problem is when i enter a name on the high score and press enter the following happens in the compiler:

 

"Invalid Save location(currdir) - redirected to: 'C:\Users\my_username\AppData\Local\my_game_name\\Scores.dat'OS has raised a pause event"

 

And the score cannot be retrieved when i exit the game and play again. I read something about current_direrctory changed in recent version of GM and should not be used. Any ideas on how to fix this?

 

thx!


  • 0

#16 rashoo

rashoo

    GMC Member

  • GMC Member
  • 26 posts
  • Version:GM:Studio

Posted 25 February 2014 - 06:54 AM

TYVM for this tutorial. Very handy!


  • 0

#17 Rexusxx70

Rexusxx70

    GMC Member

  • GMC Member
  • 39 posts
  • Version:GM:Studio

Posted 21 May 2014 - 06:57 AM

How to add this script to ,my game....copy paste?


  • 0

#18 Rexusxx70

Rexusxx70

    GMC Member

  • GMC Member
  • 39 posts
  • Version:GM:Studio

Posted 31 May 2014 - 05:19 PM

my problem solved


  • 0

#19 decent.talluri

decent.talluri

    GMC Member

  • GMC Member
  • 46 posts
  • Version:GM:Studio

Posted 01 June 2014 - 11:28 AM

how to solve your problem, How to add this script please explain  or send me any example file 


Edited by decent.talluri, 01 June 2014 - 11:28 AM.

  • 0

#20 NUKEM DUKE

NUKEM DUKE

    GMC Member

  • GMC Member
  • 22 posts
  • Version:GM8

Posted 25 July 2014 - 03:40 AM

Is there a way to make more than 10 high score slots?  I've got a game I'm on which I want 13 high scores.

 

Thank you if so; I'll be a little bored if not.


  • 0

#21 Noele

Noele

    GMC Mentor

  • GMC Member
  • 3413 posts
  • Version:GM:Studio

Posted 28 July 2014 - 10:58 AM

The GM8.x version uses the built-in high score array (which uses the Windows registry) and is fixed to 10 top scores. These cannot be altered as it is fixed by GM. The Studio version however uses data structures, thus these can be any number you want. It is also possible to convert the Studio version to use with registered legacy GM versions (GM8 Pro or GM8.1 Standard).


  • 0

#22 Nodral

Nodral

    GMC Member

  • New Member
  • 1 posts
  • Version:Unknown

Posted 18 August 2014 - 09:09 AM

How is this a tutorial?

 

There is no explanation of what does what or why?  It's just an example of a working high score.

 

I am a complete beginner, and I really need talking through the process of creating this.


  • 0

#23 TakOn1

TakOn1

    GMC Member

  • New Member
  • 14 posts
  • Version:GM:Studio

Posted 21 August 2014 - 07:59 PM

how can I share this score for network(Internet)???


  • 0

#24 Rexusxx70

Rexusxx70

    GMC Member

  • GMC Member
  • 39 posts
  • Version:GM:Studio

Posted 22 August 2014 - 03:53 AM

register & download dropbbox and easy drag&drop ther, then on net You will have link to file


  • 0

#25 TakOn1

TakOn1

    GMC Member

  • New Member
  • 14 posts
  • Version:GM:Studio

Posted 26 August 2014 - 02:42 PM

Working in GM Studio?


  • 0

#26 Rexusxx70

Rexusxx70

    GMC Member

  • GMC Member
  • 39 posts
  • Version:GM:Studio

Posted 26 August 2014 - 04:37 PM

everything about making games You can find on Youtube


  • 0

#27 veta420

veta420

    GMC Member

  • GMC Member
  • 290 posts
  • Version:GM:Studio

Posted 10 September 2014 - 05:01 PM

download doesn't seem to be working :(


  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users