The whole code where start is the real game <TargetFramework>net6.0</TargetFramework>
Sub ClearKBBuffer()
While Console.KeyAvailable
Console.ReadKey(True)
End While
End Sub
Sub Main()
Dim k As ConsoleKey
Console.TreatControlCAsInput = True
Randomize()
Do
Console.CursorVisible = False
Dim nLijnen = Start()
ClearKBBuffer
Console.CursorVisible = True
Dim hs As HighScores = HighScores.Load()
Console.BackgroundColor = ConsoleColor.Red
Console.ForegroundColor = ConsoleColor.Black
Dim NewPLace As Integer = -1
For i As Integer = 0 To 9
If nLijnen > hs.Scores(i).Lines And NewPLace < 0 Then
NewPLace = i
End If
Console.SetCursorPosition(10, 10 + i)
Console.Write(hs.Scores(i).Name.PadRight(30) & hs.Scores(i).Lines.ToString.PadLeft(10) & " " & hs.Scores(i).PlayDate.ToString("dd/MM/yyyy HH:mm:ss"))
Next
Console.Beep()
If NewPLace >= 0 Then
Dim NewHS As New Score
With NewHS
.Lines = nLijnen
.PlayDate = Now
Console.SetCursorPosition(10, 21)
Console.Write("New highscore. " & nLijnen & " Your name please? ")
.Name = Console.ReadLine
.Name = .Name.Trim
If .Name = "" Then .Name = "\[No Name\]"
End With
For i = 8 To NewPLace Step -1
hs.Scores(i + 1) = hs.Scores(i)
Next
hs.Scores(NewPLace) = NewHS
hs.Save()
End If
Console.SetCursorPosition(0, Console.WindowHeight - 2)
Console.WriteLine("New game? (Y/N) ")
Do
k = Console.ReadKey.Key
Loop While k <> ConsoleKey.Y And k <> ConsoleKey.N
Loop While k = ConsoleKey.Y
End Sub