Yannick
Nombre de messages : 8611 Age : 53 Localisation : Bretagne Date d'inscription : 15/02/2010
| Sujet: MOTUS Sam 14 Sep 2019 - 15:15 | |
| Salut à tous ! Vous connaissez le célèbre jeu télévisé MOTUS le Master Mind des lettres. Ben voilà un début en Panoramic. Celui ci est fait pour jouer seul. Avant de lancer par le bouton NEW on peut choisir le nombre de lettres des mots avecle bouton OPTIONS On entre les letres au clavier de A à Z. On se déplace sur la ligne avec les flèches droite et gauche. On valide avec la touche ENTER. 6 essais A vous de retrouver le mot. Pour consultation je vous mets le source actuel mais vous aurez besoin des images et des fichiers dico. Le tout est sur mon webdav. - Code:
-
' MOTUS ' Vs 0.1 ' Y.GERONIMI ' 11/09/2019 ' ============================================================================== ' VARIABLES ' ============================================================================== ' Incrémentation des numéros d'objets dim no% ' ============================================================================== ' CONSTANTES ENVIRONNEMENT ' ============================================================================== ' Chemins des dossiers dim Path$ dim PathRes$ dim PathImg$ ' Images du menu dim ImgBtnMenu0$(5) dim ImgBtnMenu1$(5) dim ImgBtnMenu2$(5) ' Images Game dim ImgPictGame$ ' Images résultat dim ImgResultWin$ dim ImgResultLoose$ ' ============================================================================== ' CONSTANTES OBJETS ' ============================================================================== dim EditKeyBoard% dim Dico% dim Frame%(4) dim BtnPictMenu%(5) dim PictGame% dim PictTitre% dim PictResult% dim PictCell%(60) dim PictRegle%(6) dim Cont% dim Alph%(10) dim ComboChx% ' ============================================================================== ' CONSTANTES - PARAMETRES DE JEU ' ============================================================================== dim GAMEONOFF% :' 0 pas de partie en cours / 1 partie en cours dim LETTERS% :' Nombre de lettres des mots à trouver dim TRYNUMBER% :' x/6 Essais pour trouver le mot dim SELCELL% :' Cellule sélectionnée dim PLATEAU$(60) :' Cache de la manche dim WORD$ :' Mot à trouver dim VERIF% :' Nombre de lettres trouvées dim MESS% dim WORDNUM% :' Num du mot ' ============================================================================== ' LABELS ' ============================================================================== label CLIC_MENU label CLIC_PLATEAU label CHANGE label KDOWN label MMFRAME1 label MMBTN label MDBTN label MUBTN ' ============================================================================== ' PROGRAMME ' ============================================================================== INIT_ENVIRONNEMENT() INIT_OBJETS() INIT_PARAMETRES() GUI() BUILD_PLATEAU(LETTERS%) End ' ============================================================================== ' SS PROGRAMMES - CLIC ' ============================================================================== CLIC_MENU: if number_click = BtnPictMenu%(1) if GAMEONOFF%=0 if hide(Frame%(4))=1 : show Frame%(4) : end_if GAMEONOFF%=1 file_load PictGame%,ImgPictGame$ NEWWORD() set_focus EditKeyBoard% end_if end_if ' ------ if number_click = BtnPictMenu%(2) if GAMEONOFF%=0 : hide Frame%(4): end_if set_focus EditKeyBoard% end_if ' ------ if number_click = BtnPictMenu%(3) MESS% = message_information_ok("ABOUT") set_focus EditKeyBoard% end_if ' ------ if number_click = BtnPictMenu%(4) MESS% = message_information_ok("HELP") set_focus EditKeyBoard% end_if ' ------ if number_click = BtnPictMenu%(5) if GAMEONOFF% = 1 MESS% = message_warning_yes_no("Une partie est en cours !"+chr$(13)+"Voulez vous vraiement quitter ?") if MESS% = 1 terminate end_if else terminate end_if end_if return ' ============================================================================== ' SS PROGRAMMES - CLIC_PLATEAU ' ============================================================================== CLIC_PLATEAU: set_focus EditKeyBoard% return ' ============================================================================== ' SS PROGRAMMES - CHANGE ' ============================================================================== CHANGE: if number_change = ComboChx% off_change ComboChx% LETTERS% = val(item_index$(ComboChx%)) clear Dico% file_load Dico%,PathRes$+"MOTUS_"+str$(LETTERS%)+"_Lettres.txt" DELETE_PLATEAU() BUILD_PLATEAU(LETTERS%) on_change ComboChx%,CHANGE end_if return ' ============================================================================== ' SS PROGRAMMES - MOUSE MOVE ' ============================================================================== MMFRAME1: ActiveMouseMoveButton() return ' ------------------------------------------------------------------------------ MMBTN: ActiveButton(number_mouse_move) return ' ============================================================================== ' SS PROGRAMMES - MOUSE DOWN ' ============================================================================== MDBTN: PressButton(number_mouse_down) return ' ============================================================================== ' SS PROGRAMMES - MOUSE UP ' ============================================================================== MUBTN: UnPressButton(number_mouse_up) return ' ============================================================================== ' SS PROGRAMMES - KEY DOWN ' ============================================================================== KDOWN: off_key_down EditKeyBoard% if key_down_code>63 and key_down_code<91 INSERT_LETTER(SELCELL%,chr$(key_down_code)) SELECTED_CELL(SELCELL%+1) else if key_down_code = 39 if SELCELL%<(6*LETTERS%) : SELECTED_CELL(SELCELL%+1) : end_if else if key_down_code = 37 if SELCELL%>1 : SELECTED_CELL(SELCELL%-1) : end_if else if key_down_code = 13 VERIF_LINE(TRYNUMBER%) end_if end_if end_if end_if on_key_down EditKeyBoard%,KDOWN return ' ============================================================================== ' PROCEDURES - INITIALISATIONS ' ============================================================================== ' Définition de l'environnement Sub INIT_ENVIRONNEMENT() dim_local i% Path$ = file_extract_path$(param_value$(0)) PathRes$ = Path$+"Res\" PathImg$ = Path$+"Img\" for i%=1 to 5 : ImgBtnMenu0$(i%)=PathImg$+"BtnMenuOut_"+str$(i%)+".bmp" : next i% for i%=1 to 5 : ImgBtnMenu1$(i%)=PathImg$+"BtnMenuIn_"+str$(i%)+".bmp" : next i% for i%=1 to 5 : ImgBtnMenu2$(i%)=PathImg$+"BtnMenuClic_"+str$(i%)+".bmp": next i% ImgResultWin$ = PathImg$+"EmoWin.bmp" ImgResultLoose$ = PathImg$+"EmoLoose.bmp" ImgPictGame$ = PathImg$+"Word.bmp" End_sub ' ------------------------------------------------------------------------------ ' Numérotation des objets Sub INIT_OBJETS() dim_local i% no%=no%+1 : EditKeyBoard%=no% no%=no%+1 : Dico%=no% for i%=1 to 4 : no%=no%+1 : Frame%(i%)=no% : next i% no%=no%+1 : PictGame%=no% no%=no%+1 : PictTitre%=no% no%=no%+1 : PictResult%=no% for i%=1 to 5 : no%=no%+1 : BtnPictMenu%(i%)=no% : next i% no%=no%+1 : ComboChx%=no% for i%=1 to 60 : no%=no%+1 : PictCell%(i%)=no% : next i% for i%=1 to 6 : no%=no%+1 : PictRegle%(i%)=no% : next i% for i%=1 to 10 : no%=no%+1 : Alph%(i%)=no% : next i% no%=no%+1 : Cont%=no% End_sub ' ------------------------------------------------------------------------------ ' Paramètres de jeu par defaut. Sub INIT_PARAMETRES() dim_local i% GAMEONOFF% = 0 LETTERS% = 6 TRYNUMBER% = 1 SELCELL% = 1 for i%=1 to 60 : PLATEAU$(i%) = "" : next i% WORD$ = "" VERIF% = 0 End_sub ' ============================================================================== ' PROCEDURES ' ============================================================================== ' FORM principal Sub GUI() dim_local i%,t%,l%,h%,w%,etiq$,capt$,x%,y% etiq$ = "New,Options,Quit,Help,About," dlist Dico% file_load Dico%,PathRes$+"MOTUS_"+str$(LETTERS%)+"_Lettres.txt" border_hide 0 height 0,450 width 0,680 top 0,(screen_y-height(0))/2 left 0,(screen_x-width(0))/2 color 0,140,190,230 font_name 0,"Courier New" : font_size 0,10 : font_bold 0 font_color 0,90,90,90 create_hide edit EditKeyBoard% top EditKeyBoard%,10 left EditKeyBoard%,10 width EditKeyBoard%,69 on_key_down EditKeyBoard%,KDOWN panel Frame%(1) height Frame%(1),height_client(0)-20 width Frame%(1),74 top Frame%(1),10 left Frame%(1),10 t% = 5 l% = 5 for i%=1 to 2 button_picture BtnPictMenu%(i%) parent BtnPictMenu%(i%),Frame%(1) button_picture_target_is_object height BtnPictMenu%(i%),64 width BtnPictMenu%(i%),64 top BtnPictMenu%(i%),t% left BtnPictMenu%(i%),l% button_picture_target_is_picture height BtnPictMenu%(i%),48 width BtnPictMenu%(i%),48 file_load BtnPictMenu%(i%),ImgBtnMenu0$(i%) capt$ = left$(etiq$,instr(etiq$,chr$(44))-1) etiq$ = right$(etiq$,len(etiq$)-instr(etiq$,chr$(44))) hint BtnPictMenu%(i%),capt$ cursor_point BtnPictMenu%(i%) on_click BtnPictMenu%(i%),CLIC_MENU t%=t%+height(BtnPictMenu%(i%))+5 next i% t% = height_client(Frame%(1))-69 l% = 5 for i%=5 to 3 step -1 button_picture BtnPictMenu%(i%) parent BtnPictMenu%(i%),Frame%(1) button_picture_target_is_object height BtnPictMenu%(i%),64 width BtnPictMenu%(i%),64 top BtnPictMenu%(i%),t% left BtnPictMenu%(i%),l% button_picture_target_is_picture height BtnPictMenu%(i%),48 width BtnPictMenu%(i%),48 file_load BtnPictMenu%(i%),ImgBtnMenu0$(i%) capt$ = left$(etiq$,instr(etiq$,chr$(44))-1) etiq$ = right$(etiq$,len(etiq$)-instr(etiq$,chr$(44))) hint BtnPictMenu%(i%),capt$ cursor_point BtnPictMenu%(i%) on_click BtnPictMenu%(i%),CLIC_MENU t%=t%-height(BtnPictMenu%(i%))-5 next i% panel Frame%(2) height Frame%(2),380 width Frame%(2),width_client(0)-104 top Frame%(2),10 left Frame%(2),left(Frame%(1))+width(Frame%(1))+10 picture PictTitre% parent PictTitre%,Frame%(2) height PictTitre%,80 width PictTitre%,width_client(Frame%(2))-10 top PictTitre%,5 left PictTitre%,5 font_name PictTitre%,"Courier New" : font_size PictTitre%,40 : font_bold PictTitre% font_color PictTitre%,255,255,255 2d_target_is PictTitre% 2d_flood 1,1,140,190,230 print_target_is PictTitre% print_locate 200,10 print "MOTUS" picture PictGame% parent PictGame%,Frame%(2) height PictGame%,80 width PictGame%,80 top PictGame%,top(PictTitre%)+height(PictTitre%)+80 left PictGame%,5 color PictGame%,240,240,240 alpha Alph%(4) parent Alph%(4),Frame%(2) top Alph%(4),top(PictGame%)+60 left Alph%(4),20 font_size Alph%(4),20 : font_color Alph%(4),0,0,140 picture PictResult% parent PictResult%,Frame%(2) height PictResult%,125 width PictResult%,125 top PictResult%,height_client(frame%(2))-130 left PictResult%,width_client(Frame%(2))-130 color PictResult%,240,240,240 panel Frame%(3) height Frame%(3),height_client(0)-height(Frame%(2))-30 width Frame%(3),width_client(0)-104 top Frame%(3),top(Frame%(2))+height(Frame%(2))+10 left Frame%(3),left(Frame%(1))+width(Frame%(1))+10
container Cont% parent Cont%,Frame%(3) height Cont%,height_client(Frame%(3))-5 width Cont%,width_client(frame%(3))-10 top Cont%,0 left Cont%,5
alpha Alph%(1) parent Alph%(1),Cont% top Alph%(1),11 left Alph%(1),5 caption Alph%(1),"Nbre de Lettres : " combo ComboChx% parent ComboChx%,Cont% width ComboChx%,45 top ComboChx%,9 left ComboChx%,left(Alph%(1))+width(Alph%(1))+5 color ComboChx%,140,190,230 font_color ComboChx%,255,255,255 cursor_point ComboChx% item_add ComboChx%,6 item_add ComboChx%,7 item_add ComboChx%,8 item_add ComboChx%,9 item_add ComboChx%,10 item_select ComboChx%,1 on_change ComboChx%,CHANGE panel Frame%(4) height Frame%(4),height_client(0)-height(Frame%(2))-30 width Frame%(4),width_client(0)-104 top Frame%(4),top(Frame%(2))+height(Frame%(2))+10 left Frame%(4),left(Frame%(1))+width(Frame%(1))+10 alpha Alph%(2) parent Alph%(2),Frame%(4) top Alph%(2),10 left Alph%(2),10 alpha Alph%(3) parent Alph%(3),Frame%(4) top Alph%(3),10 left Alph%(3),210 font_color Alph%(3),0,0,140 show_all on_mouse_move Frame%(1),MMFRAME1 for i%=1 to 5 : on_mouse_move BtnPictMenu%(i%),MMBTN : next i% for i%=1 to 5 : on_mouse_down BtnPictMenu%(i%),MDBTN : next i% for i%=1 to 5 : on_mouse_up BtnPictMenu%(i%),MUBTN : next i% End_sub ' ------------------------------------------------------------------------------ Sub ActiveMouseMoveButton() dim_local i% off_mouse_move Frame%(1) for i%=1 to 5 file_load BtnPictMenu%(i%),ImgBtnMenu0$(i%) on_mouse_move BtnPictMenu%(i%),MMBTN next i% End_sub ' ------------------------------------------------------------------------------ Sub ActiveButton(btn%) dim_local i% off_mouse_move btn% for i%=1 to 5 if BtnPictMenu%(i%) = btn% file_load btn%,ImgBtnMenu1$(i%) exit_for end_if next i% on_mouse_move Frame%(1),MMFRAME1 End_sub ' ------------------------------------------------------------------------------ Sub PressButton(btn%) dim_local i% for i%=1 to 5 if BtnPictMenu%(i%) = btn% file_load btn%,ImgBtnMenu2$(i%) exit_for end_if next i% End_sub ' ------------------------------------------------------------------------------ Sub UnPressButton(btn%) dim_local i% for i%=1 to 5 if BtnPictMenu%(i%) = btn% file_load btn%,ImgBtnMenu0$(i%) exit_for end_if next i% End_sub ' ------------------------------------------------------------------------------ ' Création du plateau de jeu Sub BUILD_PLATEAU(p%) dim_local i%,x%,y%,h%,w%,t%,l% create_hide h% = 40 w% = 30 t% = top(PictTitre%)+height(PictTitre%)+10 l% = int((width_client(Frame%(2))-(p%*w%)-(p%-1))/2) for y%=1 to 6 for x%=1 to p% i%=i%+1 picture PictCell%(i%) parent PictCell%(i%),Frame%(2) height PictCell%(i%),h% width PictCell%(i%),w% top PictCell%(i%),t% left PictCell%(i%),l% font_name PictCell%(i%),"Courier New" : font_size PictCell%(i%),20 : font_bold PictCell%(i%) font_color PictCell%(i%),90,90,90 on_click PictCell%(i%),CLIC_PLATEAU 2d_target_is PictCell%(i%) 2d_pen_color 140,190,230 2d_rectangle 0,0,30,40 l%=l%+w%+1 next x% t%=t%+h%+2 l% = int((width_client(Frame%(2))-(p%*w%)-(p%-1))/2) next y% t% = top(PictCell%(1)) l% = left(PictCell%(1))-40 for i%=1 to 6 picture PictRegle%(i%) parent PictRegle%(i%),Frame%(2) height PictRegle%(i%),40 width PictRegle%(i%),30 top PictRegle%(i%),t% left PictRegle%(i%),l% font_name PictRegle%(i%),"Courier New" : font_size PictRegle%(i%),20 : font_bold PictRegle%(i%) font_color PictRegle%(i%),255,255,255 2d_target_is PictRegle%(i%) 2d_pen_color 140,190,230 2d_rectangle 0,0,30,40 2d_flood 1,1,140,190,230 print_target_is PictRegle%(i%) print_locate 6,4 print str$(i%) t%=t%+42 next i% show_all End_sub ' ------------------------------------------------------------------------------ ' Destruction du plateau de jeu Sub DELETE_PLATEAU() dim_local i% 2d_target_is 0 print_target_is 0 for i%=1 to 60 if object_exists(PictCell%(i%))=0 exit_for else delete PictCell%(i%) end_if next i% for i%=1 to 6 delete PictRegle%(i%) next i% End_sub ' ------------------------------------------------------------------------------ ' Coloration de la ligne active Sub COLOR_ACTIVELINE(TN%) dim_local deb%,fin%,i% Select TN% case 1 : deb% = 1 : fin% = deb%+(LETTERS%-1) case 2 : deb% = LETTERS%+1 : fin% = deb%+(LETTERS%-1) case 3 : deb% = (LETTERS%*2)+1 : fin% = deb%+(LETTERS%-1) case 4 : deb% = (LETTERS%*3)+1 : fin% = deb%+(LETTERS%-1) case 5 : deb% = (LETTERS%*4)+1 : fin% = deb%+(LETTERS%-1) case 6 : deb% = (LETTERS%*5)+1 : fin% = deb%+(LETTERS%-1) end_select for i%=deb% to fin% COLOR_ONE_CELL(i%,255,255,170) if PLATEAU$(i%)<>"" WRITE_CELL_VALUE(i%) end_if next i% End_sub ' ------------------------------------------------------------------------------ ' Coloration d'une cellule Sub COLOR_ONE_CELL(n%,r%,g%,b%) 2d_target_is PictCell%(n%) 2d_pen_color 140,190,230 2d_rectangle 0,0,30,40 2d_flood 1,1,r%,g%,b% End_sub ' ------------------------------------------------------------------------------ ' Ecriture de sa valeur dans une cellule Sub WRITE_CELL_VALUE(n%) print_target_is PictCell%(n%) print_locate 6,4 print PLATEAU$(n%) End_sub ' ------------------------------------------------------------------------------ ' Inserer une lettre sur le plateau Sub INSERT_LETTER(C%,L$) PLATEAU$(C%) = L$ 2d_target_is PictCell%(C%) 2d_pen_color 140,190,230 2d_rectangle 0,0,30,40 print_target_is PictCell%(C%) print_locate 6,4 print L$ End_sub ' ------------------------------------------------------------------------------ ' Cellule sélectionné Sub SELECTED_CELL(n%) COLOR_ONE_CELL(SELCELL%,255,255,170) if PLATEAU$(SELCELL%)<>"" WRITE_CELL_VALUE(SELCELL%) end_if if TryNumber%=1 if n%>0 and n%<(Letters%+1) SELCELL%=n% COLOR_ONE_CELL(SELCELL%,255,186,0) if PLATEAU$(SELCELL%)<>"" WRITE_CELL_VALUE(SELCELL%) end_if end_if else if n%>((TRYNUMBER%-1)*LETTERS%) and n%<(TRYNUMBER%*LETTERS%)+1 SELCELL%=n% COLOR_ONE_CELL(SELCELL%,255,186,0) if PLATEAU$(SELCELL%)<>"" WRITE_CELL_VALUE(SELCELL%) end_if end_if end_if End_sub ' ------------------------------------------------------------------------------ ' Vérification de l'essai Sub VERIF_LINE(TN%) dim_local deb%,fin%,i%,x%,red%,green%,blue% off_key_down EditKeyBoard% Select TN% case 1 : deb% = 1 : fin% = deb%+(LETTERS%-1) case 2 : deb% = LETTERS%+1 : fin% = deb%+(LETTERS%-1) case 3 : deb% = (LETTERS%*2)+1 : fin% = deb%+(LETTERS%-1) case 4 : deb% = (LETTERS%*3)+1 : fin% = deb%+(LETTERS%-1) case 5 : deb% = (LETTERS%*4)+1 : fin% = deb%+(LETTERS%-1) case 6 : deb% = (LETTERS%*5)+1 : fin% = deb%+(LETTERS%-1) end_select for i%=deb% to fin% x%=x%+1 if PLATEAU$(i%) = mid$(WORD$,x%,1) COLOR_ONE_CELL(i%,190,235,190) if TRYNUMBER%<6 print_target_is PictCell%(i%+LETTERS%) print_locate 6,4 print PLATEAU$(i%) PLATEAU$(i%+LETTERS%) = PLATEAU$(i%) end_if VERIF% = VERIF%+1 else COLOR_ONE_CELL(i%,255,255,255) end_if WRITE_CELL_VALUE(i%) next i% if VERIF% = len(WORD$) file_load PictResult%,ImgResultWin$ INITIALISE_GAME() if WORDNUM% = 8 caption Alph%(4),"" color PictGame%,240,240,240 GAMEONOFF% = 0 else NEWWORD() end_if else if TRYNUMBER%<6 VERIF% = 0 TRYNUMBER% = TRYNUMBER%+1 COLOR_ACTIVELINE(TRYNUMBER%) SELCELL% = ((TRYNUMBER%-1)*LETTERS%)+1 SELECTED_CELL(SELCELL%) else file_load PictResult%,ImgResultLoose$ caption Alph%(2),"Le mot à trouver était : " caption Alph%(3),WORD$ INITIALISE_GAME() if WORDNUM% = 8 caption Alph%(4),"" color PictGame%,240,240,240 GAMEONOFF% = 0 else NEWWORD() end_if end_if end_if on_key_down EditKeyBoard%,KDOWN End_sub ' ------------------------------------------------------------------------------ ' Initialisation du jeu Sub INITIALISE_GAME() dim_local i% for i%=1 to 60 if object_exists(PictCell%(i%))=1 2d_target_is PictCell%(i%) 2d_pen_color 140,190,230 2d_fill_color 255,255,255 2d_rectangle 0,0,30,40 2d_fill_off PLATEAU$(i%)="" end_if next i% WORD$ = "" TRYNUMBER% = 1 SELCELL% = 1 VERIF% = 0 pause 3000 color PictResult%,240,240,240 caption Alph%(2),"" caption Alph%(3),"" End_sub ' ------------------------------------------------------------------------------ ' Nouveau mot Sub NEWWORD() WORDNUM% = WORDNUM%+1 caption Alph%(4),str$(WORDNUM%)+"/8" WORD$ = SELECTWORD$(LETTERS%) COLOR_ACTIVELINE(TRYNUMBER%) SELECTED_CELL(SELCELL%) INSERT_LETTER(1,left$(WORD$,1)) SELECTED_CELL(SELCELL%+1) End_sub ' ============================================================================== ' FONCTIONS ' ============================================================================== Fnc SELECTWORD$(LETTERS%) dim_local s% s% = count(Dico%) s% = int(rnd(s%))+1 result item_read$(Dico%,s%) End_fnc
Je viens de me rendre compte que j'ai eu des soucis lors de la transformation des listes de mots entre utf-8 et ansi. certains ont des '?' à la place de certaines lettres. Je vais retravailler mes listes de mots.
Dernière édition par Yannick le Dim 15 Sep 2019 - 18:09, édité 1 fois | |
|