From 0d17810a7c3223d2d96c91e0c220152ec867a477 Mon Sep 17 00:00:00 2001
From: Guey Garance <garance.guey@student-cs.fr>
Date: Thu, 15 Nov 2018 11:26:16 +0100
Subject: [PATCH] affichage grid

---
 game2048/2048_graphical.py                    |  33 +++++++++++++++++-
 game2048/__pycache__/grid_2048.cpython-36.pyc | Bin 5703 -> 5703 bytes
 game2048/grid_2048.py                         |  10 ++----
 3 files changed, 34 insertions(+), 9 deletions(-)

diff --git a/game2048/2048_graphical.py b/game2048/2048_graphical.py
index 3058cc3..287b228 100644
--- a/game2048/2048_graphical.py
+++ b/game2048/2048_graphical.py
@@ -42,6 +42,37 @@ def create_empty_grid():
 
 #ATTENTION lors de la création d'un frame, sa hauteur et sa largeur vaut 0 de base : modifier directement lors de la création par height= et width=
 
+def update_graphical_grid(grid_game):
+    #cette fonction ne marche que pour les grilles 4x4
+    list_tuile=[]
+    list_label=[]
+    for ligne in range (4):
+        list_tuile.append([])
+        list_label.append([])
+
+        #pour chaque ligne
+        for colonne in range (4):
+            #on liste les colonnes où il va y avoir des numéros
+            list_colonne_wt_label=[]
+            #on regarde la valeur de la tuile
+            value_tuile=grid_game[ligne][colonne]
+            #si la valeur est zero, il n'y a pas de label
+            if value_tuile==0 :
+                list_tuile[ligne].append(Frame(game_2048,borderwidth=2, relief="solid",height = 100, width = 100,bg=TILES_BG_COLOR[0]))
+            #sinon on dit crée un label et retenir sa position pour le positionner
+            else :
+                #création de la tuile
+                list_tuile[ligne].append(Frame(game_2048,borderwidth=2, relief="solid",height = 100, width = 100,bg=TILES_BG_COLOR[value_tuile]))
+                #création du label
+                list_label[ligne].append(Label(list_tuile[ligne][colonne],text=str(value_tuile),fg=TILES_FG_COLOR[value_tuile],bg=TILES_BG_COLOR[value_tuile],height = 5, width = 10,font=TILES_FONT))
+                #mémoire de sa position
+                list_colonne_wt_label.append(colonne)
+            #on positionne correctement le label
+            for lab in range (len(list_colonne_wt_label)):
+                list_label[ligne][lab].grid(row=ligne,column=list_colonne_wt_label[lab])
+            #on positionne correctement les tuiles
+            list_tuile[ligne][colonne].grid(row=ligne,column=colonne)
+    return(list_tuile)
 #FIN FONCTION
 
 
@@ -53,6 +84,6 @@ grid_size=4
 background=Frame(game_2048)
 graphical_grid=[]
 
-graphical_grid=create_empty_grid()
+graphical_grid=update_graphical_grid(grid_game)
 
 game_2048.mainloop()
diff --git a/game2048/__pycache__/grid_2048.cpython-36.pyc b/game2048/__pycache__/grid_2048.cpython-36.pyc
index ae72e820e766b62ac22f66b77ac41ebd7dc2c787..d3569437ff86da6f9ef6ba44cc4ac14b63314f4c 100644
GIT binary patch
delta 143
zcmX@Eb6khhn3tEU$Ng<|`$o>A?A&$?3=G8_3=9kmOq*}APh@2Dn4HbIlQC+tDpwL?
z<m3*nZH#f7?YVgv8Pg~G@T_Jmp8SKSgRx?BBkv+c#+uD4{H%<OvnOi_6f&-!JV)RV
z<GRW5g5```CtnxLW!yR0RVbZt&*Zg2KN$~gUM}3n$arzGndm2Gb}p{T+F~*QGb}Bq

delta 143
zcmX@Eb6khhn3tDJ%kXXVw2hoc*|}{Q7#NB<7#J8B7&qT!pUBAQHaVMfCu789Rjwq)
z@W~xq+Zbau+jH|UGNw-U;aSaCIQa)p2V>dhM&3n?j8&Ue_*oelXHM1<C}dnYd5*v#
z#x;}U1<M&XPrfdg%eZ~At57=QuE}eKeli}|yj-}Ck@5UwGtp1XY+Rg^wZ&ur^MfrK

diff --git a/game2048/grid_2048.py b/game2048/grid_2048.py
index aea1406..0a16a41 100644
--- a/game2048/grid_2048.py
+++ b/game2048/grid_2048.py
@@ -58,11 +58,9 @@ def grid_add_new_tile(grid):
     #attention, la fonction modifie la liste passée en argument !
     return grid
 
-<<<<<<< HEAD
-def init_game(n=4):
-=======
+
 def init_game(n = 4):
->>>>>>> 1faf1cea7fd45cb7d6a421ea0113d9508a596695
+
     grid = create_grid(n)
     for new_tile in range(2):
         grid = grid_add_new_tile(grid)
@@ -231,8 +229,4 @@ def random_play():
     else :
         print ("YOU FAIL, TRY AGAIN")
     return()
-<<<<<<< HEAD
 
-#TEST random_play()
-=======
->>>>>>> 1faf1cea7fd45cb7d6a421ea0113d9508a596695
-- 
GitLab