Marc
Nombre de messages : 2466 Age : 63 Localisation : TOURS (37) Date d'inscription : 17/03/2014
| Sujet: Taquin II Le Retour Mar 24 Nov 2015 - 0:55 | |
| Bonsoir à tous, Voici la version 2 de mon Taquin (pousse-pousse). Une douzaine de thèmes dont du Romain et du binaire... croissant / décroissant... Bref, de quoi s'occuper quand on ne sait plus quoi programmer ! - Code:
-
' ____________________________________ ' ' Pousse-Pousse v2 ' Marc37 24/11/2015 ' http://panoramic.1fr1.net/ ' ____________________________________
DIM i%, J%, K%, L%, x%, y% DIM A%(25) DIM B$(25), C$(25), D$(25), E$(26), F$(25), G$(25) DIM tirage%, soluble%, swap%, Theme% DIM Case_Vide%, X_casevide%, y_casevide%
LABEL Jeu LABEL Melange LABEL Choix_Theme
Datas()
Mask()
Random_Theme()
GOSUB Choix_Theme
END ' ------------------------------------------------------------------------------ Jeu: l% = NUMBER_CLICK x%=INT((l%-1)/5) y%=(l%-1)-(x%*5) X_casevide% = INT((Case_Vide% -1)/5) y_casevide%=(Case_Vide%-1)-(x_casevide%*5) IF y% = y_casevide% OR x%=x_casevide% IF ABS(Y%-y_casevide%) = 1 OR ABS(x%-x_casevide%)=1 a%(Case_Vide%)=a%(l%): CAPTION Case_Vide%, b$(a%(Case_Vide%)) A%(l%)=25 Case_Vide%=l% CAPTION l%, "" END_IF END_IF verif_gagne() RETURN ' ------------------------------------------------------------------------------ SUB Tirage_aleatoire() CAPTION 104, "" FOR i% = 1 to 25 : A%(i%)=0 : NEXT i% FOR i% = 1 TO 24 Tirage% = INT(1+RND(24)) FOR j%=1 TO 24 IF Tirage% = a%(j%) THEN EXIT_FOR NEXT j% IF j% = 25 a%(i%)=Tirage% CAPTION i%, b$(a%(i%)) ELSE I% = I% - 1 END_IF NEXT i% A%(25)=25 Case_vide% = A%(25) CAPTION 25,"" Swap%=0 FOR i%=1 TO 23 FOR j%=i%+1 TO 24 IF a%(i%)>a%(j%) THEN Swap% = Swap% + 1 NEXT j% NEXT i% Soluble% = 1 - bin_and(Swap%,1) IF Soluble% = 0 k%=a%(1) : a%(1)=a%(2) : a%(2)=k% CAPTION 1, b$(a%(1)) CAPTION 2, b$(a%(2)) END_IF verif_gagne() FOR i% = 1 to 25 : ON_CLICK i%, Jeu : NEXT i% END_SUB ' ------------------------------------------------------------------------------ SUB verif_gagne() FOR i% = 1 to 25 IF a%(i%) <> i% THEN EXIT_FOR NEXT i% IF i% = 26 THEN BEEP : CAPTION 102, "Gagné !" : ELSE : CAPTION 102, "" END_SUB ' ------------------------------------------------------------------------------ Melange: Tirage_aleatoire() RETURN ' ------------------------------------------------------------------------------ SUB Mask() WIDTH 0, 680 HEIGHT 0, 457 COLOR 0, 0,175,40 FONT_NAME 0, "arial" FONT_SIZE 0, 20 i% = 0 Theme% = 0 FOR k% = 1 TO 5 FOR j% = 1 TO 5 i% = i% + 1 BUTTON i% WIDTH i%, 60 HEIGHT i%, 60 LEFT i%, 60 * j% TOP i%, 60 * k% ON_CLICK i%, Jeu NEXT j% NEXT k%
BUTTON 100 TOP 100, 300 LEFT 100, 430 WIDTH 100, 170 HEIGHT 100, 40 FONT_SIZE 100, 18 CAPTION 100, "Mélange"
ALPHA 101 TOP 101, 80 LEFT 101, 430 FONT_ITALIC 101 CAPTION 101, "Jeu de Taquin"
ALPHA 102 TOP 102, 150 LEFT 102, 464 CAPTION 102, "Gagné !"
BUTTON 103 TOP 103, 240 LEFT 103, 430 WIDTH 103, 170 HEIGHT 103, 40 FONT_SIZE 103, 18 CAPTION 103, "Thème"
ALPHA 104 TOP 104, 370 LEFT 104, 100 FONT_SIZE 104, 18 FONT_ITALIC 104 CAPTION 104, "Modèle à reproduire !"
ON_CLICK 100, Melange ON_CLICK 103, Choix_theme END_SUB ' ------------------------------------------------------------------------------ Choix_theme: FOR i% = 1 to 25 : OFF_CLICK i% : NEXT i% Theme% = theme%+1 IF Theme% = 13 THEN Theme% = 1 SELECT Theme%
CASE 1 FOR i% = 1 to 25: FONT_SIZE i%,20 : NEXT i% FOR i% = 1 to 25: b$(i%)= i% : NEXT i%
CASE 2 FOR i% = 1 to 25: FONT_SIZE i%,20 : NEXT i% FOR i% = 1 to 24: b$(i%)= 25-i% : NEXT i%
CASE 3 FOR i% = 1 to 25: FONT_SIZE i%,14 : NEXT i% FOR i% = 1 to 24: b$(i%)= C$(i%) : NEXT i%
CASE 4 FOR i% = 1 to 25: FONT_SIZE i%,14 : NEXT i% FOR i% = 1 to 24: b$(i%)= C$(25-i%) : NEXT i%
CASE 5 FOR i% = 1 to 25: FONT_SIZE i%,12 : NEXT i% FOR i% = 1 to 24: b$(i%)= D$(i%) : NEXT i%
CASE 6 FOR i% = 1 to 25: FONT_SIZE i%,12 : NEXT i% FOR i% = 1 to 24: b$(i%)= D$(25-i%) : NEXT i%
CASE 7 FOR i% = 1 to 25: FONT_SIZE i%,20 : NEXT i% FOR i% = 1 to 24: b$(i%)= E$(i%) : NEXT i%
CASE 8 FOR i% = 1 to 25: FONT_SIZE i%,20 : NEXT i% FOR i% = 1 to 24: b$(i%)= E$(27-i%) : NEXT i%
CASE 9 FOR i% = 1 to 25: FONT_SIZE i%,20 : NEXT i% FOR i% = 1 to 24: b$(i%)= F$(i%) : NEXT i%
CASE 10 FOR i% = 1 to 25: FONT_SIZE i%,20 : NEXT i% FOR i% = 1 to 24: b$(i%)= F$(25-i%) : NEXT i%
CASE 11 FOR i% = 1 to 25: FONT_SIZE i%,20 : NEXT i% FOR i% = 1 to 24: b$(i%)= G$(i%) : NEXT i%
CASE 12 FOR i% = 1 to 25: FONT_SIZE i%,20 : NEXT i% FOR i% = 1 to 24: b$(i%)= G$(25-i%) : NEXT i%
END_SELECT
FOR i% = 1 to 24 CAPTION i%,b$(i%) NEXT i%
CAPTION 25, ""
CAPTION 102, ""
CAPTION 104, "Modèle à reproduire !"
RETURN ' ------------------------------------------------------------------------------ SUB Random_Theme()
Theme%=INT(RND(13))
END_SUB ' ------------------------------------------------------------------------------ SUB Datas() DATA I,II,III,IV,V,VI,VII,VIII,IX,X,XI,XII,XIII,XIV,XV,XVI,XVII,XVIII,IXX,XX,XXI,XXII,XXIII,XXIV,XXV DATA 00001,00010,00011,00100,00101,00110,00111,01000,01001,01010,01011,01100,01101,01110,01111,10000,10001,10010,10011,10100,10101,10110,10111,11000,11001 DATA A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z DATA 2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97 DATA 1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49 FOR i% = 1 to 25 : READ C$(i%) : NEXT i% FOR i% = 1 to 25 : READ D$(i%) : NEXT i% FOR i% = 1 to 26 : READ E$(i%) : NEXT i% FOR i% = 1 to 25 : READ F$(i%) : NEXT i% FOR i% = 1 to 25 : READ G$(i%) : NEXT i% END_SUB
Dernière édition par Marc37 le Sam 28 Nov 2015 - 14:06, édité 1 fois | |
|