3 Replies - 6112 Views - Last Post: 11 October 2010 - 12:10 PM Rate Topic: -----

#1 John-Ellis  Icon User is offline

  • D.I.C Regular

Reputation: 8
  • View blog
  • Posts: 305
  • Joined: 23-March 10

High Score Table

Posted 28 September 2010 - 04:40 AM

Hi All,

I want to write a high score table for a card game (Yahtzee) that I am creating.

The most popular idea seems to be writing data to the registry. I have a question about this, once the data has been written to the registry is it deleted once the game has been closed, or uninstalled, or does it stay there forever.

Also

When the application is first loads, I want a screen to come up asking for the players names so that they can be saved to the high score list (there is a maximum of three players for the game). Do I need to add a Windows Form to my application then use a form load event or something like that.

These are subjects I have never covered, if writing to the registry is the best way to go for making my high score table then I can start writing up some code for that, but how do I even beggin with the game asking for players names and saving them to the high score table.

I will start writing up some code for my high score table but any help or advise would really be appreciated.

Thank you very much

John

Is This A Good Question/Topic? 0
  • +

Replies To: High Score Table

#2 motcom  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 290
  • View blog
  • Posts: 1,371
  • Joined: 16-June 08

Re: High Score Table

Posted 28 September 2010 - 05:26 AM

Hi,

Why not write the info to an XML file? You can use datasets to read and write to XML. Symply Create a Table in the DataSet Designer then drag the Table to the required form and voila, you have access to the Table in the Dataset. From there you can read and write the info. Even create related records.

If it's just a single user environment, you can use My.Settings / Settings under MyProject, add the required fields and access them in code. This will uninstall automatically when you remove your application.

The XML file you would need to write a custom action (and use Setup and Deployment) to remove it.

This can also be done with the registry, however you would still have to use Setup and Deployment as Click Once is not so friendly in that respect...

Reading and writing to registry is always a bit cumbersome (at least for me) datasets and or XML and my.settings is so much easier....
Was This Post Helpful? 2
  • +
  • -

#3 John-Ellis  Icon User is offline

  • D.I.C Regular

Reputation: 8
  • View blog
  • Posts: 305
  • Joined: 23-March 10

Re: High Score Table

Posted 28 September 2010 - 10:54 AM

View Postmotcom, on 28 September 2010 - 04:26 AM, said:

Hi,

Why not write the info to an XML file? You can use datasets to read and write to XML. Symply Create a Table in the DataSet Designer then drag the Table to the required form and voila, you have access to the Table in the Dataset. From there you can read and write the info. Even create related records.

If it's just a single user environment, you can use My.Settings / Settings under MyProject, add the required fields and access them in code. This will uninstall automatically when you remove your application.

The XML file you would need to write a custom action (and use Setup and Deployment) to remove it.

This can also be done with the registry, however you would still have to use Setup and Deployment as Click Once is not so friendly in that respect...

Reading and writing to registry is always a bit cumbersome (at least for me) datasets and or XML and my.settings is so much easier....


Thanks I will have a go.

Cheers

John
Was This Post Helpful? 0
  • +
  • -

#4 John-Ellis  Icon User is offline

  • D.I.C Regular

Reputation: 8
  • View blog
  • Posts: 305
  • Joined: 23-March 10

Re: High Score Table

Posted 11 October 2010 - 12:10 PM

View PostJohn-Ellis, on 28 September 2010 - 09:54 AM, said:

View Postmotcom, on 28 September 2010 - 04:26 AM, said:

Hi,

Why not write the info to an XML file? You can use datasets to read and write to XML. Symply Create a Table in the DataSet Designer then drag the Table to the required form and voila, you have access to the Table in the Dataset. From there you can read and write the info. Even create related records.

If it's just a single user environment, you can use My.Settings / Settings under MyProject, add the required fields and access them in code. This will uninstall automatically when you remove your application.

The XML file you would need to write a custom action (and use Setup and Deployment) to remove it.

This can also be done with the registry, however you would still have to use Setup and Deployment as Click Once is not so friendly in that respect...

Reading and writing to registry is always a bit cumbersome (at least for me) datasets and or XML and my.settings is so much easier....


Thanks I will have a go.

Cheers

John

Hi All,

Ok I have been banging my head against the wall trying to sort out this high score table, as you can imagine I have a big head ache lol.

Ok so what I have done is create a text file with the main title High Scores and two headers Player Name and Score.

How do I write to a text file.

so far for the end of game sequence I have this

 Private Sub EndGame()
        GameOver = True
        Me.btnRollTheDice.Text = "Game Over"
        Me.btnRollTheDice.Enabled = False
        MsgBox("Game over" & vbNewLine & "Your score was " & GrandTotal & "." & vbNewLine & "If you'd like to play again, Go To File>New Game", , "Game Over!")
    End Sub



How can I add to this block of code, to write whatever score is in the GrandTotal to the text file I have created.

Also

In the beggining of the game, a message box comes up aking for the players name, please see below

 Private Sub PlayersName()
        PlayerName = InputBox("Please Enter Your Name", "New Yahtzee Player", PlayerName)
        Exit Sub
    End Sub



I also need to write to the text file whatever name the player puts in and all this text needs to go in the appropriate place.

Can anyone help.

Thanks very much

John

Update

I imported the System.IO

Then I wrote this sub

  'This sub writes text to the high score table text file
    Private Sub HighScoreTable()
        Try
            Dim FileWriter As StreamWriter = New StreamWriter _
            ("HighScores.txt" & PlayerName & GrandTotal)
            FileWriter.Close()
        Catch ex As Exception
            MsgBox("Cannot Save")
        End Try
    End Sub



I then called the sub in the endgame sub, I will post weather its worked or not.

Ta

This post has been edited by John-Ellis: 11 October 2010 - 01:24 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1