Option Explicit
Dim pepita As Integer
Dim mosse As Integer
Dim bonus() As Integer
Dim malus() As Integer
Dim morte() As Integer
Dim dimentica() As Integer
Private Sub cmdCasella_Click(index As Integer)
Dim i As Integer
Dim ok As Integer
Dim j As Integer
mosse = mosse - 1
txtMosse.Text = mosse
cmdCasella(index).Enabled = False
If mosse <= 0 Then perso
If index = pepita Then
vinto
cmdCasella(index).Caption = "P"
cmdCasella(index).BackColor = &HFF80FF
End If
For i = 0 To UBound(morte)
If index = morte(i) Then
perso
cmdCasella(index).BackColor = &H0&
ok = 1
End If
Next i
For i = 0 To UBound(bonus)
If index = bonus(i) Then
mosse = mosse + 5
txtMosse.Text = mosse
cmdCasella(index).BackColor = &HFFFF00
ok = 1
End If
Next i
For i = 0 To UBound(malus)
If index = malus(i) Then
mosse = mosse - 5
txtMosse.Text = mosse
cmdCasella(index).BackColor = &HFF&
ok = 1
End If
Next i
For i = 0 To UBound(dimentica)
If index = dimentica(i) Then
For j = 0 To 599
cmdCasella(j).Enabled = True
cmdCasella(j).Caption = ""
cmdCasella(j).BackColor = &H8000000F
Next j
cmdCasella(index).Enabled = False
cmdCasella(index).BackColor = &HFF00&
ok = 1
End If
Next i
If ok <> 1 Then distanza index
End Sub
Private Sub cmdNuova_Click()
cmdNuova.Visible = False
mnuNuovo_Click
End Sub
Private Sub mnuAbout_Click()
Load frmAbout
frmAbout.Show
End Sub
Private Sub mnuDifficile_Click()
mnuDifficile.Checked = True
mnuFacile.Checked = False
mnuNormale.Checked = False
mnuNuovo_Click
End Sub
Private Sub mnuEsci_Click()
End
End Sub
Private Sub mnuFacile_Click()
mnuDifficile.Checked = False
mnuFacile.Checked = True
mnuNormale.Checked = False
mnuNuovo_Click
End Sub
Private Sub mnuIstruzioni_Click()
Load frmIstruzioni
frmIstruzioni.Show
End Sub
Private Sub mnuNormale_Click()
mnuDifficile.Checked = False
mnuFacile.Checked = False
mnuNormale.Checked = True
mnuNuovo_Click
End Sub
Private Sub mnuNuovo_Click()
main
End Sub
Private Sub main()
Dim i As Integer
For i = 0 To 599
cmdCasella(i).Enabled = True
cmdCasella(i).Caption = ""
cmdCasella(i).BackColor = &H8000000F
Next i
imgPepita.Visible = False
lblRisultato.Visible = False
mnuTrucchi.Enabled = True
pos_pepita
If mnuFacile.Checked = True Then
livello 20, 20, 10, 1, 1
Else
If mnuNormale.Checked = True Then
livello 10, 15, 15, 2, 2
Else
livello 5, 5, 20, 5, 5
End If
End If
End Sub
Private Sub pos_pepita()
Randomize
pepita = (600 * Rnd) - 1
End Sub
Private Static Sub distanza(index As Integer)
cmdCasella(index).BackColor = &H80FFFF
cmdCasella(index).Appearance = 0
Dim col_pepita As Integer
Dim col_index As Integer
Dim rig_index As Single
Dim rig_pepita As Single
Dim x As Integer
Dim y As Integer
col_pepita = pepita + 1
col_index = index + 1
rig_pepita = pepita
rig_index = index
Do While col_index > 30
col_index = col_index - 30
Loop
Do While col_pepita > 30
col_pepita = col_pepita - 30
Loop
rig_index = (rig_index / 30) + 1
rig_pepita = (rig_pepita / 30) + 1
If ((col_pepita - col_index) >= 0) Then x = col_pepita - col_index Else x = col_index - col_pepita
If ((rig_pepita - rig_index) >= 0) Then y = rig_pepita - rig_index Else y = rig_index - rig_pepita
If x > y Then
cmdCasella(index).Caption = (x - y) + y
Else
cmdCasella(index).Caption = (y - x) + x
End If
End Sub
Private Sub livello(mos As Integer, bon As Integer, mal As Integer, mor As Integer, dime As Integer)
mosse = mos
txtMosse.Text = mos
pos_bonus (bon)
pos_malus (mal)
pos_morte (mor)
pos_dimentica (dime)
End Sub
Private Sub vinto()
Dim i As Integer
For i = 0 To 599
cmdCasella(i).Enabled = False
Next i
lblRisultato.Visible = True
lblRisultato.Caption = "Vittoria!!!"
imgPepita.Visible = True
cmdNuova.Visible = True
End Sub
Private Sub perso()
Dim i As Integer
For i = 0 To 599
cmdCasella(i).Enabled = False
Next i
lblRisultato.Visible = True
lblRisultato.Caption = "Hai perso..."
cmdNuova.Visible = True
End Sub
Private Sub pos_morte(n As Integer)
ReDim morte(n)
Dim i As Integer
Dim j As Integer
Dim app As Integer
Dim ok As Integer
For i = 0 To n
morte(i) = -1
Next i
For i = 0 To n - 1
Randomize
app = (600 * Rnd)
app = app - 1
For j = i To 0 Step -1
If (app <> morte(i)) And (app <> pepita) And (app <> -1) Then ok = 0 Else ok = 1
If ok = 0 Then
morte(i) = app
j = -1
End If
Next j
If ok = 1 Then i = i - 1
Next i
End Sub
Private Sub pos_bonus(n As Integer)
ReDim bonus(n)
Dim i As Integer
Dim j As Integer
Dim app As Integer
Dim ok As Integer
For i = 0 To n
bonus(i) = -1
Next i
For i = 0 To n - 1
Randomize
app = (600 * Rnd)
app = app - 1
For j = i To 0 Step -1
If (app <> bonus(i)) And (app <> pepita) And (app <> -1) Then ok = 0 Else ok = 1
If ok = 0 Then
bonus(i) = app
j = -1
End If
Next j
If ok = 1 Then i = i - 1
Next i
End Sub
Private Sub pos_malus(n As Integer)
ReDim malus(n)
Dim i As Integer
Dim j As Integer
Dim app As Integer
Dim ok As Integer
For i = 0 To n
malus(i) = -1
Next i
For i = 0 To n - 1
Randomize
app = (600 * Rnd)
app = app - 1
For j = i To 0 Step -1
If (app <> malus(i)) And (app <> pepita) And (app <> -1) Then ok = 0 Else ok = 1
If ok = 0 Then
malus(i) = app
j = -1
End If
Next j
If ok = 1 Then i = i - 1
Next i
End Sub
Private Sub pos_dimentica(n As Integer)
ReDim dimentica(n)
Dim i As Integer
Dim j As Integer
Dim app As Integer
Dim ok As Integer
For i = 0 To n
dimentica(i) = -1
Next i
For i = 0 To n - 1
Randomize
app = (600 * Rnd)
app = app - 1
For j = i To 0 Step -1
If (app <> dimentica(i)) And (app <> pepita) And (app <> -1) Then ok = 0 Else ok = 1
If ok = 0 Then
dimentica(i) = app
j = -1
End If
Next j
If ok = 1 Then i = i - 1
Next i
End Sub
Private Sub mnuTrucchi_Click()
Dim codice As String
codice = InputBox("Inserisci nell'area di testo il trucco da attivare.", "Trucchi")
If codice = "cerca bonus" Then visualizza bonus, &HFFFF00
If codice = "cerca malus" Then visualizza malus, &HFF&
If codice = "cerca morte" Then visualizza morte, &H0&
If codice = "cerca dimentica" Then visualizza dimentica, &HFF00&
End Sub
Private Sub visualizza(app() As Integer, colore As String)
Dim i As Integer
For i = 0 To UBound(app) - 1
cmdCasella(app(i)).BackColor = colore
Next i
End Sub