Code : Tout sélectionner
;constante_window
Enumeration
#window_0
EndEnumeration
;constante_gadget
Enumeration
#String_0
#String_1
#text_0
#text_1
#text_2
#text_3
#button_0
#combo_0
EndEnumeration
;declaration des variables
score = 0
;ouverture de la fenetre
OpenWindow(#window_0,0,0,500,500,#PB_Window_SystemMenu|#PB_Window_ScreenCentered,"pro des maths")
CreateGadgetList(WindowID(#window_0))
StringGadget(#String_0,350,250,50,20,"")
TextGadget(#text_3,200,250,50,20,"5")
TextGadget(#text_0,300,250,25,20,"5")
TextGadget(#text_1,300,150,50,25,"0")
TextGadget(#text_2,250,250,50,20,"+")
ButtonGadget(#button_0,250,350,80,25,"j'ai trouvé")
ComboBoxGadget(#combo_0,25,100,250,150)
AddGadgetItem(#combo_0,0,"les petits (additions nombres < 10)")
AddGadgetItem(#combo_0,1,"les enfants (soustractions nombres < 100)")
AddGadgetItem(#combo_0,2,"les collègients (multiplications nombres < 400)")
AddGadgetItem(#combo_0,3,"les lycéens (divisions nombres < 1000)")
Repeat
Select WaitWindowEvent()
Case #PB_EventGadget
Select GetGadgetState(#combo_0)
Case 0
SetGadgetText(#text_2,"+")
Select EventGadgetID()
Case #button_0
If Val(GetGadgetText(#String_0)) = Val(GetGadgetText(#text_3)) + Val(GetGadgetText(#text_0))
MessageRequester("pro des maths","réponse juste",#MB_ICONINFORMATION)
score = score + 1
Else
MessageRequester("pro des maths","réponse fausse",#MB_ICONERROR)
score = score - 1
EndIf
If score = 5
MessageRequester("fini","vous avez gagnez")
Break
EndIf
SetGadgetText(#text_1,Str(score))
SetGadgetText(#text_0,Str(Random(10)))
SetGadgetText(#text_3,Str(Random(10)))
SetGadgetText(#String_0,"")
EndSelect
Case 1
SetGadgetText(#text_2,"__")
Select EventGadgetID()
Case #button_0
If Val(GetGadgetText(#String_0)) = Val(GetGadgetText(#text_3)) - Val(GetGadgetText(#text_0))
MessageRequester("pro des maths","réponse juste",#MB_ICONINFORMATION)
score = score + 1
Else
MessageRequester("pro des maths","réponse fausse",#MB_ICONERROR)
score = score - 1
EndIf
If score = 10
MessageRequester("fini","vous avez gagnez")
Break
EndIf
SetGadgetText(#text_1,Str(score))
SetGadgetText(#text_0,Str(Random(100)))
SetGadgetText(#text_3,Str(Random(100)))
SetGadgetText(#String_0,"")
EndSelect
Case 2
SetGadgetText(#text_2,"*")
Select EventGadgetID()
Case #button_0
If Val(GetGadgetText(#String_0)) = Val(GetGadgetText(#text_3)) * Val(GetGadgetText(#text_0))
MessageRequester("pro des maths","réponse juste",#MB_ICONINFORMATION)
score = score + 1
Else
MessageRequester("pro des maths","réponse fausse",#MB_ICONERROR)
score = score - 1
EndIf
If score = 15
MessageRequester("fini","vous avez gagnez")
Break
EndIf
SetGadgetText(#text_1,Str(score))
SetGadgetText(#text_0,Str(Random(400)))
SetGadgetText(#text_3,Str(Random(400)))
SetGadgetText(#String_0,"")
EndSelect
Case 3
SetGadgetText(#text_2,"/")
Select EventGadgetID()
Case #button_0
If Val(GetGadgetText(#String_0)) = Val(GetGadgetText(#text_3)) / Val(GetGadgetText(#text_0))
MessageRequester("pro des maths","réponse juste",#MB_ICONINFORMATION)
score = score + 1
Else
MessageRequester("pro des maths","réponse fausse",#MB_ICONERROR)
score = score - 1
EndIf
If score = 20
MessageRequester("fini","vous avez gagnez")
Break
EndIf
SetGadgetText(#text_1,Str(score))
SetGadgetText(#text_0,Str(Random(1000)))
SetGadgetText(#text_3,Str(Random(1000)))
SetGadgetText(#String_0,"")
EndSelect
EndSelect
Case #PB_Event_CloseWindow
quit = 1
EndSelect
Until quit = 1