Оценить:
 Рейтинг: 0

Справочник Жаркова по проектированию и программированию искусственного интеллекта. Том 6: Программирование на Visual Basic искусственного интеллекта. Продолжение 2

Год написания книги
2023
Теги
<< 1 2 3 4 5 6 7 ... 57 >>
На страницу:
3 из 57
Настройки чтения
Размер шрифта
Высота строк
Поля

If isSoundOn Then

'Исправляем ошибку в оригинале:

My.Computer.Audio.Play( _

"..\..\Resources\Windows XP Balloon.wav", _

AudioPlayMode.WaitToComplete) 'Ждем окончания мелодии.

End If

' Update the matrix and compute the new score.

Dim count As Integer = matrix.Click(New Point(e.X, e.Y))

score += 10 * count

' Draw the new grid.

matrix.Draw(Me.PictureBox1.CreateGraphics(), _

Me.PictureBox1.BackColor)

' Write the score on the screen.

Dim images() As PictureBox = { _

Me.tenthousands, Me.thousands, _

Me.hundreds, Me.tens, Me.ones}

Dim scoreString As String = score.ToString().PadLeft(5)

Dim digits() As String = { _

scoreString.Chars(0), _

scoreString.Chars(1), _

scoreString.Chars(2), _

scoreString.Chars(3), _

scoreString.Chars(4)}

For index As Integer = 0 To 4

If digits(index) <> " " Then

images(index).Image = _

numbers.Images(CInt(digits(index)))

Else

images(index).Image = Nothing

End If

Next

End Sub

Private Sub StartNewGame()

' If a game is already running, check for a new high score.

If Not matrix Is Nothing Then

Me.Timer1.Enabled = False

HighScores.UpdateScores(score)

End If

Timer1.Enabled = False

matrix = New Grid(6)

score = 0

matrix.Draw(Me.PictureBox1.CreateGraphics(), _

Me.PictureBox1.BackColor)

Timer1.Enabled = True

AddHandler PictureBox1.MouseDown, AddressOf BlockClick

'Обнуляем счётчик секунд:

secondCounter = 0

End Sub

' To pause the game, turn off the timer.

Private Sub Pause()
<< 1 2 3 4 5 6 7 ... 57 >>
На страницу:
3 из 57

Другие электронные книги автора Валерий Алексеевич Жарков