[VB6] Jogo - Problema

Pss

Power Member
Boas,

Tou a fazer um jogo que consiste em martelar as imagens que aparecem.
Existe uma imagem sempre visivel e outra que so é visivel quando for escolhida aleatoriamente que quando se carrega em cima dela antes de desaparecer ganhamos um ponto.
O problema e que essa imagem nao aparece... Aqui em baixo deixo o codigo que eu meti. Quem conseguir resolver o problema diga por favor

Código:
Dim myvalue As Integer
Dim placar As Integer
Dim tempodojogo As Integer
 
Private Sub picture2_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
placar = placar + 1
Text1.Text = placar
End Sub
 
Private Sub Form_Load()
Randomize
placar = 0
tempodojogo = 0
End Sub
 
Private Sub Text1_Change()
placar = placar
End Sub
 
Private Sub Timer1_Timer()
For i = 0 To 9
Picture2(i).Enabled = False
Next i
myvalue = Int(10 * Rnd)
Picture2(myvalue).Enabled = True
tempodojogo = tempodojogo + 1
If tempodojogo > 30 Then
MsgBox ("total = " + Str$(placar) + " acertos")
End
End If
End Sub
 

Private Sub Timer1_Timer()
For i = 0 To 9
Picture2(i).Visible = False \\todas as imagensb ficam invisiveis
Next i
myvalue = Int(10 * Rnd)
Picture2(myvalue).Visible = True \\a imagem que foi "sorteada" aparece
tempodojogo = tempodojogo + 1
If tempodojogo > 30 Then
MsgBox ("total = " + Str$(placar) + " acertos")
End
End If
End Sub



Private Sub picture2_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
placar = placar + 1
Text1.Text = placar
picture2(Index).visible=False \\a imagem em que clicas-te fica invisivel
End Sub
 
Private Sub Timer1_Timer()
For i = 0 To 9
Picture2(i).Visible = False \\todas as imagensb ficam invisiveis
Next i
myvalue = Int(10 * Rnd)
Picture2(myvalue).Visible = True \\a imagem que foi "sorteada" aparece
tempodojogo = tempodojogo + 1
If tempodojogo > 30 Then
MsgBox ("total = " + Str$(placar) + " acertos")
End
End If
End Sub



Private Sub picture2_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
placar = placar + 1
Text1.Text = placar
picture2(Index).visible=False \\a imagem em que clicas-te fica invisivel
End Sub

Obrigado... Só mais uma pergunta... Como faço agora para quando me apareçe a imagem e eu carrego nela apareçe outra imagem durante por exemplo meio segundo e depois desaparece outra vez?

Exemplo: apareçe a toupeira eu carrego nela e depois aparece a mesma com ferimentos, durante meio segundo e desapareçe outra vez.
 
Essa imagem é a "picture3"
Dim x as Integer




Private Sub Timer2_Timer()
picture3(x).visibled=False
timer2.enabled=False
End Sub


Private Sub picture2_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
placar = placar + 1
Text1.Text = placar
picture2(Index).visible=False \\a imagem em que clicas-te fica invisivel
picture3(Index).visible=True
x=Index
timer2.enabled=true
End Sub
 
Dim x as Integer




Private Sub Timer2_Timer()
picture3(x).visibled=False
timer2.enabled=False
End Sub


Private Sub picture2_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
placar = placar + 1
Text1.Text = placar
picture2(Index).visible=False \\a imagem em que clicas-te fica invisivel
picture3(Index).visible=True
x=Index
timer2.enabled=true
End Sub

Já tinha exprimentado isso mas tem 2 problemas:

1º a imagem escondida aparece depois eu clico nela e a imagem dos ferimentos aparece noutro lado. Por exemplo: sao 10 caixas é "sorteada" uma caixa para a toupeira aparecer ,por exemplo a caixa nº 5, e depois quando ela aparece e eu clico nessa caixa a imagem dela com os ferimentos aparece por exemplo na caixa nº 7.

