[Calc] - Jeu des bâtons
Bonjour,
Démo:
Le code:
'=============================Jeu crée par ImoKa
'=============================v1.5
Option Compatible
Dim oDialogue As Object
Sub boite
initialisation
oDialogue=CreateUnoDialog(DialogLibraries.Standard.Dialog1)
oDialogue.execute()
End Sub
Dim label(19) As String
Dim tour As String
Dim x As Integer
Dim secondes As Double
Dim fin As Boolean
Dim joue_IA As Boolean
Sub initialisation
x = 0
secondes = 0.00000001
fin = false
joue_IA = false
tour = "joueur"
For i=0 To 19
label(i) = "Label"+(i+1)
Next
End Sub
Sub allumette1
Dim timer_avant As Long
If tour = "joueur" and joue_IA = false Then
timer_avant = Timer
Do While Timer < timer_avant + secondes
DoEvents
Loop
For i=0 To 19
oDialogue.getControl(label(x)).Model.PositionY = 25+i
Next
oDialogue.getControl("Label21").Text = "Au tour de l'IA, patience"
ElseIf joue_IA = true Then
oDialogue.getControl("CommandButton1").Model.BackgroundColor = 15658734
oDialogue.getControl("CommandButton2").Model.BackgroundColor = 15658734
oDialogue.getControl("CommandButton3").Model.BackgroundColor = 15658734
timer_avant = Timer
Do While Timer < timer_avant + secondes
DoEvents
Loop
For i=0 To 19
oDialogue.getControl(label(x)).Model.PositionY = 25-i
Next
oDialogue.getControl("Label21").Text = "A ton tour"
oDialogue.getControl("CommandButton1").Model.BackgroundColor = 13421772
oDialogue.getControl("CommandButton2").Model.BackgroundColor = 13421772
oDialogue.getControl("CommandButton3").Model.BackgroundColor = 13421772
End If
x = x+1
verification
If tour = "joueur" and fin = false Then
IA
End If
End Sub
Sub allumette2
Dim timer_avant As Long
If tour = "joueur" and joue_IA = false Then
timer_avant = Timer
Do While Timer < timer_avant + secondes
DoEvents
Loop
For i=0 To 19
oDialogue.getControl(label(x)).Model.PositionY = 25+i
oDialogue.getControl(label(x+1)).Model.PositionY = 25+i
Next
oDialogue.getControl("Label21").Text = "Au tour de l'IA, patience"
ElseIf joue_IA = true Then
oDialogue.getControl("CommandButton1").Model.BackgroundColor = 15658734
oDialogue.getControl("CommandButton2").Model.BackgroundColor = 15658734
oDialogue.getControl("CommandButton3").Model.BackgroundColor = 15658734
timer_avant = Timer
Do While Timer < timer_avant + secondes
DoEvents
Loop
For i=0 To 19
oDialogue.getControl(label(x)).Model.PositionY = 25-i
oDialogue.getControl(label(x+1)).Model.PositionY = 25-i
Next
oDialogue.getControl("Label21").Text = "A ton tour"
oDialogue.getControl("CommandButton1").Model.BackgroundColor = 13421772
oDialogue.getControl("CommandButton2").Model.BackgroundColor = 13421772
oDialogue.getControl("CommandButton3").Model.BackgroundColor = 13421772
End If
x = x+2
verification
If tour = "joueur" and fin = false Then
IA
End If
End Sub
Sub allumette3
Dim timer_avant As Long
If tour = "joueur" and joue_IA = false Then
timer_avant = Timer
Do While Timer < timer_avant + secondes
DoEvents
Loop
For i=0 To 19
oDialogue.getControl(label(x)).Model.PositionY = 25+i
oDialogue.getControl(label(x+1)).Model.PositionY = 25+i
oDialogue.getControl(label(x+2)).Model.PositionY = 25+i
Next
oDialogue.getControl("Label21").Text = "Au tour de l'IA, patience"
ElseIf joue_IA = true Then
oDialogue.getControl("CommandButton1").Model.BackgroundColor = 15658734
oDialogue.getControl("CommandButton2").Model.BackgroundColor = 15658734
oDialogue.getControl("CommandButton3").Model.BackgroundColor = 15658734
timer_avant = Timer
Do While Timer < timer_avant + secondes
DoEvents
Loop
For i=0 To 19
oDialogue.getControl(label(x)).Model.PositionY = 25-i
oDialogue.getControl(label(x+1)).Model.PositionY = 25-i
oDialogue.getControl(label(x+2)).Model.PositionY = 25-i
Next
oDialogue.getControl("Label21").Text = "A ton tour"
oDialogue.getControl("CommandButton1").Model.BackgroundColor = 13421772
oDialogue.getControl("CommandButton2").Model.BackgroundColor = 13421772
oDialogue.getControl("CommandButton3").Model.BackgroundColor = 13421772
End If
x = x+3
verification
If tour = "joueur" and fin = false Then
IA
End If
End Sub
Sub bouton1
allumette1
End Sub
Sub bouton2
allumette2
End Sub
Sub bouton3
allumette3
End Sub
Sub IA
Dim nombre As Integer
nombre = Int(Rnd * 3)
tour = "IA"
joue_IA = true
If nombre = 1 Then
allumette1
ElseIf nombre = 2 Then
allumette2
ElseIf nombre = 3 Then
allumette3
Else
If Int(Rnd * 2) MOD 2 = 0 Then
allumette1
Else
allumette3
End If
End If
tour = "joueur"
joue_IA = false
End Sub
Sub verification
If x = 20 and tour = "joueur" Then
MsgBox(prompt:="Bravo !!!!"&Chr(10)&Chr(10)&"Tu as gagné")
fin = true
ElseIf x = 20 and tour = "IA" Then
MsgBox(prompt:="Dommage"&Chr(10)&Chr(10)&"Tu as perdu")
fin = true
End If
If fin = true Then
oDialogue.endExecute()
End If
End SubBonne Journée
PS: Je l'ai proposé aux téléchargements mais Sébastien à refusé