Inquiridor
Jogo da memória

Discussão Geral
-
Olá a todos, portanto, eu estou a tentar fazer o jogo da memoria, um trabalho da escola, mas já tentei tudo para que as imagens no jogo não apareçam mais que duas vezes, fiz o "pic.enabled = false" sei que não basta pois ele não vai saber que são só duas imagens para mostrar, por isso se alguém me quiser mostrar agradeço
Aqui vai o código:
Public Class Form1
Public Function getrandom(ByVal MaxMum As Integer) As Integer
Dim value As Integer = CInt(Int((MaxMum * Rnd()) + 1))
Return value
End Function
Dim randomNum As Integer
Private Sub pic_Click(sender As Object, e As EventArgs) Handles pic01.Click, pic02.Click, pic03.Click, pic04.Click, pic05.Click,
pic06.Click
randomNum = getrandom(3)
Select Case randomNum
Case 1
sender.Image = My.Resources._1
Case 2
sender.Image = My.Resources._2
Case 3
sender.Image = My.Resources._3
End Select
Njogadas += 1
sender.Enabled = False 'Não permite jogar mais que 1 vez
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Randomize()
restart()
btnrestart.Visible = True
Timer1.Interval = 1000
Timer1.Start()
End Sub
Private Sub btnrestart_Click(sender As Object, e As EventArgs) Handles btnrestart.Click
pic01.Image = Nothing
pic02.Image = Nothing
pic03.Image = Nothing
pic04.Image = Nothing
pic05.Image = Nothing
pic06.Image = Nothing
restart()
End Sub
Private Sub restart()
'lblvervencedor = ''
'For i = 0 To 8
' mjogo(i) = vbNullChar
'Next
'terminaJogo(True)
'Njogadas = 0
End Sub
Private Sub terminaJogo(ByVal bool As Boolean)
Dim pic As Control
For Each pic In Me.Controls
pic.Enabled = bool
Next
'pic01.Enabled = False
'pic02.Enabled = False
'pic03.Enabled = False
'pic04.Enabled = False
'pic05.Enabled = False
'pic06.Enabled = False
End Sub
End Class- Tipo Alterado Filipe B CastroModerator quarta-feira, 2 de janeiro de 2019 18:24
Todas as Respostas
-
Olá a todos, portanto, eu estou a tentar fazer o jogo da memoria, um trabalho da escola, mas já tentei tudo para que as imagens no jogo não apareçam mais que duas vezes, fiz o "pic.enabled = false" sei que não basta pois ele não vai saber que são só duas imagens para mostrar, por isso se alguém me quiser ajudar* agradeço
Aqui vai o código:
Public Class Form1
Public Function getrandom(ByVal MaxMum As Integer) As Integer
Dim value As Integer = CInt(Int((MaxMum * Rnd()) + 1))
Return value
End Function
Dim randomNum As Integer
Private Sub pic_Click(sender As Object, e As EventArgs) Handles pic01.Click, pic02.Click, pic03.Click, pic04.Click, pic05.Click,
pic06.Click
randomNum = getrandom(3)
Select Case randomNum
Case 1
sender.Image = My.Resources._1
Case 2
sender.Image = My.Resources._2
Case 3
sender.Image = My.Resources._3
End Select
Njogadas += 1
sender.Enabled = False 'Não permite jogar mais que 1 vez
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Randomize()
restart()
btnrestart.Visible = True
Timer1.Interval = 1000
Timer1.Start()
End Sub
Private Sub btnrestart_Click(sender As Object, e As EventArgs) Handles btnrestart.Click
pic01.Image = Nothing
pic02.Image = Nothing
pic03.Image = Nothing
pic04.Image = Nothing
pic05.Image = Nothing
pic06.Image = Nothing
restart()
End Sub
Private Sub restart()
'lblvervencedor = ''
'For i = 0 To 8
' mjogo(i) = vbNullChar
'Next
'terminaJogo(True)
'Njogadas = 0
End Sub
Private Sub terminaJogo(ByVal bool As Boolean)
Dim pic As Control
For Each pic In Me.Controls
pic.Enabled = bool
Next
'pic01.Enabled = False
'pic02.Enabled = False
'pic03.Enabled = False
'pic04.Enabled = False
'pic05.Enabled = False
'pic06.Enabled = False
End Sub
End Class
- Editado falexa00 segunda-feira, 10 de dezembro de 2018 12:02