Puis, je me tourne vers AutoIt (Le C, c'est génial mais je ne suis qu'un programmeur du dimanche, j'veut pas trop me compliquer la vie!), alors j'me dit pourquoi ne pas adapter le plus ou moin en AutoIt!
Et voila le résultat!
► Afficher le texte
Code : Tout sélectionner
#cs ----------------------------------------------------------------------------
AutoIt Version: 3.3.0.0
Author: Matwachich
Date: 28-08-2009
Version: 0.1a
Script Function:
Adaptation du plus ou moins en C du site du zero
#ce ----------------------------------------------------------------------------
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Global $main_gui = GUICreate("Plus ou Moins", 242, 78)
$menu_fichier = GUICtrlCreateMenu("Fichier")
Global $new_game = GUICtrlCreateMenuItem("Nouveau", $menu_fichier)
Global $menu_exit = GUICtrlCreateMenuItem("Quiter", $menu_fichier)
$menu_difficulte = GUICtrlCreateMenu("Difficulté")
Global $diff_3 = GUICtrlCreateMenuItem("Difficile", $menu_difficulte)
Global $diff_2 = GUICtrlCreateMenuItem("Moyen", $menu_difficulte)
Global $diff_1 = GUICtrlCreateMenuItem("Facile", $menu_difficulte)
Global $Input = GUICtrlCreateInput("Entrée", 80, 16, 81, 32)
GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
Global $pic_plus = GUICtrlCreatePic("plus.bmp", 176, 8, 49, 41, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS))
GUICtrlSetState($pic_plus, $GUI_HIDE)
Global $pic_moins = GUICtrlCreatePic("moins.bmp", 16, 8, 49, 41)
GUICtrlSetState($pic_moins, $GUI_HIDE)
GUISetState(@SW_SHOW)
Global $nombre_max = 100
Global $difficulte = 2
Global $nombre_secret
_Main()
Func _Main()
GUICtrlSetData($Input, "")
$nombre_secret = get_nombre($difficulte)
HotKeySet("{ENTER}", "verif")
While 1
$event = GUIGetMsg()
Switch $event
Case $diff_1
$difficulte = 1
_Main()
Case $diff_2
$difficulte = 2
_Main()
Case $diff_3
$difficulte = 3
_Main()
Case $GUI_EVENT_CLOSE
Exit
Case $menu_exit
Exit
Case $new_game
_Main()
EndSwitch
WEnd
EndFunc ;==>_Main
Func get_nombre($difficulte)
Local $nombre = 0
If $difficulte = 1 Then
$nombre = Random(1, 20, 1)
MsgBox(64, "Plus ou Moins", "Difficulté facile: nombre entre 1 et 20")
ElseIf $difficulte = 2 Then
$nombre = Random(1, 100, 1)
MsgBox(64, "Plus ou Moins", "Difficulté moyenne: nombre entre 1 et 100")
ElseIf $difficulte = 3 Then
$nombre = Random(1, 1000, 1)
MsgBox(64, "Plus ou Moins", "Difficulté difficile: nombre entre 1 et 1000")
EndIf
Return $nombre
EndFunc ;==>get_nombre
Func verif()
$nombre_entre = GUICtrlRead($Input)
If $nombre_entre > $nombre_secret And $nombre_entre <= $nombre_max Then
GUICtrlSetState($pic_moins, $GUI_SHOW)
Sleep(500)
GUICtrlSetState($pic_moins, $GUI_HIDE)
GUICtrlSetData($Input, "")
ElseIf $nombre_entre < $nombre_secret And $nombre_entre >= 1 Then
GUICtrlSetState($pic_plus, $GUI_SHOW)
Sleep(500)
GUICtrlSetState($pic_plus, $GUI_HIDE)
GUICtrlSetData($Input, "")
ElseIf $nombre_entre > $nombre_max Or $nombre_entre < 1 Then
MsgBox(48, "Plus ou Moins", "Le nombre se cache entre 1 et " & $nombre_max)
ElseIf $nombre_entre = $nombre_secret Then
_win()
EndIf
EndFunc ;==>verif
Func _win()
$msg = MsgBox(4, "Gagné!!!", "Bravo!!! Rejouer?")
If $msg = 6 Then
_Main()
ElseIf $msg = 7 Then
Exit 0
EndIf
EndFunc ;==>_win