logiciel éducatif

Programmation avancée de jeux en PureBasic
Avatar de l’utilisateur
Micoute
Messages : 2522
Inscription : dim. 02/oct./2011 16:17
Localisation : 35520 La Mézière

logiciel éducatif

Message par Micoute »

Bonjour à tous,
toujours dans ma collection de logiciels éducatifs pour mes petits enfants, j'ai conçu ce programme :

Code : Tout sélectionner

;Expressions françaises avec des noms d'animaux

;Utilisation de BindGadgetEvent

Enumeration Fenetres
  #Fenetre_principale
EndEnumeration

Enumeration Gadgets
  #Image_0
  #Txt_1
  #Txt_2
  #Txt_3
  #Txt_4
  #Txt_5
  #Txt_6
  #Cmb_1
  #Cmb_2
  #Cmb_3
  #Cmb_4
  #Cmb_5
  #Cmb_6
  #Btn_Verifier
  #Btn_Suivant
EndEnumeration

Enumeration Polices
  #Font_Txt_1
  #Font_Cmb_1
  #Font_Cmb_2
  #Font_Cmb_3
  #Font_Cmb_4
  #Font_Cmb_5
  #Font_Cmb_6
  #Font_Btn_Verifier
  #Font_Btn_Suivant
EndEnumeration

UsePNGImageDecoder()

Global Event, X, Q = 1
Global Dim Question.s(5,1), Dim RndReponse.s(5)
Global FichierImage.s = #PB_Compiler_FilePath + "\Data\Lapin.png"

