Ver Mensaje Individual
  #6 (permalink)  
Antiguo 15/06/2007, 11:54
vrael
 
Fecha de Ingreso: mayo-2007
Mensajes: 200
Antigüedad: 17 años
Puntos: 1
Re: Juego Basic, Problema con un Bucle!

Gracias por los consejos, la verdad es que me han sido de bastante ayuda.

¡¡¡Por fín lo he conseguido!!!

Después de bastante tiempo pensando, me dí cuenta que me había complicado la vida, y lo ví todo más sencillo. Conseguí hacer que funcionara, de forma más facil y sencilla.

Como contestación a tu pregunta, los timer los utilizo para animar un poco los textos (que aparezcan al segundo y cosas así) y para hacer visible e invisible el command1

Por si tienes curiosidad, te dejo el código mas abajo que funciona al 100%:
(Todavía no tengo muy pillado lo de dar formato al texto, así que te costará un poco leerlo) , como puedes ver, he quitado el bucle que me daba problemas y con esto consigo una función muy parecida:

Option Explicit
Dim i As Integer
Dim num1 As Integer
Dim num2 As Integer
Dim a
Dim vm
Dim vt
Dim dr
Dim dp
Dim b

Private Sub Command1_Click()

i = i + 1


If i = 1 Then

Randomize
num1 = Int((Rnd * 20) + 1)
Text1.Text = "Has sacado: " & num1
Command1.Visible = False

Randomize
num2 = Int((Rnd * 20) + 1)
Text1.Text = Text1.Text + vbCrLf + vbCrLf + "Tu enemigo ha sacado: " & num2
Command1.Visible = False

If num1 > num2 Then


Text1.Text = Text1.Text + vbCrLf + vbCrLf + " EMPIEZAS ATACANDO: ¡PREPARATE!"
Timer1.Enabled = True
End If

If num2 > num1 Then
Text1.Text = Text1.Text + vbCrLf + vbCrLf + vbCrLf + " TU ENEMIGO EMPIEZA ATACANDO: ¡PREPARATE!"
Timer1.Enabled = True

End If


End If


If i >= 2 And num1 > num2 Then

Randomize
dp = Int((Rnd * 20) + 1)
Text1.Text = "Tu ataque quita: " & dp & " de daño."
vt = vt - dp
Text2.Text = "Vida:" & vt
Command1.Visible = False
b = 0
Timer2.Enabled = True
End If

If i >= 2 And num2 > num1 Then

Randomize
dr = Int((Rnd * 20) + 1)
Text1.Text = "Tu enemigo te quita: " & dr & " de daño."
vm = vm - dr
Text3.Text = "Vida:" & vm
b = 0
Command1.Visible = False
Timer2.Enabled = True

End If



End Sub




Private Sub Form_Load()
vm = 150
vt = 150
Text2.Text = "Vida:" & vt
Text3.Text = "Vida:" & vm
End Sub

Private Sub Text2_Change()

If vt <= 0 Then
Text2.Enabled = False
Text3.Enabled = False
Command1.Visible = False
Command1.Enabled = False
MsgBox "HAS APLASTADO A TU ENEMIGO. PUEDES CONTINUAR TU CAMINO..." + vbCrLf + vbCrLf + " Código: PACPRO", vbOKOnly, "Fight Dragons of War"
Form5.Show
Unload Me
End If
End Sub


Private Sub Text3_Change()

If vm <= 0 Then
Text3.Enabled = False
Text2.Enabled = False
Command1.Visible = False
Command1.Enabled = False
MsgBox "¡¡HAS SIDO DERROTADO!!" + vbCrLf + vbCrLf + "Ya no hay esperanza...", vbOKOnly, "Fight Dragons of War"
Form1.Show
Unload Me
End If
End Sub


Private Sub Timer1_Timer()

a = a + 1
If a = 3 Then
Text1.Text = vbCrLf + vbCrLf + vbCrLf + " ¡¡EMPIEZA EL COMBATE!!"
End If

If a = 5 And num2 > num1 Then

Text1.Text = "Tira los dados para empezar la pelea:"
Command1.Visible = True
Timer1.Enabled = False
End If

If a = 5 And num1 > num2 Then

Command1.Visible = True
Text1.Text = "Tira los Dados:"
Timer1.Enabled = False
End If
End Sub


Private Sub Timer2_Timer()
b = b + 1
If i >= 2 And num1 > num2 And b = 1 Then
Randomize
dr = Int((Rnd * 20) + 1)
Text1.Text = Text1.Text + vbCrLf + vbCrLf + "Tu enemigo te quita:" & dr & " de vida."
vm = vm - dr
Text3.Text = "Vida:" & vm
Command1.Visible = True
End If

If i >= 2 And num1 < num2 And b = 1 Then

dp = Int((Rnd * 20) + 1)
Text1.Text = Text1.Text + vbCrLf + vbCrLf + "Tu ataque quita:" & dr & " de vida."
vt = vt - dp
Text2.Text = "Vida:" & vt
Command1.Visible = True
End If
End Sub



PD: tenías razón, me sobraban algunas variables.

Gracias por la ayuda.