fromtimeimportsleepfromionimport*fromkandinskyimport*"""try:
get_keys()
color_pions = ((192, 53, 53), (255, 183, 52)) + color_pions
except:
color_pions = ((255, 183, 52), (192, 53, 53)) + color_pions"""color_pions=((148,113,222),(192,53,53),(255,183,52),(242,242,242))plateau=int("2"*20+"3"*10+"1"*20)fill_rect(0,200,320,22,(148,113,222))lettres=(32032318,33095217,18732593,33061407,33061951)defaffiche_lettres(x_start,y_start,l=lettres):temp_y=y_startforlettreinlettres:pos=0forpixelinstr(bin(lettre))[2:]:ifpos==20:pos=0y_start+=4ifpixel=='1':fill_rect(x_start+pos,y_start,4,4,(128,206,225))pos+=4x_start+=25y_start=temp_ydraw_string("Gameplay by nsi.xyz/dames",33,202,(255,255,255),color_pions[0])affiche_lettres(202,0)defpion(i,j,plat=plateau):position=i+j*5returnint(str(plat)[position])"""def create_plateau(): # Crée un plateau en graphique 10x10 avec comme point de départ le point de coordonnées (10, 20) et avec chaque carré de taille 20x20
for j in range(10, 211, 20):
for x in range(20, 221, 1):
set_pixel(x, j, (0, 0, 0))
for i in range(20, 221, 20):
for y in range(10, 211, 1):
set_pixel(i, y, (0, 0, 0))"""defdecalage(ord_pion):returnint(notord_pion%2)defrempli_pion(coord_pion,couleur):fill_rect(decalage(coord_pion[1])*20+coord_pion[0]*40,coord_pion[1]*20,20,20,couleur)definit_pions():color_temp_pion=(0,0,0)forjinrange(10):foriinrange(5):ifpion(i,j)==3:color_temp_pion=color_pions[3]ifpion(i,j)==2:color_temp_pion=color_pions[1]ifpion(i,j)==1:color_temp_pion=color_pions[0]else:# si c'est une dame
passrempli_pion((i,j),color_temp_pion)defbouge_pion(coord_pion,new_coord):rempli_pion(coord_pion,color_pions[3])rempli_pion(new_coord,color_pions[0])defallume_pion(coord_pion):rempli_pion(coord_pion,color_pions[2])defeteint_pion(coord_pion):rempli_pion(coord_pion,color_pions[0])defchoix(liste_choix):id_choix=0whilenotkeydown(4):# tant que ok n'est pas appuyé
allume_pion(liste_choix[id_choix])ifkeydown(0):# touche gauche
sleep(0.25)eteint_pion(liste_choix[id_choix])ifid_choix==0:id_choix=len(liste_choix)-1else:id_choix-=1elifkeydown(3):# touche droite
sleep(0.25)eteint_pion(liste_choix[id_choix])ifid_choix==len(liste_choix)-1:id_choix=0else:id_choix+=1returnliste_choix[id_choix]defest_deplacable(coord_pion:tuple):print(coord_pion)pass"""couleur_pion = int(plateau[coord_pion[0]][coord_pion[1]])
if couleur_pion == 1:
return plateau[coord_pion[0]+1][coord_pion[1]-1] == '0' and plateau[coord_pion[0]+1][coord_pion[1]+1] == '0'
elif couleur_pion == 2:
return plateau[coord_pion[0]-1][coord_pion[1]-1] == '0' and plateau[coord_pion[0]-1][coord_pion[1]+1] == '0'"""defchoix_pion():temp_pions_joueur=[]forjinrange(10):foriinrange(5):ifpion(i,j)==1:temp_pions_joueur+=[(i,j)]temp_pion=choix(temp_pions_joueur)whilenotest_deplacable(temp_pion):init_pions()# refresh le plateau
temp_pion=choix(temp_pions_joueur)returntemp_piondefmove_possible_pion_blanc(coord_pion):print(coord_pion)passdefchoix_deplacement_pion(coord_pion):# noinspection PyTypeChecker
choix(move_possible_pion_blanc(coord_pion))returnTrueinit_pions()print(choix_pion())
During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:
Ensure the proper functioning of the site (essential cookies); and
Track your browsing to send you personalized communications if you have created a professional account on the site and can be contacted (audience measurement cookies).
With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.