def draw_init():
	"""Affiche au début les éléments qui ne seront jamais effaces."""
	
	tk.rectangle(0, C.EXTRA_TOP, C.WIDTH, C.HEIGHT_TOTAL, "black", "black")
	tk.rectangle(0, 0, 0 + C.WIDTH, 0 + C.EXTRA_TOP, "black", "blue2", epaisseur=2)  #Le fond de la fenêtre
	tk.texte(C.WIDTH/2, 70/2, "Casse Brique", "firebrick1", police="fixedsys", ancrage="center", taille=42)
	tk.texte(C.WIDTH//7, 80, "Score: ", "green2", police="fixedsys", ancrage="center", taille=23)
	tk.texte(C.WIDTH//5*4, 80, "Temps: ", "green2", police="fixedsys", ancrage="center", taille=23)
def check_destroy(blocks_list):
    """Vérifie si la résistance d'une des briques est à 0, si oui la supprime de la liste.
		 Avec blocks_list, la liste contenant les coordonnées et résistance des briques. """

    i = 0
    while i < len(blocks_list):
        if blocks_list[i][4] == 0:
            b = blocks_list[i]
            tk.efface(b[5])
            tk.rectangle(b[0], b[1], b[2], b[3], "black",
                         "black")  #Pour repasser par dessus l'ancien block
            blocks_list.pop(i)
        else:
            i += 1
def draw_variable(change_list, **kwargs):
	"""Affiche certains objets du jeu en fonction de si ils ont ete modifies depuis la boucle d'avant.
	change_list de la forme ["balle", "score",], on utilisera ensuite les str pour acceder au kwargs."""
	
	if change_list == []:
		return
	for argument in change_list:
		if argument == "balle":
			tk.cercle(kwargs["balle"][0], kwargs["balle"][1], C.BALL_RADIUS, "red", "red", tag="balle")
		elif argument == "raquette":
			tk.rectangle(kwargs["raquette"][0], kwargs["raquette"][1], kwargs["raquette"][2], kwargs["raquette"][3], "green2", "green2", tag="raquette")
		elif argument == "blocs":
			for block in kwargs["blocs"]:
				color = C.COLOR_TUP[block[4]]
				efface_obj = tk.rectangle(block[0], block[1], block[2], block[3], "black", color)
				block[5] = efface_obj
		elif argument == "temps":
			tk.texte(C.WIDTH//5*4.6, 80, str(int(kwargs["temps"][0])), "green2", police="fixedsys", ancrage="center", taille=23, tag="inter_temps")
		elif argument == "score":
			tk.texte(C.WIDTH//7*1.8, 80, str(kwargs["score"]), "green2", police="fixedsys", ancrage="center", taille=23, tag="inter_score")
	return
예제 #4
0
def draw_init():
    """Affichage de la fenetre de menu(formes, images, texte)."""

    sixieme = C.HEIGHT_TOTAL // 6
    tk.rectangle(0, 0, C.WIDTH, sixieme * 2, "black", "blue2", epaisseur=2)

    tk.rectangle(0,
                 sixieme * 2,
                 C.WIDTH,
                 sixieme * 3,
                 "black",
                 "yellow",
                 epaisseur=2)
    tk.rectangle(0,
                 sixieme * 3,
                 C.WIDTH,
                 sixieme * 4,
                 "black",
                 "yellow",
                 epaisseur=2)
    tk.rectangle(0,
                 sixieme * 4,
                 C.WIDTH,
                 sixieme * 5,
                 "black",
                 "yellow",
                 epaisseur=2)
    tk.rectangle(0,
                 sixieme * 5,
                 C.WIDTH,
                 C.HEIGHT_TOTAL,
                 "black",
                 "yellow",
                 epaisseur=2)

    tk.texte(C.WIDTH / 2,
             sixieme // 2,
             "Casse-Brique",
             "red2",
             police="fixedsys",
             ancrage="center",
             taille=54)
    tk.texte(C.WIDTH / 2,
             sixieme // 2 * 3,
             "--SW--",
             "red2",
             police="fixedsys",
             ancrage="center",
             taille=60)
    #Image gif 100x84
    tk.image(C.WIDTH // 16 * 2, sixieme // 2 * 3, C.IMAGE1_PATH)
    tk.image(C.WIDTH // 16 * 14.25, sixieme // 2 * 3, C.IMAGE2_PATH)

    tk.texte(C.WIDTH / 2,
             sixieme // 2 * 5,
             "Normal",
             "black",
             police="fixedsys",
             ancrage="center",
             taille=20)
    tk.texte(C.WIDTH / 2,
             sixieme // 2 * 7,
             "Automatique",
             "black",
             police="fixedsys",
             ancrage="center",
             taille=20)
    tk.texte(C.WIDTH / 2,
             sixieme // 2 * 9,
             "Charger un fichier",
             "black",
             police="fixedsys",
             ancrage="center",
             taille=20)
    tk.texte(C.WIDTH / 2,
             sixieme // 2 * 11,
             "High-scores",
             "black",
             police="fixedsys",
             ancrage="center",
             taille=20)
예제 #5
0
def draw_scores():
    """Affichage de la fentre des high_scores."""

    dixieme = C.HEIGHT_TOTAL // 10
    tk.rectangle(0, 0, C.WIDTH, dixieme * 3, "black", "blue2", epaisseur=2)

    tk.rectangle(0,
                 dixieme * 3,
                 C.WIDTH,
                 dixieme * 4,
                 "black",
                 "yellow",
                 epaisseur=2)
    tk.rectangle(0,
                 dixieme * 4,
                 C.WIDTH,
                 dixieme * 5,
                 "black",
                 "yellow",
                 epaisseur=2)
    tk.rectangle(0,
                 dixieme * 5,
                 C.WIDTH,
                 dixieme * 6,
                 "black",
                 "yellow",
                 epaisseur=2)
    tk.rectangle(0,
                 dixieme * 6,
                 C.WIDTH,
                 dixieme * 7,
                 "black",
                 "yellow",
                 epaisseur=2)
    tk.rectangle(0,
                 dixieme * 7,
                 C.WIDTH,
                 dixieme * 8,
                 "black",
                 "yellow",
                 epaisseur=2)
    tk.rectangle(0,
                 dixieme * 8,
                 C.WIDTH,
                 dixieme * 9,
                 "black",
                 "yellow",
                 epaisseur=2)
    tk.rectangle(0,
                 dixieme * 9,
                 C.WIDTH,
                 C.HEIGHT_TOTAL,
                 "black",
                 "yellow",
                 epaisseur=2)

    tk.texte(C.WIDTH / 2,
             dixieme // 1.5,
             "Casse-Brique",
             "red2",
             police="fixedsys",
             ancrage="center",
             taille=54)
    tk.texte(C.WIDTH / 2,
             dixieme // 2 * 4.5,
             "SCORES",
             "black",
             police="fixedsys",
             ancrage="center",
             taille=60)
    #Image gif 100x84
    tk.image(C.WIDTH // 16 * 2, dixieme // 2 * 4.5, C.IMAGE1_PATH)
    tk.image(C.WIDTH // 16 * 14.25, dixieme // 2 * 4.5, C.IMAGE2_PATH)

    tk.texte(C.WIDTH / 2,
             dixieme // 2 * 7,
             "JOUEUR / DATE / TEMPS / SCORE",
             "black",
             police="fixedsys",
             ancrage="center",
             taille=18)

    score_list = FI.read_score()
    score_list = sorted(score_list, key=lambda x: x[3], reverse=True)
    score_list = score_list[:10]
    if score_list != []:
        i = 9
        for s in score_list:
            chaine_score = " / ".join(s)
            taille = 17

            if tk.longueur_texte(chaine_score) > C.WIDTH - 10:
                taille = 16
            tk.texte(C.WIDTH / 2,
                     dixieme // 1.9 * i,
                     chaine_score,
                     "blue",
                     police="fixedsys",
                     ancrage="center",
                     taille=taille)
            i += 2