2º a imagem dos ferimentos aparece mas não desaparece
 
Eu só vou poder voltar a ajudar amanhã. A minha placa de rede pifou e é complicado postar com o n80. Espero que resolvas antes o problema. Senão amanhã estou de volta com uma solução,
 
Para apagar os ferimentos podes criar um array boolean de 10 posições, e cada vez que acertas, a posição fica "true" e ligas o timer2 para apagar.

Código:
Private Sub Timer2_Timer()
For i = 0 To 9
if array[i] then picture3(x).visibled=False
Next i
timer2.enabled=False
End Sub

e por true no array

Código:
Private Sub picture2_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
placar = placar + 1
Text1.Text = placar
picture2(Index).visible=False \\a imagem em que clicas-te fica invisivel
picture3(Index).visible=True
x=Index
array(Index) = True
timer2.enabled=true
End Sub
Isto foi pensado assim por alto, já não pego em VB há bastante tempo.
 
Última edição:
Já consegui resolver o problema do sítio onde elas aparecem só falta descobrir como faço para desaparecerem...

Código:
Private Sub Timer2_Timer()
Picture3(x).Visible = False
Timer2.Enabled = False
End Sub
 
Private Sub Picture2_MouseDown(Index As Integer, Button As Integer, Shift As Integer, x As Single, Y As Single)
placar = placar + 1
Text1.Text = placar
Picture2(Index).Visible = False ' a imagem em que clicas-te fica invisivel
If (myvalue) = 0 Then
Picture3(0).Visible = True
End If
If (myvalue) = 1 Then
Picture3(1).Visible = True
End If
If (myvalue) = 2 Then
Picture3(2).Visible = True
End If
If (myvalue) = 3 Then
Picture3(3).Visible = True
End If
If (myvalue) = 4 Then
Picture3(4).Visible = True
End If
If (myvalue) = 5 Then
Picture3(5).Visible = True
End If
If (myvalue) = 6 Then
Picture3(6).Visible = True
End If
If (myvalue) = 7 Then
Picture3(7).Visible = True
End If
If (myvalue) = 8 Then
Picture3(8).Visible = True
End If
If (myvalue) = 9 Then
Picture3(9).Visible = True
End If
x = Index
Timer2.Enabled = True
End Sub

Como não encontrei uma função simplificada recorri a esta que vai sempre certinha...:D
 
Obrigado a todos... Já consegui criar o jogo. Quando tiver os níveis feitos e tudo isso meto aqui :D

O que faltava para tirar a imagem era:

Código:
Private Sub Picture2_MouseDown(Index As Integer, Button As Integer, Shift As Integer, x As Single, Y As Single)
placar = placar + 1
Text1.Text = placar
Picture2(Index).Visible = False ' a imagem em que clicas-te fica invisivel
If (myvalue) = 0 Then
Picture3(0).Visible = True
End If
If (myvalue) = 1 Then
Picture3(1).Visible = True
End If
If (myvalue) = 2 Then
Picture3(2).Visible = True
End If
If (myvalue) = 3 Then
Picture3(3).Visible = True
End If
If (myvalue) = 4 Then
Picture3(4).Visible = True
End If
If (myvalue) = 5 Then
Picture3(5).Visible = True
End If
If (myvalue) = 6 Then
Picture3(6).Visible = True
End If
If (myvalue) = 7 Then
Picture3(7).Visible = True
End If
If (myvalue) = 8 Then
Picture3(8).Visible = True
End If
If (myvalue) = 9 Then
Picture3(9).Visible = True
End If
[B][SIZE=3]Timer2.Enabled = True[/SIZE][/B]
End Sub
 
Private Sub Timer2_Timer()
[B][SIZE=3]Picture3(myvalue).Visible = False[/SIZE][/B]
End Sub
 
Back
Topo