记忆游戏帮助!如何显示未配对的卡片

时间:2016-07-27 13:59:12

标签: vb.net visual-studio visual-studio-2010

在我的记忆游戏中显示配对卡工作正常。但问题是我无法显示未配对的卡片。我的游戏中有20张牌。

Dim paircount As Integer = 0
Dim unpaircount As Integer

Dim Card1 As Integer = 0
Dim Card2 As Integer = 0
Dim Card1pic As Integer = 0
Dim Card2pic As Integer = 0
Dim Score As Integer = 0
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

    st = st + 1
    Label3.Text = "Time : " & st & " seconds"
    Label7.Text = "Pairs : " & paircount
    If paircount = 19 And Card1 <> 0 And Card2 <> 0 Then
        paircount = paircount + 1
        victory()
        Label32.Text = "Unpaired : 20" & unpaircount    'This is my code for showing the unpaired card & and it's not working
        If unpaircount = 19 And Card1 = 0 And Card2 = 0 Then 
            unpaircount = unpaircount - paircount
        End If
    End If

End Sub

1 个答案:

答案 0 :(得分:0)

'[Begin]Declare Object/Value'
Dim paircount As Integer = 0
Dim unpaircount As Integer
Dim Card1 As Integer = 0
Dim Card2 As Integer = 0
Dim Card1pic As Integer = 0
Dim Card2pic As Integer = 0
Dim Score As Integer = 0
'[End]Declare Object/Value'

'[Begin]Tick handles'
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    st = st + 1
    Label3.Text = "Time : " & st & " seconds" ' Default As 1, in your code'
    Label7.Text = "Pairs : " & paircount ' Default As 0, in your code'
    If paircount = 19 And Card1 <> 0 And Card2 <> 0 Then ' Card1 & 2 default as 0, return False'
        paircount = paircount + 1 ' paircount is 20
        victory() ' your function or sub'

        Label32.Text = "Unpaired : 20" & unpaircount 'Default as null, return 0: Unpaired: 200'

        If unpaircount = 19 And Card1 = 0 And Card2 = 0 Then 'unpaircount = 0, will not be active this checking, please make sure your code will change the unpaircount value before this checking'
            unpaircount = unpaircount - paircount
        End If
    End If
End Sub
'[End]Tick handles'

正如您的代码所提供的那样,首先进行检查 '如果paircount = 19且Card1&lt;&gt; 0和Card2&lt;&gt; 0然后'
有没有办法改变paircound / card1 / card2?

如果没有,这意味着检查将不被接受,对于我的观点,
我认为您的代码成功显示结果:无变化,无显示

最诚挚的问候, KT