Comment rendre mon programme plus rapide ?
Publié : lun. 29/août/2016 16:12
Bonjour à tous,
toujours dans mes programmes destinés à mes petits enfants, je souhaiterais améliorer l'initialisation pour rendre ce logiciel, un poil plus rapide.
Je viens donc une fois de plus, solliciter votre aide bienveillante et je vous en remercie beaucoup par anticipation.
toujours dans mes programmes destinés à mes petits enfants, je souhaiterais améliorer l'initialisation pour rendre ce logiciel, un poil plus rapide.
Je viens donc une fois de plus, solliciter votre aide bienveillante et je vous en remercie beaucoup par anticipation.
Code : Tout sélectionner
;Capitales de l'Europe des 27
Enumeration Fenetres
#Fenetre_principale
EndEnumeration
Enumeration Gadgets
#Txt_0
#Txt_1
#Txt_2
#Txt_3
#Txt_4
#Txt_5
#Txt_6
#Txt_7
#Txt_8
#Txt_9
#Txt_10
#Txt_11
#Txt_12
#Txt_13
#Txt_14
#Txt_15
#Txt_16
#Txt_17
#Txt_18
#Txt_19
#Txt_20
#Txt_21
#Txt_22
#Txt_23
#Txt_24
#Cmb_0
#Cmb_1
#Cmb_2
#Cmb_3
#Cmb_4
#Cmb_5
#Cmb_6
#Cmb_7
#Cmb_8
#Cmb_9
#Cmb_10
#Cmb_11
#Cmb_12
#Cmb_13
#Cmb_14
#Cmb_15
#Cmb_16
#Cmb_17
#Cmb_18
#Cmb_19
#Cmb_20
#Cmb_21
#Cmb_22
#Cmb_23
#Cmb_24
#Btn_Verifier
#Ctn_0
#Ctn_1
EndEnumeration
Enumeration Polices
#Police
EndEnumeration
Structure Jeu
Points.i
C0.b
C1.b
C2.b
C3.b
C4.b
C5.b
C6.b
C7.b
C8.b
C9.b
C10.b
C11.b
C12.b
C13.b
C14.b
C15.b
C16.b
C17.b
C18.b
C19.b
C20.b
C21.b
C22.b
C23.b
C24.b
EndStructure
;Déclarations des variables
Global NbQuestions = 24, Dim Question.s(NbQuestions), Dim Reponse.s(NbQuestions), Dim RndReponse.s(NbQuestions), Evenement,
Police = LoadFont(#Police, "FontAwesome", 18, #PB_Font_Bold|#PB_Font_HighQuality)
Global.Jeu NbPoints, Verif
NbPoints\Points = 0
Verif\C0 = #False
Verif\C1 = #False
Verif\C2 = #False
Verif\C3 = #False
Verif\C4 = #False
Verif\C5 = #False
Verif\C6 = #False
Verif\C7 = #False
Verif\C8 = #False
Verif\C9 = #False
Verif\C10 = #False
Verif\C11 = #False
Verif\C12 = #False
Verif\C13 = #False
Verif\C14 = #False
Verif\C15 = #False
Verif\C16 = #False
Verif\C17 = #False
Verif\C18 = #False
Verif\C19 = #False
Verif\C20 = #False
Verif\C21 = #False
Verif\C22 = #False
Verif\C23 = #False
Verif\C24 = #False
SetGadgetFont(#PB_Default,FontID(#Police))
;Lecture des questions
Procedure Lire_les_donnees()
Restore Debut
For i = 0 To NbQuestions
Read.s Question(i)
Read.s Reponse(i)
Next i
;Lectures des réponses
;Restore Reponse
For i = 0 To NbQuestions
RndReponse(i) = Reponse(i)
Next i
;Mélanges des réponses
RandomizeArray(RndReponse())
SortArray(RndReponse(), #PB_Sort_Ascending)
EndProcedure
Procedure.s Clic_Btn_Verifier()
If GetGadgetText(#Cmb_0) = Reponse(0)
If Verif\C0 = #False
SetGadgetColor(#Txt_0, #PB_Gadget_FrontColor, $7F00)
Points + 10
Verif\C0 = #True
EndIf
Else
SetGadgetColor(#Txt_0, #PB_Gadget_FrontColor, $FF)
SetGadgetText(#Cmb_0, Reponse(0))
EndIf
If GetGadgetText(#Cmb_1) = Reponse(1)
If Verif\C1 = #False
SetGadgetColor(#Txt_1, #PB_Gadget_FrontColor, $7F00)
Points + 10
Verif\C1 = #True
EndIf
Else
SetGadgetColor(#Txt_1, #PB_Gadget_FrontColor, $FF)
SetGadgetText(#Cmb_1, Reponse(1))
EndIf
NbPoints\Points + Points
If GetGadgetText(#Cmb_2) = Reponse(2)
If Verif\C2 = #False
SetGadgetColor(#Txt_2, #PB_Gadget_FrontColor, $7F00)
Points + 10
Verif\C2 = #True
EndIf
Else
SetGadgetColor(#Txt_2, #PB_Gadget_FrontColor, $FF)
SetGadgetText(#Cmb_2, Reponse(2))
EndIf
If GetGadgetText(#Cmb_3) = Reponse(3)
If Verif\C3 = #False
SetGadgetColor(#Txt_3, #PB_Gadget_FrontColor, $7F00)
Points + 10
Verif\C3 = #True
EndIf
Else
SetGadgetColor(#Txt_3, #PB_Gadget_FrontColor, $FF)
SetGadgetText(#Cmb_3, Reponse(3))
EndIf
If GetGadgetText(#Cmb_4) = Reponse(4)
If Verif\C4 = #False
SetGadgetColor(#Txt_4, #PB_Gadget_FrontColor, $7F00)
Points + 10
Verif\C4 = #True
EndIf
Else
SetGadgetColor(#Txt_4, #PB_Gadget_FrontColor, $FF)
SetGadgetText(#Cmb_4, Reponse(4))
EndIf
If GetGadgetText(#Cmb_5) = Reponse(5)
If Verif\C5 = #False
SetGadgetColor(#Txt_5, #PB_Gadget_FrontColor, $7F00)
Points + 10
Verif\C5 = #True
EndIf
Else
SetGadgetColor(#Txt_5, #PB_Gadget_FrontColor, $FF)
SetGadgetText(#Cmb_5, Reponse(5))
EndIf
If GetGadgetText(#Cmb_6) = Reponse(6)
If Verif\C6 = #False
SetGadgetColor(#Txt_6, #PB_Gadget_FrontColor, $7F00)
Points + 10
Verif\C6 = #True
EndIf
Else
SetGadgetColor(#Txt_6, #PB_Gadget_FrontColor, $FF)
SetGadgetText(#Cmb_6, Reponse(6))
EndIf
If GetGadgetText(#Cmb_7) = Reponse(7)
If Verif\C7 = #False
SetGadgetColor(#Txt_7, #PB_Gadget_FrontColor, $7F00)
Points + 10
Verif\C7 = #True
EndIf
Else
SetGadgetColor(#Txt_7, #PB_Gadget_FrontColor, $FF)
SetGadgetText(#Cmb_7, Reponse(7))
EndIf
If GetGadgetText(#Cmb_8) = Reponse(8)
If Verif\C8 = #False
SetGadgetColor(#Txt_8, #PB_Gadget_FrontColor, $7F00)
Points + 10
Verif\C8 = #True
EndIf
Else
SetGadgetColor(#Txt_8, #PB_Gadget_FrontColor, $FF)
SetGadgetText(#Cmb_8, Reponse(8))
EndIf
If GetGadgetText(#Cmb_9) = Reponse(9)
If Verif\C9 = #False
SetGadgetColor(#Txt_9, #PB_Gadget_FrontColor, $7F00)
Points + 10
Verif\C9 = #True
EndIf
Else
SetGadgetColor(#Txt_9, #PB_Gadget_FrontColor, $FF)
SetGadgetText(#Cmb_9, Reponse(9))
EndIf
If GetGadgetText(#Cmb_10) = Reponse(10)
If Verif\C10 = #False
SetGadgetColor(#Txt_10, #PB_Gadget_FrontColor, $7F00)
Points + 10
Verif\C10 = #True
EndIf
Else
SetGadgetColor(#Txt_10, #PB_Gadget_FrontColor, $FF)
SetGadgetText(#Cmb_10, Reponse(10))
EndIf
If GetGadgetText(#Cmb_11) = Reponse(11)
If Verif\C11 = #False
SetGadgetColor(#Txt_11, #PB_Gadget_FrontColor, $7F00)
Points + 10
Verif\C11 = #True
EndIf
Else
SetGadgetColor(#Txt_11, #PB_Gadget_FrontColor, $FF)
SetGadgetText(#Cmb_11, Reponse(11))
EndIf
If GetGadgetText(#Cmb_12) = Reponse(12)
If Verif\C12 = #False
SetGadgetColor(#Txt_12, #PB_Gadget_FrontColor, $7F00)
Points + 10
Verif\C12 = #True
EndIf
Else
SetGadgetColor(#Txt_12, #PB_Gadget_FrontColor, $FF)
SetGadgetText(#Cmb_12, Reponse(12))
EndIf
If GetGadgetText(#Cmb_13) = Reponse(13)
If Verif\C13 = #False
SetGadgetColor(#Txt_13, #PB_Gadget_FrontColor, $7F00)
Points + 10
Verif\C13 = #True
EndIf
Else
SetGadgetColor(#Txt_13, #PB_Gadget_FrontColor, $FF)
SetGadgetText(#Cmb_13, Reponse(13))
EndIf
If GetGadgetText(#Cmb_14) = Reponse(14)
If Verif\C14 = #False
SetGadgetColor(#Txt_14, #PB_Gadget_FrontColor, $7F00)
Points + 10
Verif\C14 = #True
EndIf
Else
SetGadgetColor(#Txt_14, #PB_Gadget_FrontColor, $FF)
SetGadgetText(#Cmb_14, Reponse(14))
EndIf
If GetGadgetText(#Cmb_15) = Reponse(15)
If Verif\C15 = #False
SetGadgetColor(#Txt_15, #PB_Gadget_FrontColor, $7F00)
Points + 10
Verif\C15 = #True
EndIf
Else
SetGadgetColor(#Txt_15, #PB_Gadget_FrontColor, $FF)
SetGadgetText(#Cmb_15, Reponse(15))
EndIf
If GetGadgetText(#Cmb_16) = Reponse(16)
If Verif\C16 = #False
SetGadgetColor(#Txt_16, #PB_Gadget_FrontColor, $7F00)
Points + 10
Verif\C16 = #True
EndIf
Else
SetGadgetColor(#Txt_16, #PB_Gadget_FrontColor, $FF)
SetGadgetText(#Cmb_16, Reponse(16))
EndIf
If GetGadgetText(#Cmb_17) = Reponse(17)
If Verif\C17 = #False
SetGadgetColor(#Txt_17, #PB_Gadget_FrontColor, $7F00)
Points + 10
Verif\C17 = #True
EndIf
Else
SetGadgetColor(#Txt_17, #PB_Gadget_FrontColor, $FF)
SetGadgetText(#Cmb_17, Reponse(17))
EndIf
If GetGadgetText(#Cmb_18) = Reponse(18)
If Verif\C18 = #False
SetGadgetColor(#Txt_18, #PB_Gadget_FrontColor, $7F00)
Points + 10
Verif\C18 = #True
EndIf
Else
SetGadgetColor(#Txt_18, #PB_Gadget_FrontColor, $FF)
SetGadgetText(#Cmb_18, Reponse(18))
EndIf
If GetGadgetText(#Cmb_19) = Reponse(19)
If Verif\C19 = #False
SetGadgetColor(#Txt_19, #PB_Gadget_FrontColor, $7F00)
Points + 10
Verif\C19 = #True
EndIf
Else
SetGadgetColor(#Txt_19, #PB_Gadget_FrontColor, $FF)
SetGadgetText(#Cmb_19, Reponse(19))
EndIf
If GetGadgetText(#Cmb_20) = Reponse(20)
If Verif\C20 = #False
SetGadgetColor(#Txt_20, #PB_Gadget_FrontColor, $7F00)
Points + 10
Verif\C20 = #True
EndIf
Else
SetGadgetColor(#Txt_20, #PB_Gadget_FrontColor, $FF)
SetGadgetText(#Cmb_20, Reponse(20))
EndIf
If GetGadgetText(#Cmb_21) = Reponse(21)
If Verif\C21 = #False
SetGadgetColor(#Txt_21, #PB_Gadget_FrontColor, $7F00)
Points + 10
Verif\C21 = #True
EndIf
Else
SetGadgetColor(#Txt_21, #PB_Gadget_FrontColor, $FF)
SetGadgetText(#Cmb_21, Reponse(21))
EndIf
If GetGadgetText(#Cmb_22) = Reponse(22)
If Verif\C22 = #False
SetGadgetColor(#Txt_22, #PB_Gadget_FrontColor, $7F00)
Points + 10
Verif\C22 = #True
EndIf
Else
SetGadgetColor(#Txt_22, #PB_Gadget_FrontColor, $FF)
SetGadgetText(#Cmb_22, Reponse(22))
EndIf
If GetGadgetText(#Cmb_23) = Reponse(23)
If Verif\C23 = #False
SetGadgetColor(#Txt_23, #PB_Gadget_FrontColor, $7F00)
Points + 10
Verif\C23 = #True
EndIf
Else
SetGadgetColor(#Txt_23, #PB_Gadget_FrontColor, $FF)
SetGadgetText(#Cmb_23, Reponse(23))
EndIf
;If GetGadgetText(#Cmb_24) = Reponse(24)
; If Verif\C24 = #False
; SetGadgetColor(#Txt_24, #PB_Gadget_FrontColor, $7F00)
; Points + 10
; Verif\C24 = #True
; EndIf
;Else
; SetGadgetColor(#Txt_24, #PB_Gadget_FrontColor, $FF)
; SetGadgetText(#Cmb_24, Reponse(24))
;EndIf
NbPoints\Points = Points
If NbPoints\Points = 0
MessageRequester("Info", "Hélas, tu n'as aucun point")
Else
MessageRequester("Info", "Bravo, tu as " + Str(NbPoints\Points) + " points")
EndIf
Points = 0
EndProcedure
;Questionnaire
Procedure Ouvrir_Questionnaire()
OpenWindow(#Fenetre_principale, 0, 0, 1600, 680, "Capitales de l'Europe des 27", #PB_Window_ScreenCentered|#PB_Window_SystemMenu)
ContainerGadget(#Ctn_0, 0, 10, 800, 585)
TextGadget(#Txt_0, 10, 3, 500, 25, Question(0), #PB_Text_Right)
ComboBoxGadget(#Cmb_0, 520, 0, 270, 35)
TextGadget(#Txt_1, 10, 53, 500, 25, Question(1), #PB_Text_Right)
ComboBoxGadget(#Cmb_1, 520, 50, 270, 35)
TextGadget(#Txt_2, 10, 103, 500, 25, Question(2), #PB_Text_Right)
ComboBoxGadget(#Cmb_2, 520, 100, 270, 35)
TextGadget(#Txt_3, 10, 153, 500, 25, Question(3), #PB_Text_Right)
ComboBoxGadget(#Cmb_3, 520, 150, 270, 35)
TextGadget(#Txt_4, 10, 203, 500, 25, Question(4), #PB_Text_Right)
ComboBoxGadget(#Cmb_4, 520, 200, 270, 35)
TextGadget(#Txt_5, 10, 253, 500, 25, Question(5), #PB_Text_Right)
ComboBoxGadget(#Cmb_5, 520, 250, 270, 35)
TextGadget(#Txt_6, 10, 303, 500, 25, Question(6), #PB_Text_Right)
ComboBoxGadget(#Cmb_6, 520, 300, 270, 35)
TextGadget(#Txt_7, 10, 353, 500, 25, Question(7), #PB_Text_Right)
ComboBoxGadget(#Cmb_7, 520, 350, 270, 35)
TextGadget(#Txt_8, 10, 403, 500, 25, Question(8), #PB_Text_Right)
ComboBoxGadget(#Cmb_8, 520, 400, 270, 35)
TextGadget(#Txt_9, 10, 453, 500, 25, Question(9), #PB_Text_Right)
ComboBoxGadget(#Cmb_9, 520, 450, 270, 35)
TextGadget(#Txt_10, 10, 503, 500, 25, Question(10), #PB_Text_Right)
ComboBoxGadget(#Cmb_10, 520, 500, 270, 35)
TextGadget(#Txt_11, 10, 553, 500, 25, Question(11), #PB_Text_Right)
ComboBoxGadget(#Cmb_11, 520, 550, 270, 35)
CloseGadgetList()
ContainerGadget(#Ctn_1, 800, 10, 800, 585)
TextGadget(#Txt_12, 10, 3, 500, 25, Question(12), #PB_Text_Right)
ComboBoxGadget(#Cmb_12, 520, 0, 270, 35)
TextGadget(#Txt_13, 10, 53, 500, 25, Question(13), #PB_Text_Right)
ComboBoxGadget(#Cmb_13, 520, 50, 270, 35)
TextGadget(#Txt_14, 10, 103, 500, 25, Question(14), #PB_Text_Right)
ComboBoxGadget(#Cmb_14, 520, 100, 270, 35)
TextGadget(#Txt_15, 10, 153, 500, 25, Question(15), #PB_Text_Right)
ComboBoxGadget(#Cmb_15, 520, 150, 270, 35)
TextGadget(#Txt_16, 10, 203, 500, 25, Question(16), #PB_Text_Right)
ComboBoxGadget(#Cmb_16, 520, 200, 270, 35)
TextGadget(#Txt_17, 10, 253, 500, 25, Question(17), #PB_Text_Right)
ComboBoxGadget(#Cmb_17, 520, 250, 270, 35)
TextGadget(#Txt_18, 10, 303, 500, 25, Question(18), #PB_Text_Right)
ComboBoxGadget(#Cmb_18, 520, 300, 270, 35)
TextGadget(#Txt_19, 10, 353, 500, 25, Question(19), #PB_Text_Right)
ComboBoxGadget(#Cmb_19, 520, 350, 270, 35)
TextGadget(#Txt_20, 10, 403, 500, 25, Question(20), #PB_Text_Right)
ComboBoxGadget(#Cmb_20, 520, 400, 270, 35)
TextGadget(#Txt_21, 10, 453, 500, 25, Question(21), #PB_Text_Right)
ComboBoxGadget(#Cmb_21, 520, 450, 270, 35)
TextGadget(#Txt_22, 10, 503, 500, 25, Question(22), #PB_Text_Right)
ComboBoxGadget(#Cmb_22, 520, 500, 270, 35)
TextGadget(#Txt_23, 10, 553, 500, 25, Question(23), #PB_Text_Right)
ComboBoxGadget(#Cmb_23, 520, 550, 270, 35)
CloseGadgetList()
ButtonGadget(#Btn_Verifier, 765, 620, 70, 25, "Vérifier")
For i = 0 To NbQuestions
AddGadgetItem(#Cmb_0, - 1, RndReponse(i))
AddGadgetItem(#Cmb_1, - 1, RndReponse(i))
AddGadgetItem(#Cmb_2, - 1, RndReponse(i))
AddGadgetItem(#Cmb_3, - 1, RndReponse(i))
AddGadgetItem(#Cmb_4, - 1, RndReponse(i))
AddGadgetItem(#Cmb_5, - 1, RndReponse(i))
AddGadgetItem(#Cmb_6, - 1, RndReponse(i))
AddGadgetItem(#Cmb_7, - 1, RndReponse(i))
AddGadgetItem(#Cmb_8, - 1, RndReponse(i))
AddGadgetItem(#Cmb_9, - 1, RndReponse(i))
AddGadgetItem(#Cmb_10, - 1, RndReponse(i))
AddGadgetItem(#Cmb_11, - 1, RndReponse(i))
AddGadgetItem(#Cmb_12, - 1, RndReponse(i))
AddGadgetItem(#Cmb_13, - 1, RndReponse(i))
AddGadgetItem(#Cmb_14, - 1, RndReponse(i))
AddGadgetItem(#Cmb_15, - 1, RndReponse(i))
AddGadgetItem(#Cmb_16, - 1, RndReponse(i))
AddGadgetItem(#Cmb_17, - 1, RndReponse(i))
AddGadgetItem(#Cmb_18, - 1, RndReponse(i))
AddGadgetItem(#Cmb_19, - 1, RndReponse(i))
AddGadgetItem(#Cmb_20, - 1, RndReponse(i))
AddGadgetItem(#Cmb_21, - 1, RndReponse(i))
AddGadgetItem(#Cmb_22, - 1, RndReponse(i))
AddGadgetItem(#Cmb_23, - 1, RndReponse(i))
Next i
;BindGadgetEvent(#Btn_Verifier, @Clic_Btn_Verifier())
EndProcedure
Lire_les_donnees()
Ouvrir_Questionnaire()
;Boucle événementielle
Repeat
Evenement = WaitWindowEvent()
Select Evenement
Case #PB_Event_Gadget
EventGadget = EventGadget()
Select EventGadget
Case #Btn_Verifier
Clic_Btn_Verifier()
EndSelect
Case #PB_Event_CloseWindow
Select EventWindow()
Case #Fenetre_principale
CloseWindow(#Fenetre_principale)
Break
EndSelect
EndSelect
ForEver
DataSection
Debut:
Data.s "Dans quel pays se situe Madrid ?", "Espagne"
Data.s "Quelle est la capitale de la Finlande ?", "Helsinki"
Data.s "Où se situe Varsovie ?", "Pologne"
Data.s "Quelle est la capitale de l'Allemagne ?", "Berlin"
Data.s "Où se situe Dublin ?", "Irlande"
Data.s "Où se situe Stockholm ?", "Suède"
Data.s "Quelle est la capitale du Danemark ?", "Copenhague"
Data.s "Où se situe Vienne ?", "Autriche"
Data.s "Quelle est la capitale de la Grèce ?", "Athènes"
Data.s "Où se situe Budapest ?", "Hongrie"
Data.s "Quelle est la capitale de la Slovénie ?", "Ljubljana"
Data.s "Où se situe Bruxelles ?", "Belgique"
Data.s "Où se situe Luxembourg ?", "Grand-Duché du Luxembourg"
Data.s "Quelle est la capitale du Royaume-Uni ?", "Londres"
Data.s "Où se situe Rome ?", "Italie"
Data.s "Quelle est la capitale de la Slovaquie ?", "Bratislava"
Data.s "Où se situe La Valette ?", "Malte"
Data.s "Quelle est la capitale de Chypre ?", "Nicosie"
Data.s "Où se situe Prague ?", "République tchèque"
Data.s "Où se situe Vilnius ?", "Lituanie"
Data.s "Quelle est la capitale de la Lettonie ?", "Riga"
Data.s "Où se situe Tallinn ?", "Estonie"
Data.s "Où se situe Lisbonne ?", "Portugal"
Data.s "Quelle est la capitale des Pays-Bas ?", "Amsterdam"
Data.s "Où se situe Paris ?", "France"
EndDataSection