Private Sub game()
Command1.Enabled = False
Option1.Enabled = False
Option2.Enabled = False
Text1.Enabled = False
Frame2.Visible = True
For i = 0 To 2
Label6(i).Visible = True
Next i
time.Enabled = True
End Sub
Private Sub Error()
MsgBox "La tua scommessa non è valida", vbCritical, "ATTENZIONE"
Text1.Enabled = True
Option1.Enabled = True
Option2.Enabled = True
Command1.Enabled = True
End Sub
Private Sub b_Click()
If lepre.Enabled = True And tartle.Enabled = True Then
MsgBox "Non puoi resettare mentre la gara è in corso!", vbInformation, "Gara"
Else
Text2.Text = 100
Call Form_Load
End If
End Sub
Private Sub Command1_Click()
On Error GoTo errori
Call game
Exit Sub
errori:
MsgBox "E' avvenuto un errore: scommessa non valida", vbCritical, "ERRORE"
End Sub
Private Sub e_Click()
Form2.Show
End Sub
Private Sub f_Click()
Unload Me
End Sub
Private Sub Form_Load()
Frame2.Visible = False
Text1.Text = ""
Label11.Caption = ""
Label12.Caption = ""
scommessa = Text1.Text
soldi = Text2.Text
Option1.Value = False
Option2.Value = False
Command1.Enabled = False
Option1.Enabled = True
Option2.Enabled = True
Text1.Enabled = True
Label4.Left = 120
Label5.Left = 120
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
If MsgBox("Sei sicuro di voler ucire?", vbYesNo, "Gara") = vbNo Then
Cancel = True
Else
End
End If
End Sub
Private Sub h_Click()
MsgBox "Gara: Lepre vs Tartaruga copyright © by Matteo Tomasulo 2003", vbInformation, "About"
End Sub
Private Sub lepre_Timer()
On Error GoTo errori
Dim scommessa As Double
Dim soldi As Double
scommessa = Text1.Text
soldi = Text2.Text
If scommessa > soldi Then
GoTo errori
End If
If scommessa = 0 Then
GoTo errori
End If
If Label4.Left > 10080 Then
lepre.Enabled = False
tartle.Enabled = False
MsgBox "Ha vinto la LEPRE!", vbExclamation, "Gara finita"
If Option1.Value = True Then
MsgBox "Hai vinto la scommessa", vbExclamation, "Vittoria"
Text2.Text = soldi + scommessa
Call Form_Load
Else
MsgBox "Hai perso la scommessa.", vbCritical, "Hai perso i soldi"
Text2.Text = soldi - scommessa
If Text2.Text < 0 Or Text2.Text = 0 Then
MsgBox "Hai perso tutti i soldi!!", vbCritical, "BANCAROTTA"
MsgBox "Game Over", , "Game Over"
If MsgBox("Hai perso tutto! vuoi rigiocare?", vbYesNo, "Hai perso") = vbNo Then
End
Else
Text2.Text = 100
Call Form_Load
End If
Else
Call Form_Load
End If
End If
Else
Dim a As Integer
a = 10 * Rnd(1)
If a = 1 Then
Label4.Left = Label4.Left
Label11.Caption = "si riposa"
ElseIf a = 2 Then
Label4.Left = Label4.Left
Label11.Caption = "si riposa"
ElseIf a = 3 Then
Label4.Left = Label4.Left + 1296
Label11.Caption = "fa il salto lungo"
ElseIf a = 4 Then
Label4.Left = Label4.Left + 1296
Label11.Caption = "fa il salto lungo"
ElseIf a = 5 Then
Label4.Left = Label4.Left - 1728
If Label4.Left < 480 Then
Label4.Left = 480
End If
Label11.Caption = "fa la scivolata lunga"
ElseIf a = 6 Then
Label4.Left = Label4.Left + 144
Label11.Caption = "fa il salto piccolo"
ElseIf a = 7 Then
Label4.Left = Label4.Left + 144
Label11.Caption = "fa il salto piccolo"
ElseIf a = 8 Then
Label4.Left = Label4.Left + 144
Label11.Caption = "fa il salto piccolo"
ElseIf a = 9 Then
Label4.Left = Label4.Left - 288
Label11.Caption = "fa la scivolata piccola"
If Label4.Left < 480 Then
Label4.Left = 480
ElseIf a = 10 Then
Label4.Left = Label4.Left - 288
If Label4 < 480 Then
Label4 = 480
End If
Label4.Caption = "fa la scivolata piccola"
End If
End If
End If
Exit Sub
errori:
tartle.Enabled = False
MsgBox "E' avvenuto un errore: scommessa non valida", vbCritical, "ERRORE"
lepre.Enabled = False
tartle.Enabled = False
Call Form_Load
End Sub
Private Sub Option1_Click()
Command1.Enabled = True
End Sub
Private Sub Option2_Click()
Command1.Enabled = True
End Sub
Private Sub tartle_Timer()
On Error GoTo valis
Dim sol As Double
sol = Text2.Text
Dim scom As Double
scom = Text1.Text
If Label5.Left > 10080 Then
lepre.Enabled = False
tartle.Enabled = False
MsgBox "Ha vinto la TARTARUGA!", vbExclamation, "Gara finita"
If Option2.Value = True Then
MsgBox "Hai vinto la scommessa", vbExclamation, "Vittoria"
Text2.Text = sol + scom
Call Form_Load
Else
MsgBox "Hai perso la scommessa.", vbCritical, "Hai perso i soldi"
Text2.Text = sol - scom
If Text2.Text < 0 Or Text2.Text = 0 Then
MsgBox "Hai perso tutti i soldi!!", vbCritical, "BANCAROTTA"
MsgBox "Game Over", , "Game Over"
If MsgBox("Hai perso tutto! vuoi rigiocare?", vbYesNo, "Hai perso") = vbNo Then
End
Else
Text2.Text = 100
Call Form_Load
End If
Else
Call Form_Load
End If
End If
Else
Dim W As Integer
W = 10 * Rnd(1)
If W = 1 Then
Label5.Left = Label5.Left + 432
Label12.Caption = "fa il passo veloce"
ElseIf W = 2 Then
Label5.Left = Label5.Left + 432
Label12.Caption = "fa il passo veloce"
ElseIf W = 3 Then
Label5.Left = Label5.Left + 432
Label12.Caption = "fa il passo veloce"
ElseIf W = 4 Then
Label5.Left = Label5.Left + 432
Label12.Caption = "fa il passo veloce"
ElseIf W = 5 Then
Label5.Left = Label5.Left + 432
Label12.Caption = "fa il passo veloce"
ElseIf W = 6 Then
Label5.Left = Label5.Left - 864
If Label5.Left < 480 Then
Label5.Left = 480
End If
Label12.Caption = "fa la scivolata"
ElseIf W = 7 Then
Label5.Left = Label5.Left - 864
If Label5.Left < 480 Then
Label5.Left = 480
End If
Label12.Caption = "fa la scivolata"
ElseIf W = 8 Then
Label5.Left = Label4.Left + 144
Label12.Caption = "fa il passo lento"
ElseIf W = 9 Then
Label5.Left = Label5.Left + 144
Label11.Caption = "fa il passo lento"
ElseIf W = 10 Then
Label5.Left = Label5.Left + 144
Label12.Caption = "fa il passo lento"
End If
End If
Exit Sub
valis:
tartle.Enabled = False
Call Form_Load
End Sub
Private Sub time_Timer()
Label6(2).Visible = False
time2.Enabled = True
time.Enabled = False
End Sub
Private Sub time2_Timer()
Label6(1).Visible = False
time3.Enabled = True
time2.Enabled = False
End Sub
Private Sub time3_Timer()
Label6(0).Visible = True
Label6(0).Visible = False
Timer1.Enabled = True
time3.Enabled = False
End Sub
Private Sub Timer1_Timer()
lepre.Enabled = True
tartle.Enabled = True
Timer1.Enabled = False
End Sub