Skip to content
Snippets Groups Projects
Commit 30ed2d2b authored by Garance Guey's avatar Garance Guey
Browse files

upadate graphic

parent 3573d701
No related branches found
No related tags found
No related merge requests found
......@@ -10,6 +10,8 @@
<option value="E501" />
<option value="W29" />
<option value="E501" />
<option value="W29" />
<option value="E501" />
</list>
</option>
</inspection_tool>
......
from tkinter import *
from game2048.grid_2048 import *
# DICTIONNAIRE
TILES_BG_COLOR = {0: "#9e948a", 2: "#eee4da", 4: "#ede0c8", 8: "#f1b078", \
16: "#eb8c52", 32: "#f67c5f", 64: "#f65e3b", \
128: "#edcf72", 256: "#edcc61", 512: "#edc850", \
1024: "#edc53f", 2048: "#edc22e", 4096: "#5eda92", \
8192: "#24ba63"}
TILES_FG_COLOR = {0: "#776e65", 2: "#776e65", 4: "#776e65", 8: "#f9f6f2", \
16: "#f9f6f2", 32: "#f9f6f2", 64: "#f9f6f2", 128: "#f9f6f2", \
256: "#f9f6f2", 512: "#f9f6f2", 1024: "#f9f6f2", \
2048: "#f9f6f2", 4096: "#f9f6f2", 8192: "#f9f6f2"}
TILES_FONT = {"Verdana", 40, "bold"}
#FIN DICTIONNAIRE
#FONCTIONS
def graphical_inti():
game_2048=Tk()
fenetre=Toplevel()
fenetre.title("2048")
game_2048.title("2048")
game_2048["bg"]="pink"
return(game_2048)
#attention il faut toujours faire game_2048.mainloop() à la fin du programme
def create_empty_grid():
list_tuile=[]
for ligne in range (4):
list_tuile.append([])
for colonne in range (4):
list_tuile[ligne].append(Frame(game_2048,borderwidth=2, relief="solid",height = 100, width = 100,bg=TILES_BG_COLOR[0]))
list_tuile[ligne][colonne].grid(row=ligne,column=colonne)
return(list_tuile)
#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=
#FIN FONCTION
#EXECUTION
game_2048=graphical_inti()
grid_game=init_game()
grid_size=4
background=Frame(game_2048)
graphical_grid=[]
graphical_grid=create_empty_grid()
game_2048.mainloop()
File added
No preview for this file type
No preview for this file type
......@@ -58,7 +58,7 @@ def grid_add_new_tile(grid):
#attention, la fonction modifie la liste passée en argument !
return grid
def init_game(n):
def init_game(n=4):
grid = create_grid(n)
for new_tile in range(2):
grid = grid_add_new_tile(grid)
......@@ -204,7 +204,6 @@ def list_move_possible (grid):
return(list_final)
<<<<<<< HEAD
def random_play():
#on suppose que le jeu par defaut comprend une grille de 4x4
......@@ -230,5 +229,3 @@ def random_play():
return()
#TEST random_play()
=======
>>>>>>> 15883ac11a1d5e067e173c9ddba3c0e80ca1d0df
......@@ -53,3 +53,4 @@ def game_play():
print ("YOU FAIL, TRY AGAIN")
return
game_play()
from tkinter import *
"""window=Tk()
label_field = Label(window,text="Hello World !")
label_field.pack(fill=BOTH)
window.mainloop()"""
#disposition :
# dans .pack
#placement cardinal : side =(Tkinter.TOP, Tkinter.LEFT, Tkinter.RIGHT, Tkinter.BOTTOM
# grosseur de la fenetre : fill= X,Y,BOTH
#acction
#les boutons :
#Les boutons (Button) sont des widgets sur lesquels on peut cliquer et qui peuvent déclencher des actions ou commandes.
"""def write_text():
print("Hello CentraleSupelec")
root = Tk()
frame =Frame(root)
frame.pack()
button = Button(frame,
text="QUIT",
activebackground = "blue",
fg="red",
command=quit)
button.pack(side=LEFT)
slogan = Button(frame,
fg="blue",
text="Hello",
command=write_text)
slogan.pack(side=LEFT)
root.mainloop()"""
"""from tkinter import Tk, StringVar, Label, Entry, Button
from functools import partial
def update_label(label, stringvar):
#Met à jour le texte d'un label en utilisant une StringVar.
text = stringvar.get()
label.config(text=text)
stringvar.set('merci')
root = Tk()
text = StringVar(root)
label = Label(root, text='Your name')
entry_name = Entry(root, textvariable=text)
button = Button(root, text='clic',
command=partial(update_label, label, text))
label.grid(column=0, row=0)
entry_name.grid(column=0, row=1)
button.grid(column=0, row=2)
root.mainloop()"""
"""from tkinter import Tk, Label, Frame
root = Tk()
f1 = Frame(root, bd=1, relief='solid')
Label(f1, text='je suis dans F1').grid(row=0, column=0)
Label(f1, text='moi aussi dans F1').grid(row=0, column=1)
f1.grid(row=0, column=0)
Label(root, text='je suis dans root').grid(row=1, column=0)
Label(root, text='moi aussi dans root').grid(row=2, column=0)
root.mainloop()"""
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment