Introduction.
This is an old game, first implemented in 1996 or so... It has a great addictive power. You will quickly find out the rules. I used the winmm.dll library for playing sounds, the picturebox.Paint event to draw bitmaps in a Picturebox and a recursive function to check the balls next to each other for the colors. And some more stuff...
Private Sub pictureBox1_Paint(ByVal sender As Object, ByVal e As PaintEventArgs) Handles pictureBox1.Paint
Dim g As Graphics = e.Graphics
Dim i As Integer
For i = 0 To 7
Dim j As Integer
For j = 0 To 11
If engine._ball(i, j)._exists Then
'g.FillEllipse(_color[engine._ball[i, j]._icolor], i * 24, j * 24, 24, 24);
g.DrawImage(_bmp(engine._ball(i, j)._icolor), i * 24 - _posx * engine._ball(i, j)._yvel, j * 24 + _posy * engine._ball(i, j)._vel, 24, 24)
End If
If engine._ball(i, j)._isDisappearing Then
g.DrawImage(_bmp(engine._ball(i, j)._icolor), i * 24 + _var, j * 24 + _var, 24 - _var * 2, 24 - _var * 2)
End If
Next j
Next i
If _gameover AndAlso Not _gamewon Then
g.DrawString("GAME OVER", New Font("Arial", 20), System.Drawing.Brushes.Black, 10, 122)
g.DrawString("GAME OVER", New Font("Arial", 20), System.Drawing.Brushes.White, 8, 120)
End If
If _gamewon Then
g.DrawString("GAME WON", New Font("Arial", 20, System.Drawing.FontStyle.Bold), System.Drawing.Brushes.Black, 10, 122)
g.DrawString("GAME WON", New Font("Arial", 20, System.Drawing.FontStyle.Bold), System.Drawing.Brushes.LightBlue, 8, 120)
End If
End Sub 'pictureBox1_Paint
NOTE: THIS ARTICLE IS CONVERTED FROM C# TO VB.NET USING A CONVERSION TOOL. ORIGINAL ARTICLE CAN BE FOUND ON C# CORNER (WWW.C-SHARPCORNER.COM).