![]() |
|
Creating Pocket PC games that publish high scores in web
By Andrey Lebedev, January 13, 2003.
Introduction
BackgroundAlmost every game application has a high scores (or records) table. Each developer who writes a game has to implement a high scores table and he does this in his own way using his own data format. By the way, he must provide data integrity checking. The Pocket Highscores library does all these and many other tasks for you, simplifying the development process significantly. There is also a freeware program for desktop PC - Pocket Highscores that allows users to publish their high scores in web. You can distribute this program along with your Pocket PC games that use Pocket Highscores library. The high scores will be published to the PocketGamer.org website. Users will be able to compare their results and take part in monthly contests organized by PocketGamer.org. About Pocket Highscores systemPocket Highscores system consists of 3 parts:
What You Need
About Pocket Highscores libraryThe library loads/saves/enumerates/modifies high scores located in a HighScores.sco file in your folder. It supports crypto signature to prevent cheating. The library is implemented as a single h-file with three classes in it (CHighScores, CByteStorage, CCryptoHashMD5). CByteStorage class is a simple memory stream, CCryptoHashMD5 is a wrapper around md5 algorithm. The Highscores library doesn't use MFC and therefore it can be used in both MFC and non-MFC projects. CHighScores class is a container for a limited number of high scores records with an ability to load the list from a file or a memory stream, to save the list into a file or a memory stream, to add, sort and enumerate the high scores records. Each high score record keeps the following information:
The Additional information can contain any auxiliary string data. Here is the CHighScores interface: Using the Highscores libraryInitializationDefine a variable of CHighScores class: it's a good idea for this variable to exist during the whole application lifetime. For example, in MFC application the best place for the high scores variable will be a field of the application object. Pass the following data into the constructor: the maximum number of high scores records to be kept in the list and the "magic" string to be used in the encryption for security purposes.
To specify the game application and its version use the
following methods: Loading from fileTo load the high scores list from a file call the Load method passing there the directory path where the high scores file (HighScores.sco) is placed:
If load operation succeeds, the Load method returns HS_OK value. If an error
occurs then it returns one of HS_XXXX or HSL_XXXX constant values. If the
signature check succeeds then the The high scores list is automatically sorted after each loading. Saving to fileTo save the high scores list into a file call the Save method passing there the directory path where the high scores file (HighScores.sco) should be placed:
The second (boolean) optional parameter of the Save method only makes sense
in a case of the signature check failure during the previous load operation
(call the If save operation succeeds, the Save method returns HS_OK value. If an error occurs then it returns one of HS_XXXX or HSS_XXXX constant values. Enumerating the high scores
To list the scores (in the dialog box or wherever you want) call the
Adding a new score
To add a high score record into the list use the
Important: the score value should be nonnegative, the player name should not
contain "|" characters. The list is not automatically sorted after each score
insertion, therefore you should sort it by calling the Misc
You can save and load the high scores list from the memory stream (CByteStorage class):
the appropriate methods are Step by step
ConclusionYou can save your development time and make your Pocket PC games more attractive to users by using Pocket Highscores library. Related resources:
DiscussDiscuss this article. Here you can write your comments and read comments of other developers. |
|||||||||||||||||||||