Created
December 3, 2015 23:28
-
-
Save nhooyr/c637a4d6caae3e015651 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Public Class Concentration | |
Dim cards() As String = {"Ace_Dia", "_2_Dia", "_3_Dia", "_4_Dia", "_5_Dia", "_6_Dia", "_7_Dia", "_8_Dia", "_9_Dia", "_10_Dia", "J_Dia", "Q_Dia", "K_Dia", "Ace_Spades", "_2_Spades", "_3_Spades", "_4_Spades", "_5_Spades", "_6_Spades", "_7_Spades", "_8_Spades", "_9_Spades", "_10_Spades", "J_Spades", "Q_Spades", "K_Spades", "Ace_Clubs", "_2_Clubs", "_3_Clubs", "_4_Clubs", "_5_Clubs", "_6_Clubs", "_7_Clubs", "_8_Clubs", "_9_Clubs", "_10_Clubs", "J_Clubs", "Q_Clubs", "K_Clubs", "Ace_Hearts", "_2_Hearts", "_3_Hearts", "_4_Hearts", "_5_Hearts", "_6_Hearts", "_7_Hearts", "_8_Hearts", "_9_Hearts", "_10_Hearts", "J_Hearts", "Q_Hearts", "K_Hearts"} | |
Dim clickCounter As Integer | |
Dim usedCards As Dictionary(Of String, String) = New Dictionary(Of String, String) | |
Public Sub pClick(sender As PictureBox, e As EventArgs) Handles PictureBox1.Click, PictureBox2.Click, PictureBox3.Click, PictureBox4.Click, PictureBox5.Click, PictureBox6.Click, PictureBox7.Click, PictureBox8.Click, PictureBox9.Click, PictureBox10.Click, PictureBox11.Click, PictureBox12.Click, PictureBox13.Click, PictureBox14.Click, PictureBox15.Click, PictureBox16.Click | |
clickCounter += 1 | |
sender.Image = My.Resources.ResourceManager.GetObject(usedCards.Item(sender.Name)) | |
End Sub | |
Private Sub Concentration_Load(sender As Object, e As EventArgs) Handles MyBase.Load | |
Dim randomCards(15) As String | |
Randomize() | |
For i As Integer = 0 To 14 Step 2 | |
randomCards(i) = cards(Rnd() * cards.Length) | |
randomCards(i + 1) = randomCards(i) | |
Next | |
randomOrder(randomCards) | |
For i As Integer = 0 To 15 | |
usedCards.Add("PictureBox" & i + 1, randomCards(i)) | |
Next | |
End Sub | |
'sorting algorithm code do not touch plz | |
Private Sub randomOrder(ByRef al() As String) | |
For i As Integer = 0 To al.Length - 2 | |
Dim tmp = al(i) | |
Dim x As Integer = Rnd() * (al.Length - 1 - i) + i | |
al(i) = al(x) | |
al(x) = tmp | |
Next | |
End Sub | |
End Class |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment