Jicehel
Nombre de messages : 5947 Age : 51 Localisation : 77500 Date d'inscription : 18/04/2011
| Sujet: Re: Yamic Mar 9 Aoû 2011 - 12:22 | |
| Voilà, j'ai repris mon source et j'ai terminé de le modifier, le but des modifs est principalement de diminuer le nombre de lignes pour ceux qui aiment bien travailler sur un source imprimé ... En plus le fait de reprendre le programme me permet de le comprendre complétement même si il était déjà très bien commenté Source: - Code:
-
' Version 1.2 du programme Yamic créé par Polaris le 27/07/2011 ' Programme en langage Panoramic ' Modifié par Jicehel le 09/08/11 pour diminuer le nombre de lignes ' ' ***********************************************************Déclaration des étiquettes label restart_game, init_lock, clear_yamic, show_stat, help_print, hide_stat, check_stat label add_stat, high_score, reset_all_dice, update_score, On_Click_Score label calculate_Nb, calculate_BRELAN, calculate_CARRE, calculate_FULL, calculate_PETITE label calculate_GRANDE, calculate_YAMIC,calculate_CHANCE label draw_table, init_score_result, init_dice, sort_dice, look_for_suite, end_game, new_game label On_Click_Button_roll, On_Click_Cadenas, On_Click_Quit
' ************************************************************Déclaration des variables dim as%,deux%,trois%,quatre%,cinq%,six%,selected_score%(12),add_dice, clique dim i,j,x,y,temp$, select_score,turn_played,dice_value,dice_result%(4),dice_state%(4) dim score_result%(18),figure_dice%(4) dim stat_as%,stat_deux%,stat_trois%,stat_quatre%,stat_cinq%,stat_six%,stat_on%
' ************************************************************Déclaration des constantes dim dice_y,dice_x,lock_x,lock_y,score_select_y,score_select_x,locate_xsl dim locate_ysl,locate_xsr,locate_ysr,score_label$(18),dice_mini_x,dice_mini_y dim help_bulb_x,stat_y%
' ****************************************************Initialisation du texte des scores Data "Total des AS","Total des DEUX","Total des TROIS","Total des QUATRE","Total des CINQ","Total des SIX" Data "TOTAL","PRIME DE DES","TOTAL SUPERIEUR","Brelan","Carré","Full","Petite suite" Data "Grande suite","Yamic","Chance", "Prime Yamic","TOTAL INFERIEUR","TOTAL GENERAL" for i = 0 to 18: read temp$ : score_label$(i)= temp$ : next i
' ******************************************************Initialisation des variables dice_mini_y=460 : stat_on%=0 :score_select_y=55 :score_select_x=650 :help_bulb_x=710 add_dice=0 : select_score=0 : turn_played=0 : dice_X=50 : dice_y=60 lock_x=50 : lock_y=140: locate_xsl=450 : locate_ysl=60 :locate_xsr=600 :locate_ysr=60 for i=0 to 10 : selected_score%(i)=0 : next i
' *****************************************************Création des objets principaux
left 0,100 : top 0,100 : width 0,800 : height 0,600 : caption 0,"YAMIC" : color 0,63,138,63 : border_hide 0 list 70 : left 70,1 : top 70,1 :width 70,1 : height 70,1 : color 70,63,138,63 : ' Liste pour trier les dés pour les figures list 90 : left 90,1 : top 90,1: width 90,1 : height 90,1 : color 90,63,138,63 : ' Liste pour trier les dés pour la suite list 300 : left 300,1 : top 300,1 : width 300,1 : height 300,1 :color 300,63,138,6 : ' Liste pour les stats picture 61 : width 61,800 :height 61,600 : color 61,63,138,63 : ' Création du fond du jeu picture 63 : width 63,343 : height 63,200 : top 63,300 : left 63,52 :file_load 63,"img/yamic.bmp" : ' STATS picture 80 : top 80,230 : left 80,50 : width 80,350 : height 80,60 :file_load 80,"img/roll_button.bmp": ' Image / bouton pour lancer les dés on_click 80,On_Click_Button_Roll : ' Si on clic dessus, traiter le lancé
' *******************************************************************************Sons sound 500 : file_load 500,"snd/dice_roll_1.wav" : ' Son quand on lance les dés sound 510 : file_load 510,"snd/lock_dice.wav" : ' Son quand on verouille un dé sound 520 : file_load 520,"snd/unlock_dice.wav" : ' Son quand on le déverouille
' ********************************************************On termine de tout afficher for i=0 to 5 picture 200+i : left 200+i,86+50*i : top 200+i,dice_mini_y : width 200+i,25 : height 200+i,25 file_load 200+i,"img/dice_mini" +str$(i+1) +".bmp": hide 200 +i picture 20+i : top 20+i,score_select_y + 25*i : left 20+i,score_select_x : width 20+i,22 : height 20+i,22 file_load 20+i,"img/choice_yes.bmp" : On_click 20+i, On_Click_Score : REM SCORE DES DES 1 à 6 picture 27+i : top 27+i,score_select_y+225 + 25*i : left 27+i,score_select_x : width 27+i,22 : height 27+i,22 file_load 27+i,"img/choice_yes.bmp" : On_click 27+i, On_Click_Score : REM SCORE DES FIGURES (Brelan, carré, full, Petite, Grandes, YAMIC next i
picture 26 : top 26,score_select_y+175 : left 26,score_select_x : width 26,22 : height 26,22 : color 26,63,138,63 : ' Espace picture 33 : top 33,score_select_y+375 : left 33,score_select_x :width 33,22 :height 33,22 file_load 33,"img/choice_yes.bmp": on_click 33,On_Click_Score : REM Boutton Chance picture 34 : top 34,score_select_y+400 : left 34,score_select_x : width 34,22 :height 34,22 :color 34,63,138,63 : ' Espace
for i = 0 to 4 picture 1+i : left 1+i,dice_x + 70*i : top 1+i,dice_y : width 1+i,62 : height 1+i,62 : REM DICES picture 6+i : left 6+i,lock_x + 70*i : top 6+i,lock_y : width 6+i,62 : height 6+i,62 on_click 6+i,On_Click_Cadenas : REM LOCKS next i
' *************************************************************************Bouton quitter picture 11 : hint 11,"quitter" : left 11,40 :top 11,520 : width 11,32 :height 11,32 file_load 11,"img/exit1.bmp" : on_click 11,On_Click_Quit
' *****************************************************************Bouton Nouvelle partie picture 12 : hint 12,"nouveau jeu" : left 12,90 : top 12,520 : width 12,32 :height 12,32 file_load 12,"img/new_game.bmp" : on_click 12,new_game
' **************************************************************Bouton afficher les stats picture 13 : hint 13,"statistiques" : left 13,140 : top 13,520 :width 13,32 :height 13,32 file_load 13,"img/stat.bmp" :on_click 13,check_stat
' **********************************************************Les boutons "ampoules" d'aide For i = 0 to 14 picture 40+i : top 40+i,score_select_y+2+i*25 : left 40+i,help_bulb_x : width 40+i,22 : height 40+i,20 file_load 40+i,"img/help_bulb.bmp" : on_click 40+i,help_print Next i
' *************************************************************************************** ' Programme principal ' ***************************************************************************************
gosub init_score_result gosub draw_table end
' *************************************************************************************** ' Procédures ' **************************************************************Initialisation des scores init_score_result:
2d_target_is 61 : print_target_is 61 for i=0 to 18 score_result%(i)=0 : print_locate locate_xsr,locate_ysr: 2d_fill_color 63,138,63 : print score_result%(i) locate_ysr=locate_ysr+25 next i return
' ***************************************************************Dessine la table de jeu draw_table:
gosub init_dice
rem ---------cadenas for i=0 to 4 dice_state%(i)=0 next i for i=6 to 10 for j=0 to 4 if dice_state%(j)=0 file_load i,"img/lock_open.bmp" else file_load i,"img/lock_close.bmp" end_if next j next i
rem ---------feuille de score 2d_target_is 61 : print_target_is 61 for i= 0 to 18 print_locate locate_xsl,locate_ysl: 2d_fill_color 63,138,63 : print score_label$(i) locate_ysl=locate_ysl+25 next i
for y =54 to 535 step 25 2d_line 451,y,750,y next y
rem -------- table de jeu
2d_fill_color 0,0,0 2d_rectangle 10,10,31,31 : 2d_rectangle 769,10,790,31 : 2d_rectangle 10,569,31,590 : 2d_rectangle 769,569,790,590 2d_line 40,20,760,20 : 2d_line 21,41,21,559: 2d_line 40,579,760,579 : 2d_line 779,40,779,559 return
' ***********************************Traitement d'un clic sur le bouton de lancer de dés On_Click_Button_Roll: clear 90 : hide 80 if active(80)=1 then play_wait 500 for i= 1 to 5 if dice_state%(i-1)=0 dice_value=int(rnd(6))+1 dice_result%(i-1)=dice_value file_load i,"img/dice_"+ str$(dice_value)+".bmp" end_if item_add 90,dice_result%(i-1) next i sort 90 : show 80 : turn_played=turn_played+1 : select_score=1 : gosub add_stat if turn_played >= 3 then inactive 80 if stat_on%=1 then gosub show_stat return
' ********************Traitement de la bascule (Ouvert/Fermé) lors du clic sur un cadenas On_Click_Cadenas: Clique = Number_click if turn_played>=1 and turn_played <=2 if dice_state%(Clique - 6)=0 dice_state%(Clique - 6)=1:file_load Clique,"img/lock_close.bmp":play_wait 510 else dice_state%(Clique - 6)=0:file_load Clique,"img/lock_open.bmp":play_wait 520 end_if end_if return
' *********************************************************************QUIT GAME On_Click_Quit: if message_confirmation_yes_no("Voulez-vous vraiment quitter?")=1 then terminate return
' ******************************************************************SELECT_SCORE On_Click_Score:
Clique = Number_Click if clique > 19 and clique < 34 if Clique < 26 selected_score%(Clique-20)=1 else if clique > 26 selected_score%(Clique-21)=1 end_if end_if
if select_score=1 if Clique > 26 and Clique < 32 then gosub sort_dice file_load Clique,"img/choice_no.bmp" select_score=0 active 80:turn_played=0 inactive Clique gosub init_dice select Clique case 20 : gosub calculate_Nb case 21 : gosub calculate_Nb case 22 : gosub calculate_Nb case 23 : gosub calculate_Nb case 24 : gosub calculate_Nb case 25 : gosub calculate_Nb case 26 : REM rien case 27 : gosub calculate_BRELAN case 28 : gosub calculate_CARRE case 29 : gosub calculate_FULL case 30 : gosub calculate_PETITE case 31 : gosub calculate_GRANDE case 32 : gosub calculate_YAMIC case 33 : gosub calculate_CHANCE end_select end_if end_if return
'****************************************************************CALCULATE_SCORE calculate_Nb: Clique = Clique - 19 for i=0 to 4 if dice_result%(i) = Clique then add_dice=add_dice + Clique next i score_result%(Clique - 1)=add_dice : add_dice=0 gosub update_score return
calculate_BRELAN: if figure_dice%(0)=figure_dice%(1) and figure_dice%(1)=figure_dice%(2) for i=0 to 4 : score_result%(9)=score_result%(9)+dice_result%(i) : next i goto update_score end_if if figure_dice%(1)=figure_dice%(2) and figure_dice%(2)=figure_dice%(3) for i=0 to 4 : score_result%(9)=score_result%(9)+dice_result%(i) : next i goto update_score end_if if figure_dice%(2)=figure_dice%(3) and figure_dice%(3)=figure_dice%(4) for i=0 to 4 : score_result%(9)=score_result%(9)+dice_result%(i) : next i goto update_score end_if return
calculate_CARRE: if figure_dice%(0)=figure_dice%(1) and figure_dice%(1)=figure_dice%(2)and figure_dice%(2)=figure_dice%(3) for i=0 to 4 : score_result%(10)=score_result%(10)+dice_result%(i) : next i goto update_score end_if if figure_dice%(1)=figure_dice%(2) and figure_dice%(2)=figure_dice%(3)and figure_dice%(3)=figure_dice%(4) for i=0 to 4 : score_result%(10)=score_result%(10)+dice_result%(i) : next i end_if goto update_score return
calculate_FULL: if figure_dice%(0)=figure_dice%(1) and figure_dice%(2)=figure_dice%(3)and figure_dice%(3)=figure_dice%(4) score_result%(11)=25 goto update_score end_if if figure_dice%(0)=figure_dice%(1)and figure_dice%(1)=figure_dice%(2) and figure_dice%(3)=figure_dice%(4) score_result%(11)=25 goto update_score end_if goto update_score return
calculate_PETITE: gosub look_for_suite if (as%=1) and (deux%=1) and (trois%=1) and (quatre%=1) then score_result%(12)=30 : goto update_score if (deux%=1) and (trois%=1) and (quatre%=1) and (cinq%=1) then score_result%(12)=30 : goto update_score if (trois%=1) and (quatre%=1) and (cinq%=1) and (six%=1) then score_result%(12)=30 goto update_score return
calculate_GRANDE: gosub look_for_suite if (as%=1) and (deux%=1) and (trois%=1) and (quatre%=1) and (cinq%=1) then score_result%(13)=40: goto update_score if (deux%=1) and (trois%=1) and (quatre%=1) and (cinq%=1) and (six%=1)then score_result%(13)=40 goto update_score return
calculate_YAMIC: if dice_result%(0)=dice_result%(1) and dice_result%(1)=dice_result%(2) and dice_result%(2)=dice_result%(3) and dice_result%(3)=dice_result%(4) score_result%(14)=50 else score_result%(14)=0 end_if goto update_score return
calculate_CHANCE: score_result%(15)=dice_result%(0)+dice_result%(1)+dice_result%(2)+dice_result%(3)+dice_result%(4) gosub update_score return
'*******************************************************************UPDATE_SCORE update_score:
' partie_superieure score_result%(6)=0 for i=0 to 5 : score_result%(6)=score_result%(6)+score_result%(i) : next i
' prime haut for i=0 to 5 if selected_score%(i) = 1 if score_result%(6) < 63 file_load 26,"img/choice_no.bmp" else score_result%(6) >= 63 score_result%(7) = 35 file_load 26,"img/prime.bmp" end_if end_if next i
' total haut score_result%(8)=score_result%(6)+score_result%(7)
' partie_inferieure if selected_score%(11)=1 and score_result%(14)=50 file_load 34,"img/prime.bmp": score_result%(16)=100 else if selected_score%(11)=1 and score_result%(14)=0 file_load 34,"img/choice_no.bmp" end_if end_if
' total bas score_result%(17)=0 for i = 9 to 16 score_result%(17)=score_result%(17)+score_result%(i) next i score_result%(18)=score_result%(17)+score_result%(8)
' affichage_score locate_xsr=600:locate_ysr=60 2d_target_is 61 : print_target_is 61 for i=0 to 18 2d_fill_color 63,138,63 : print_locate locate_xsr,locate_ysr print str$(score_result%(i))+" " locate_ysr=locate_ysr+25 next i clear 70 : gosub reset_all_dice j= 1 : for i=0 to 12 : if selected_score%(i)=0 then j=0 : next i if j=1 then goto end_game return
' ********************************************************RESET_DICE_END_OF_TURN reset_all_dice: for j=0 to 4 select dice_state%(j) case 1:dice_state%(j)=0:file_load j+6,"img/lock_open.bmp":play 520 end_select dice_result%(j)=0 next j return
'**********************************************************************INIT_DICE init_dice: For j = 1 to 5 : file_load j,"img/dice_p.bmp" : next j return
'**********************************************************************INIT_LOCK init_lock: For i = 6 to 10 : file_load i,"img/lock_open.bmp" : next i return
' *********************************************************************SORT_DICE sort_dice: for i= 0 to 4 : item_add 70,dice_result%(i) : next i sort 70 for i=1 to 5 : figure_dice%(i-1)= item_read$(70,i) : next i return
' ****************************************************************LOOK_FOR_SUITE look_for_suite: as%=0:deux%=0:trois%=0:quatre%=0:cinq%=0:six%=0 for i=1 to 5 select val(item_read$(90,i)) case 1: as%=1 case 2: deux%=1 case 3: trois%=1 case 4: quatre%=1 case 5: cinq%=1 case 6: six%=1 end_select next i
return
' **********************************************************************END_GAME end_game: if message_confirmation_yes_no("Partie terminée, voulez-vous rejouer?")=1 goto restart_game end_if return
' ********************************************************************HIGH_SCORE high_score: return
' **********************************************************************ADD_STAT add_stat: clear 300 for i=0 to 4 select dice_result%(i) case 1 : if dice_state%(i)=0 then stat_as%=stat_as%+1 case 2 : if dice_state%(i)=0 then stat_deux%=stat_deux%+1 case 3 : if dice_state%(i)=0 then stat_trois%=stat_trois%+1 case 4 : if dice_state%(i)=0 then stat_quatre%=stat_quatre%+1 case 5 : if dice_state%(i)=0 then stat_cinq%=stat_cinq%+1 case 6 : if dice_state%(i)=0 then stat_six%=stat_six%+1 end_select next i item_add 300,stat_as% : item_add 300,stat_deux% : item_add 300,stat_trois% item_add 300,stat_quatre% : item_add 300,stat_cinq% : item_add 300,stat_six% return
' *********************************************************************DRAW_STAT check_stat: if stat_on%=0 goto show_stat else goto hide_stat end_if
show_stat: hint 13,"hide stat" stat_y%=150 color 63,63,138,63 : 2d_target_is 63 : print_target_is 63 2d_fill_diagonal_down : 2d_fill_color 0,0,0 2d_rectangle 34,stat_y%,59,(stat_y%-(stat_as%*3)) 2d_rectangle 84,stat_y%,109,(stat_y%-(stat_deux%*3)) 2d_rectangle 134,stat_y%,159,(stat_y%-(stat_trois%*3)) 2d_rectangle 184,stat_y%,209,(stat_y%-(stat_quatre%*3)) 2d_rectangle 234,stat_y%,259,(stat_y%-(stat_cinq%*3)) 2d_rectangle 284,stat_y%,309,(stat_y%-(stat_six%*3)) for i=200 to 205 : show i : next i print_locate 34,185 : print stat_as% print_locate 84,185 : print stat_deux% print_locate 134,185: print stat_trois% print_locate 184,185: print stat_quatre% print_locate 234,185: print stat_cinq% print_locate 284,185: print stat_six% 2d_target_is 61 stat_on%=1 return
hide_stat: for i=200 to 205 : hide i : next i file_load 63,"img/yamic.bmp" hint 13,"show stat" stat_on%=0 return
help_print: for i=40 to 54 if clicked(i)=1 then j=i next i gosub clear_yamic print:print:print select j case 40 : print "Total des 1: Votre score sera égal au total des 1 de vos cinq dés." case 41 : print "Total des 2: Votre score sera égal au total des 2 de vos cinq dés." case 42 : print "Total des 3: Votre score sera égal au total des 3 de vos cinq dés." case 43 : print "Total des 4: Votre score sera égal au total des 4 de vos cinq dés." case 44 : print "Total des 5: Votre score sera égal au total des 5 de vos cinq dés." case 45 : print "Total des 6: Votre score sera égal au total des 6 de vos cinq dés" case 46 : print "PRIME DE DES: Cette prime est accordée si le TOTAL est égal ou plus" print "grand que 63 points." case 47 : print "BRELAN: Pour réaliser un brelan il faut avoir trois dés identiques, le" print "score sera alors augmenté de la somme des cinq dés." case 48 : print "CARRE: Pour le carré, il faut avoir quatre dés identiques, le " print "score sera alors augmenté de la somme des cinq dés." case 49 : print "FULL: Pour réaliser le full il faut que trois dés est la même valeur et que" print "les deux autres dés soient identiques, le score sera augmenté de 25 points." case 50 : print "PETITE SUITE: Pour réaliser une petite suite il faut avoir quatre dés qui" print "se suivent soit:": print : print "- 1,2,3,4" : print "- 2,3,4,5" : print "- 3,4,5,6" print : print "Le score sera alors augmenté de 30 points." case 51 : print "GRANDE SUITE: Pour réaliser une grande suite il faut avoir cinq dés qui" print "se suivent soit:": print : print "- 1,2,3,4,5": print "- 2,3,4,5,6" print : print "Le score sera alors augmenté de 40 points." case 52 : print "YAMIC: Pour réaliser un yamic il faut avoir cinq dés de la même valeur," print "le score sera alors augmenté de 50 points." case 53 : print "CHANCE: La chance cumelera la somme de vos cinq dés. Aucune " print "condition particulière n'est requise." case 54 : print "PRIME YAMIC: Une prime de 100 points vous sera donnée si vous" print "réussissez le YAMIC" end_select return
new_game: if message_confirmation_yes_no("nouveau jeu?")=1 goto restart_game end_if return
restart_game: ' init suite,dice_value,add_dice,stat as%=0:deux%=0:trois%=0:quatre%=0:cinq%=0:six%=0:dice_value=0:add_dice=0 select_score=0:turn_played=0 stat_as%=0:stat_deux%=0:stat_trois%=0:stat_quatre%=0:stat_cinq%=0:stat_six%=0:stat_on%=0 ' init selected score for i=0 to 12 : selected_score%(i)=0 : next i ' init for i=0 to 4 : dice_result%(i)=0:dice_state%(i)=0:figure_dice%(i)=0 : next i ' init score_result for i=0 to 18 : score_result%(i)=0 : next i ' init score_selected_pic for i= 20 to 25 : active i : file_load i,"img/choice_yes.bmp" : next i for i= 27 to 33 : active i : file_load i,"img/choice_yes.bmp" : next i file_load 26,"img/choice_blank.bmp" : file_load 34,"img/choice_blank.bmp" gosub hide_stat gosub init_dice gosub init_lock gosub reset_all_dice gosub update_score
return
clear_yamic: color 63,63,138,63 : print_target_is 63 : 2d_target_is 63 2d_fill_color 63,138,63 for i=200 to 205 : hide i : next i stat_on%=0 return | |
|