CODICE
#cs ----------------------------------------------------------------------------
AutoIt Version: 3.3.0.0
Author: Greywolf
Script Function: Classico gioco carta, forbice e pietra.
#ce ----------------------------------------------------------------------------
#include <GUIConstants.au3>
$Form1 = GUICreate("Created by Greywolf",559, 453, 349, 271)
$Button1 = GUICtrlCreateButton("Carta ", 104, 352, 89, 81, 0)
$Button2 = GUICtrlCreateButton("Forbice", 224, 352, 91, 81, 0)
$Button3 = GUICtrlCreateButton("Pietra", 352, 352, 91, 81, 0)
$Button4 = GUICtrlCreateButton("Carta", 102, 70, 89, 81, 0)
$Button5 = GUICtrlCreateButton("Forbice", 222, 70, 91, 81, 0)
$Button6 = GUICtrlCreateButton("Pietra", 350, 70, 91, 81, 0)
$Group1 = GUICtrlCreateGroup("",96, 176, 353, 145)
$Label1 = GUICtrlCreateLabel(":::::::::::::::::::::::::::"& @CRLF &":::COMPUTER:::" & @CRLF &":::::::::::::::::::::::::::", 8, 88, 84, 73)
$Label2 = GUICtrlCreateLabel("::::::::::::::::::::::::::::"& @CRLF &":::::::::::TU::::::::::::"& @CRLF &"::::::::::::::::::::::::::::", 464, 376, 84, 41)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group3 = GUICtrlCreateGroup("TU", 400, 8, 153, 49)
Dim $punt1=0,$punt2=0
$Label6 = GUICtrlCreateLabel($punt1, 430, 30, 36, 25)
$Label7 = GUICtrlCreateLabel($punt2, 505, 30, 44, 25)
$Group4 = GUICtrlCreateGroup("PC", 480, 8, 1, 50)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
Global $n,$comp,$r
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $Button1
$n="carta"
$immag= GUICtrlCreatePic(@ScriptDir & "carta.jpg", 136, 208, 100, 81)
Sleep(1000)
gioco()
punteggio()
Case $button2
$n="forbice"
$immag= GUICtrlCreatePic(@ScriptDir & "forbice.jpg", 136, 208, 100, 81)
Sleep(1000)
gioco()
punteggio()
Case $button3
$n="pietra"
$immag= GUICtrlCreatePic(@ScriptDir & "pietra.jpg", 136, 208, 100, 81)
Sleep(1000)
gioco()
punteggio()
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
Func gioco()
$comp =Int(Random(1,4))
Switch $comp
Case $comp= 1
$immag2= GUICtrlCreatePic(@ScriptDir & "carta.jpg", 304, 208, 108, 81)
Case $comp =2
$immag2= GUICtrlCreatePic(@ScriptDir & "forbice.jpg", 304, 208, 108, 81)
Case $comp =3
$immag2= GUICtrlCreatePic(@ScriptDir & "pietra.jpg", 304, 208, 108, 81)
EndSwitch
if $n = "carta" and $comp = 1 Then
Sleep(1000)
MsgBox(0,"Game","Pareggio")
$r="pareggio"
ElseIf $n = "carta" and $comp = 2 Then
Sleep(1000)
MsgBox(0,"Game","Hai Perso")
$r="perso"
ElseIf $n = "carta" and $comp = 3 Then
Sleep(1000)
MsgBox(0,"Game","Hai Vinto")
$r="vinto"
ElseIf $n = "forbice" and $comp = 1 Then
Sleep(1000)
MsgBox(0,"Game","Hai Vinto")
$r="vinto"
ElseIf $n = "forbice" and $comp = 2 Then
Sleep(1000)
MsgBox(0,"Game","Pareggio")
$r="pareggio"
ElseIf $n = "forbice" and $comp = 3 Then
Sleep(1000)
MsgBox(0,"Game","Hai Perso")
$r="perso"
ElseIf $n = "pietra" and $comp = 1 Then
Sleep(1000)
MsgBox(0,"Game","Hai Perso")
$r="perso"
ElseIf $n = "pietra" and $comp = 2 Then
Sleep(1000)
MsgBox(0,"Game","Hai Vinto")
$r="vinto"
ElseIf $n = "pietra" and $comp = 3 Then
Sleep(1000)
MsgBox(0,"Game","Pareggio")
$r="pareggio"
EndIf
GUICtrlDelete ($immag)
GUICtrlDelete ($immag2)
EndFunc
Func Punteggio()
If $r="vinto" Then
$punt1=$punt1 + 1
ElseIf $r="perso" Then
$punt2=$punt2 + 1
EndIf
$Label6 = GUICtrlCreateLabel($punt1, 430, 30, 36, 25)
$Label7 = GUICtrlCreateLabel($punt2, 505, 30, 44, 25)
If $punt1=5 Then
vittoria()
ElseIf $punt2=5 Then
sconfitta()
EndIf
EndFunc
Func Vittoria()
Switch MsgBox(4,"Game","Complimenti hai vinto!!!" & @CRLF & "Vuoi rigiocare ??")
Case 6
$punt1=0
$punt2=0
$Label6 = GUICtrlCreateLabel($punt1, 430, 30, 36, 25)
$Label7 = GUICtrlCreateLabel($punt2, 505, 30, 44, 25)
Case 7
MsgBox(0,"Game", "A presto... Ciao!!!")
Exit
EndSwitch
EndFunc
Func Sconfitta()
switch MsgBox(4,"Game","Mi dispiace hai perso...!!!" & @CRLF & "Vuoi rigiocare ??")
Case 6
$punt1=0
$punt2=0
$Label6 = GUICtrlCreateLabel($punt1, 430, 30, 36, 25)
$Label7 = GUICtrlCreateLabel($punt2, 505, 30, 44, 25)
Case 7
MsgBox(0,"Game", "A presto... Ciao!!!")
Exit
EndSwitch
EndFunc