Simple High Score System for Tetris Game
Hey guys,
I just finished making a Tetris game in VB.NET, and I wanted to add a high score system to the application. So, when a user completes their game, they have the option of submitting it as a high score, which will compare their score against the previous high scores, then place it accordingly. I was thinking of an XML approach of doing this, where the user's name, rank, score, level, and number of lines cleared will be stored in tags. Here is what I thought the XML might resemble:
Code:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Root>
<HighScore>
<Rank>1</Rank>
<User>"Blank"</User>
<Score>0</Score>
<Level>0</Level>
<Lines>0</Lines>
</HighScore>
</Root>
So the program will have an array to store all the previous scores. It will read through the XML, and copy the the score data into this array. Then, when the time comes to submit a score, it will compare this score against those previous scores, and find the proper position for that score, and then save it into the array. At the end, it will then copy all the score data from this array to the XML, replacing the <Level>, <Lines>, and <User> tags in the process.
I am however having trouble implementing this, as I have no experience with XML files and everything I've read has been very confusing. Any help you guys could offer would be sweet!
Thanks!
-Paul
Re: Simple High Score System for Tetris Game
You could use XmlSerialization or even Binary Serialization if you want. Heck, even a simple text file that follows a pattern would work for something like this.
Re: Simple High Score System for Tetris Game
Okay, but how do you think I might be able to go about doing this? Can you give me an example of some code that I could use to read from the XML, and write to it? Or what do you think would be the easiest way of going about this?