1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
| Public Class Form1
Public lstDiament As New List(Of Diamant)
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Chargement.Parent = Plateau
PlacerDiamant(True)
End Sub
' ### Placement des diamants au hasard sur le plateau de jeu
Public Sub PlacerDiamant(ByVal load As Boolean)
Dim numero As Integer = 5
Dim rand As New Random
Dim i As Integer = 0
' Boucles verticale / horizontale de placement des diamants
For a As Integer = 0 To 5
For b As Integer = 0 To 10
If load = False Then numero = rand.Next(0, 4)
lstDiament.Add(New Diamant With {.ID = i, .Fen = Me, .numero = numero, .XY = New Point With {.X = b * 40 + 24, .Y = a * 40 + 24}})
lstDiament(lstDiament.Count - 1).ajoutDiamant()
i = i + 1
Next
Next
End Sub
' ### Supprime les diamants gris et ajout des diamants couleur
Private Sub NouveauToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NouveauToolStripMenuItem.Click
lstDiament.Clear()
PlacerDiamant(False)
End Sub
End Class
Public Class Diamant
Property numero As Integer
Property ID As Integer
Property XY As Point
Property imgDiamant As PictureBox
Property Fen As Form1
' ### Ajout du diamant en fonction de sa couleur et son emplacement
Public Sub ajoutDiamant()
If numero = 0 Then
imgDiamant = New PictureBox With {.Location = XY, .Image = Fen.DiaBleu.Image, .Parent = Fen.Plateau, .Width = 34, .Height = 35, .BackColor = Color.Transparent}
ElseIf numero = 1 Then
imgDiamant = New PictureBox With {.Location = XY, .Image = Fen.DiaVert.Image, .Parent = Fen.Plateau, .Width = 34, .Height = 35, .BackColor = Color.Transparent}
ElseIf numero = 2 Then
imgDiamant = New PictureBox With {.Location = XY, .Image = Fen.DiaRouge.Image, .Parent = Fen.Plateau, .Width = 34, .Height = 35, .BackColor = Color.Transparent}
ElseIf numero = 3 Then
imgDiamant = New PictureBox With {.Location = XY, .Image = Fen.DiaJaune.Image, .Parent = Fen.Plateau, .Width = 34, .Height = 35, .BackColor = Color.Transparent}
Else
imgDiamant = New PictureBox With {.Location = XY, .Image = Fen.DiaGris.Image, .Parent = Fen.Plateau, .Width = 34, .Height = 35, .BackColor = Color.Transparent}
End If
End Sub
End Class |
Partager