PDA

Click to See Complete Forum and Search --> : Me again with ? on My Simple Game


cfreiling
Dec 4th, 2000, 03:04 PM
Ok. I have everything set corrcetly on how I want it. High Score Works But!
When you Close the Game and Start it back up again theres no set High
Scores. How can i set the Score to a .scr file or any other way. This is want I
did for Saving the High Scores during Game Play:

------Module Code------
Public Type Game
IntName As String
IntCash As Integer
IntWins As Integer
IntLost As Integer
IntGames As Integer
End Type
------END MOD----------

Below is the Setting On the Main Form
I have other settings but Im going to Place just what I
have for Setting the High Scores

-----frmCraps-----------

Dim Scores(1 To 100) As Game 'Arrays 1 to 100 Players
Dim Players As Integer
Dim MaxCash As Integer
Players = 0

'The High Score gets set when Player's Cash Hits 0
'And gets sent to GameLoss
Private Sub GameLoss()
'Removes Cash from Bank
Cash = Cash - Bet
lblCash = Cash 'Sets Cash for Bet
txtBet.Locked = False 'Unlocks Place Bet

'Adds a Loss to Game Stats
NumLose = NumLose + 1
lblNumLose.Caption = NumLose

Call GamesPlayed(NumWin, NumLose)

'Random Phrases for Game Over
Dim Phrase2 As Integer
If Cash = 0 Then
Phrase2 = Int((5 - 1 + 1) * Rnd + 1)
cmdStart.Enabled = False 'Forces Player to Start New Game
Select Case (Phrase2)
Case 1:
lblStatus.Caption = "Your Broke, Go Home!"
Case 2:
lblStatus.Caption = "Game Over, Play Again!"
Case 3:
lblStatus.Caption = "Busted, Play Again?"
Case 4:
lblStatus.Caption = "Kinda Like Vegas, HUH!"
Case 5:
lblStatus.Caption = "Need A loan?"
End Select

Call HighScore

End If

End Sub


Private Sub HighScore()
frmScores.Visible = True
Players = Players + 1

Scores(Players).IntName = InputBox("Enter Your Name")
frmScores.listName.AddItem (Scores(Players).IntName)

frmScores.listPlayerCash.AddItem (MaxCash)
Scores(Players).IntCash = MaxCash
frmScores.listWins.AddItem (frmCraps.lblNumWin.Caption)
Scores(Players).IntWins = frmCraps.lblNumWin.Caption
frmScores.listLost.AddItem (frmCraps.lblNumLose.Caption)
Scores(Players).IntLost = frmCraps.lblNumLose.Caption
frmScores.listGames.AddItem (frmCraps.lblNumGame.Caption)
Scores(Players).IntGames = frmCraps.lblNumGame.Caption
End Sub

------------End Code------------

The High Score form when closed gets
frmScore.visible = false
So that no info is lost. I would like it set to something so when the user is
done playing and closes. then comes back to play again Users Old High
Score is still there along with Other info Set.

???
Thanks

dlm
Dec 8th, 2000, 08:20 AM
Hi,

here is an example for writing to a simple flat file...


Open "TESTFILE" For Output As #1 ' Open file for output.
Write #1, "Hello World", 234 ' Write comma-delimited data.
Write #1, ' Write blank line.

Dim MyBool, MyDate, MyNull, MyError
' Assign Boolean, Date, Null, and Error values.
MyBool = False : MyDate = #February 12, 1969# : MyNull = Null
MyError = CVErr(32767)
' Boolean data is written as #TRUE# or #FALSE#. Date literals are
' written in universal date format, for example, #1994-07-13#

'represents July 13, 1994. Null data is written as #NULL#.
' Error data is written as #ERROR errorcode#.
Write #1, MyBool ; " is a Boolean value"
Write #1, MyDate ; " is a date"
Write #1, MyNull ; " is a null value"
Write #1, MyError ; " is an error value"
Close #1 ' Close file.

dlm
Dec 8th, 2000, 08:22 AM
Hi again,


Here is some code to read from a flatfile...



Type Record ' Define user-defined type.
ID As Integer
Name As String * 20
End Type

Dim MyRecord As Record, Position ' Declare variables.
' Open sample file for random access.
Open "TESTFILE" For Random As #1 Len = Len(MyRecord)
' Read the sample file using the Get statement.
Position = 3 ' Define record number.
Get #1, Position, MyRecord ' Read third record.
Close #1 ' Close file.