original = LoadImage(#Image_0, FichierImage,0)

Restore S1

Procedure Lire_les_donnees()
  For X = 0 To 5 
    Read.s Question(X,0)
    Read.s Question(X,1)
    RndReponse(X) = Question(X,1)
  Next
  RandomizeArray(RndReponse())
EndProcedure

Procedure Polices() 
  For x = 1 To 6
    SetGadgetFont(x, LoadFont(#Font_Txt_1, "Verdana", 12, #PB_Font_Bold|#PB_Font_HighQuality))
  Next
  SetGadgetFont(#Btn_Verifier, LoadFont(#Font_Btn_Verifier, "Verdana", 12, #PB_Font_Bold|#PB_Font_HighQuality))
  SetGadgetFont(#Btn_Suivant, LoadFont(#Font_Btn_Suivant, "Verdana", 12, #PB_Font_Bold|#PB_Font_HighQuality))
  
  SetGadgetFont(#cmb_1,LoadFont(#Font_Cmb_1, "Verdana", 12, #PB_Font_Bold|#PB_Font_HighQuality))
  SetGadgetFont(#cmb_2,LoadFont(#Font_Cmb_2, "Verdana", 12, #PB_Font_Bold|#PB_Font_HighQuality))
  SetGadgetFont(#cmb_3,LoadFont(#Font_Cmb_3, "Verdana", 12, #PB_Font_Bold|#PB_Font_HighQuality))
  SetGadgetFont(#cmb_4,LoadFont(#Font_Cmb_4, "Verdana", 12, #PB_Font_Bold|#PB_Font_HighQuality))
  SetGadgetFont(#cmb_5,LoadFont(#Font_Cmb_5, "Verdana", 12, #PB_Font_Bold|#PB_Font_HighQuality))
  SetGadgetFont(#cmb_6,LoadFont(#Font_Cmb_6, "Verdana", 12, #PB_Font_Bold|#PB_Font_HighQuality))
EndProcedure

Procedure.s Clic_Btn_Verifier()
  If GetGadgetText(#Cmb_1) = Question(0,1)
    SetGadgetColor(#Txt_1, #PB_Gadget_FrontColor, $FF)
    Points + 10
  Else
    SetGadgetColor(#Txt_1, #PB_Gadget_FrontColor, 0)
  EndIf
  If GetGadgetText(#Cmb_2) = Question(1,1)
    SetGadgetColor(#Txt_2, #PB_Gadget_FrontColor, $FF)
    Points + 10
  Else
    SetGadgetColor(#Txt_2, #PB_Gadget_FrontColor, 0)
  EndIf
  If GetGadgetText(#Cmb_3) = Question(2,1)
    SetGadgetColor(#Txt_3, #PB_Gadget_FrontColor, $FF)
    Points + 10
  Else
    SetGadgetColor(#Txt_3, #PB_Gadget_FrontColor, 0)
  EndIf
  If GetGadgetText(#Cmb_4) = Question(3,1)
    SetGadgetColor(#Txt_4, #PB_Gadget_FrontColor, $FF)
    Points + 10
  Else
    SetGadgetColor(#Txt_4, #PB_Gadget_FrontColor, 0)
  EndIf
  If GetGadgetText(#Cmb_5) = Question(4,1)
    SetGadgetColor(#Txt_5, #PB_Gadget_FrontColor, $FF)
    Points + 10
  Else
    SetGadgetColor(#Txt_5, #PB_Gadget_FrontColor, 0)
  EndIf
  If GetGadgetText(#Cmb_6) = Question(5,1)
    SetGadgetColor(#Txt_6, #PB_Gadget_FrontColor, $FF)
  Else
    SetGadgetColor(#Txt_6, #PB_Gadget_FrontColor, 0)
    Points + 10
  EndIf
  
  Polices()
  
  If Points < 10    
    MessageRequester("Info","Hélas, tu n'as que " + Str(Points) + " point")
  Else  
    MessageRequester("Info","Bravo, tu as " + Str(Points) + " points")
  EndIf
  Total + Points
  Points = 0
  
EndProcedure  

Procedure Clic_Btn_Suivant()
  Q + 1
  If Q = 2
    Restore S2
  ElseIf Q = 3
    Restore S3
  ElseIf Q = 4
    Restore S4
  ElseIf Q = 5
    Restore S5
  ElseIf Q = 6
    Restore S6
  ElseIf Q = 7
    Restore S7
  ElseIf Q = 8
    Restore S8
  ElseIf Q = 9
    Restore S9
  ElseIf Q = 10
    Restore S10
  Else
    Q = 1
    Restore S1
  EndIf  
    
  SetGadgetColor(#Txt_1, #PB_Gadget_FrontColor, 0)
  SetGadgetColor(#Txt_2, #PB_Gadget_FrontColor, 0)
  SetGadgetColor(#Txt_3, #PB_Gadget_FrontColor, 0)
  SetGadgetColor(#Txt_4, #PB_Gadget_FrontColor, 0)
  SetGadgetColor(#Txt_5, #PB_Gadget_FrontColor, 0)
  SetGadgetColor(#Txt_6, #PB_Gadget_FrontColor, 0)
  
  Lire_les_donnees()
  
  SetGadgetText(#Txt_1,Question(0,0))
  SetGadgetText(#Txt_2,Question(1,0))
  SetGadgetText(#Txt_3,Question(2,0))
  SetGadgetText(#Txt_4,Question(3,0))
  SetGadgetText(#Txt_5,Question(4,0))
  SetGadgetText(#Txt_6,Question(5,0))
  
  ComboBoxGadget(#Cmb_1, 390, 30, 195, 24)
  ComboBoxGadget(#Cmb_2, 390, 64, 195, 24)
  ComboBoxGadget(#Cmb_3, 390, 98, 195, 24)
  ComboBoxGadget(#Cmb_4, 390, 132, 195, 24)
  ComboBoxGadget(#Cmb_5, 390, 166, 195, 24)
  ComboBoxGadget(#Cmb_6, 390, 200, 195, 24)
  
  For x = 0 To 5 
    AddGadgetItem(#Cmb_1, -1, RndReponse(X)) 
  Next
  For x = 0 To 5 
    AddGadgetItem(#Cmb_2, -1, RndReponse(X)) 
  Next
  For x = 0 To 5 
    AddGadgetItem(#Cmb_3, -1, RndReponse(X)) 
  Next
  For x = 0 To 5 
    AddGadgetItem(#Cmb_4, -1, RndReponse(X)) 
  Next
  For x = 0 To 5 
    AddGadgetItem(#Cmb_5, -1, RndReponse(X)) 
  Next
  For x = 0 To 5 
    AddGadgetItem(#Cmb_6, -1, RndReponse(X)) 
  Next
  
  Polices()
  
EndProcedure

Procedure Fermer_Fenetre_principale()  
  CloseWindow(#Fenetre_principale) 
  End
EndProcedure


Procedure OuvrirFenetre_principale()
  If OpenWindow(#Fenetre_principale, 450, 200, 610, 316, "Expressions françaises avec des noms d'animaux © 11/09/2014 - Micoute", #PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_MinimizeGadget|#PB_Window_TitleBar)
    BindEvent(#PB_Event_CloseWindow, @Fermer_Fenetre_principale(), #Fenetre_principale)
    ;images
    ImageGadget(#Image_0, 30, 30, 126, 200, ImageID(#Image_0))
    ;Textes
    TextGadget(#Txt_1, 180, 30, 205, 24, Question(0,0))
    TextGadget(#Txt_2, 180, 64, 205, 24, Question(1,0))
    TextGadget(#Txt_3, 180, 98, 205, 24, Question(2,0))
    TextGadget(#Txt_4, 180, 132, 205, 24, Question(3,0))
    TextGadget(#Txt_5, 180, 166, 205, 24, Question(4,0))
    TextGadget(#Txt_6, 180, 200, 205, 24, Question(5,0))
    ;Combos
    ComboBoxGadget(#Cmb_1, 390, 30, 195, 24)
    ComboBoxGadget(#Cmb_2, 390, 64, 195, 24)
    ComboBoxGadget(#Cmb_3, 390, 98, 195, 24)
    ComboBoxGadget(#Cmb_4, 390, 132, 195, 24)
    ComboBoxGadget(#Cmb_5, 390, 166, 195, 24)
    ComboBoxGadget(#Cmb_6, 390, 200, 195, 24)
    ComboBoxGadget(#Cmb_6, 390, 200, 195, 24)
    For x = 0 To 5 
      AddGadgetItem(#Cmb_1, -1, RndReponse(X)) 
    Next
    For x = 0 To 5 
      AddGadgetItem(#Cmb_2, -1, RndReponse(X)) 
    Next
    For x = 0 To 5 
      AddGadgetItem(#Cmb_3, -1, RndReponse(X)) 
    Next
    For x = 0 To 5 
      AddGadgetItem(#Cmb_4, -1, RndReponse(X)) 
    Next
    For x = 0 To 5 
      AddGadgetItem(#Cmb_5, -1, RndReponse(X)) 
    Next
    For x = 0 To 5 
      AddGadgetItem(#Cmb_6, -1, RndReponse(X)) 
    Next
    ;Boutons
    ButtonGadget(#Btn_Verifier, 175, 265, 115, 25, "Vérifier")
    ButtonGadget(#Btn_Suivant, 300, 265, 115,25,"Suivant")
    ;Gestions des événements
    BindGadgetEvent(#Btn_Verifier, @Clic_Btn_Verifier())
    BindGadgetEvent(#Btn_Suivant, @Clic_Btn_Suivant())
    
    Polices()
  EndIf
EndProcedure

Lire_les_donnees()

OuvrirFenetre_principale()

;- Boucle principale
Repeat
  Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow

;Données
DataSection
  S1:
  Data.s "Se faire poser","un lapin","Être lent comme","un escargot","Avoir une faim","de loup",
         "Être malade comme","un chien","Une écriture en pattes","de mouche","Être bête comme","une oie"
  S2:
  Data.s "Être malin comme","un singe","Être fier comme","un paon","Faire une queue","de poisson",
         "Avoir des mollets","de coq","Se jeter dans la gueule","du loup","C’est un temps","de canard"
  S3:
  Data.s "Être rusé comme","un renard","Être muet comme","une carpe","Être myope comme","une taupe",
         "Être tête","de linotte","Donner sa langue","au chat","Avoir la chair","de poule"
  S4:
  Data.s "Se coucher comme","les poules","Sauter du coq à","l'âne","Avaler","une couleuvre",
         "Courir comme","un lapin","Prendre","la mouche","Être gai comme","un pinson"
  S5:
  Data.s "Avoir un caractère","de cochon","Avoir une cervelle","de moineau","Bailler","aux corneilles",
         "Être têtu comme","une mule","Avoir","le cafard","Être une peau","de vache"
  S6:
  Data.s "Faire un froid","de canard","Avoir des larmes","de crocodile","Dormir comme","une marmotte",
         "Monter sur","ses grands chevaux","Avoir une mémoire","d'éléphant","Être gai comme","un pinson"
  S7:
  Data.s "Être noir comme","un corbeau","Revenir à","nos moutons","Être plat comme","une limande",
         "Être laid comme","un poux","Être nu comme","un ver","Être doux comme","un agneau"
  S8:
  Data.s "Avoir une langue","de vipère","Faire le pied","de grue","Être gavé comme","une oie",
         "Avoir une crinière","de lion","Avoir","le bourbon","Avoir une fièvre","de cheval"
  S9:
  Data.s "Se faire prendre pour","un pigeon","Être fier comme","un coq","Faire la politique de","l'autruche",
         "Se faufiler comme","une anguille","Puer comme","bouc","Manger comme","un cochon"
  S10:
  Data.s "Marcher comme","un crabe","Être excité comme","une puce","Être serrés comme","des sardines",
         "Être bavarde comme","une pie","Être un beau comme","un merle","Être frisé comme","un mouton"
EndDataSection  
image : http://www.petit-fichier.fr/2014/09/11/lapin/
Microsoft Windows 10 Famille 64 bits : Carte mère : ASRock 970 Extreme3 R2.0 : Carte Graphique NVIDIA GeForce RTX 3080 : Processeur AMD FX 6300 6 cœurs 12 threads 3,50 GHz PB 5.73 PB 6.00 LTS (x64)
Un homme doit être poli, mais il doit aussi être libre !
Avatar de l’utilisateur
MetalOS
Messages : 1492
Inscription : mar. 20/juin/2006 22:17
Localisation : Lorraine
Contact :

Re: logiciel éducatif

Message par MetalOS »

Super je vais bientôt être papa sa me servira plus tard [WINKING FACE]
Avatar de l’utilisateur
Micoute
Messages : 2522
Inscription : dim. 02/oct./2011 16:17
Localisation : 35520 La Mézière

Re: logiciel éducatif

Message par Micoute »

Bonjour MetalOS,

c'est sûr que tu as encore du temps, c'est du niveau CE1, CE2 !
Microsoft Windows 10 Famille 64 bits : Carte mère : ASRock 970 Extreme3 R2.0 : Carte Graphique NVIDIA GeForce RTX 3080 : Processeur AMD FX 6300 6 cœurs 12 threads 3,50 GHz PB 5.73 PB 6.00 LTS (x64)
Un homme doit être poli, mais il doit aussi être libre !
Avatar de l’utilisateur
Kwai chang caine
Messages : 6962
Inscription : sam. 23/sept./2006 18:32
Localisation : Isere

Re: logiciel éducatif

Message par Kwai chang caine »

Merci Micoute 8)
Pour info, je ne sais pas comment mais à un moment j'ai eu un bug d'affichage
Deux polices de caracteres qui se chevauchaient en appuyant sur verifier

Ca a été dur...mais j'ai eu quelques points :mrgreen:
ImageLe bonheur est une route...
Pas une destination

PureBasic Forum Officiel - Site PureBasic
Avatar de l’utilisateur
MetalOS
Messages : 1492
Inscription : mar. 20/juin/2006 22:17
Localisation : Lorraine
Contact :

Re: logiciel éducatif

Message par MetalOS »

Micoute a écrit :Bonjour MetalOS,

c'est sûr que tu as encore du temps, c'est du niveau CE1, CE2 !
Effectivement j'ai encore le temps lol
Avatar de l’utilisateur
Micoute
Messages : 2522
Inscription : dim. 02/oct./2011 16:17
Localisation : 35520 La Mézière

Re: logiciel éducatif

Message par Micoute »

Kwai chang caine a écrit :Merci Micoute 8)
Pour info, je ne sais pas comment mais à un moment j'ai eu un bug d'affichage
Deux polices de caracteres qui se chevauchaient en appuyant sur verifier
Je trouve ça étrange, en effet, mais j'ai refait plusieurs fois le test et je n'ai rien eut de semblable.
La chose qui doit se produire, normal, c'est fait exprès, c'est que les bonnes réponses s'affichent en rouge, c'est plus facile pour corriger !
Microsoft Windows 10 Famille 64 bits : Carte mère : ASRock 970 Extreme3 R2.0 : Carte Graphique NVIDIA GeForce RTX 3080 : Processeur AMD FX 6300 6 cœurs 12 threads 3,50 GHz PB 5.73 PB 6.00 LTS (x64)
Un homme doit être poli, mais il doit aussi être libre !
Répondre