Example #1
0
    def __init__(self, application, score):
        ''' Destruction préventive des widget precedant (comme les notif) '''
        for widg in widget.Widget.group:
            widg.kill()

        record_score = self.meilleur_score(score)
        score = str(score)

        width = 200
        height = 50
        x = taille_ecran[0] / 2 - (width / 2)
        y = taille_ecran[1] / 3 - (height / 2)
        self.widg_rejouer = widget.Button(
            (x, y),
            size=(width, height),
            text="REJOUER",
            action=application.jeu,
            font="Razer Regular",
            centered=True,
            police=26,
            bold=True,
            hoover_color=(0, 255, 0))  # Bouton "REJOUER"
        self.widg_menu = widget.Button(
            (x, 2 * y),
            size=(width, height),
            text="MENU",
            action=application.menu,
            font="Razer Regular",
            centered=True,
            police=26,
            bold=True,
            hoover_color=(255, 0, 0))  # Bouton "MENU"
        self.widg_score = widget.Label(
            (0.75 * x, 1.4 * y),
            size=(2 * width, height),
            text="Score de la partie: " + score,
            text_color=(200, 200, 200),
            font="Razer Regular",
            centered=True,
            police=26,
            bold=False,
            color=(0, 0, 0, 0))  # affichage du score
        self.widg_record = widget.Label(
            (0.75 * x, 1.6 * y),
            size=(2 * width, height),
            text="Meilleur score: " + record_score,
            text_color=(200, 200, 200),
            font="Razer Regular",
            centered=True,
            police=26,
            bold=False,
            color=(0, 0, 0, 0))  # affichage du score

        fond = config.getImage(
            "fond game over")  # recuperation de l'image du fond menu
        fond = pygame.transform.scale(fond,
                                      taille_ecran)  # redimension de l'image
        pygame.display.get_surface().blit(fond, (0, 0))  # on colle le fond
Example #2
0
	def _init_editeur(self):
		''' Construit tout les éléments necessaires à l'éditeur '''

		''' On dessine un quadrillage '''
		for x in range(self.nb_case):
			pygame.draw.line(fond, (0, 0, 0), (x*self.taille_case+self.taille_case, 0), (x*self.taille_case+self.taille_case, self.height))
			pygame.draw.line(fond, (0, 0, 0), (0, x*self.taille_case+self.taille_case), (self.height, x*self.taille_case+self.taille_case))

		''' Définition des Frames (cadres) de l'editeur '''
		frame1 = widget.Frame((self.height+10, 10), (280, 90), color=(100, 100,100), border=1)
		frame2 = widget.Frame((self.height+10, 110), (280, 280), color=(100, 100,100), border=1)
		frame3 = widget.Frame((self.height+10, 400), (280, 130), color=(100, 100,100), border=1)
		self.frame2 = frame2 # On stocke le frame 2

		''' FRAME 1 - Sauvegarde / Ouverture d'un niveau '''
		self.widg_entry = widget.Entry((10, 10), border=0, border_color=(255, 0, 0), text="nom ?", frame=frame1)
		widget.Button((150, 50), text="Ouvrir", frame=frame1, action=self.load_level, hoover_color=(200, 200, 255), centered=True)
		widget.Button((10, 50), text="Enregistrer", frame=frame1, action=self.save_level, hoover_color=(200, 200, 255), centered=True)
		widget.Button((150, 10), text="Reset", frame=frame1, action=self.reset_level, hoover_color=(200, 200, 255), centered=True)

		''' FRAME 2 - Paramètres de selection d'une case '''
		self.widg_image_case = widget.Image((10, 10), size=(30, 30), border=1, path="", frame=frame2)
		self.widg_label_case = widget.Label((40, 10), size=(150, 30), text="None", color=(100, 100, 100), frame=frame2)
		self.widg_label_param = widget.Label((10, 40), size=(260, 30), text="Aucun(s) paramètre(s)", color=(100, 100, 100), frame=frame2)

		self.widg_button_test = widget.Button((10, 200), text="Tester niveau", frame=frame2, action=(self.change_mode, "test niveau"), hoover_color=(200, 200, 255), centered=True)
		self.widg_button_mode = widget.Button((10, 240), text="Changer mode", frame=frame2, action=(self.change_mode, "edition"), hoover_color=(200, 200, 255), centered=True)
		self.widg_select_mode = widget.Label((120, 240), size=(150, 30), text="Mode: selection", text_color=(0, 0, 255), color=(100, 100, 100), frame=frame2)

		''' FRAME 3 - Type de case à ajouter '''
		widget.ImageButton((10, 10), size=(30, 30), action=(self.change_type, "sol"), path="../image/sol.png", frame=frame3)
		widget.ImageButton((10, 50), size=(30, 30), action=(self.change_type, "fin"), path="../image/fin.png", frame=frame3)
		widget.ImageButton((10, 90), size=(30, 30), action=(self.change_type, "spawn"), path="../image/spawn.png", frame=frame3)
		widget.ImageButton((50, 10), size=(30, 30), action=(self.change_type, "mur"), path="../image/mur.png", frame=frame3)
		widget.ImageButton((50, 50), size=(30, 30), action=(self.change_type, "eau"), path="../image/eau.png", frame=frame3)
		widget.ImageButton((50, 90), size=(30, 30), action=(self.change_type, "vide"), path="../image/vide.png", frame=frame3)
		widget.ImageButton((90, 10), size=(30, 30), action=(self.change_type, "lave"), path="../image/lave.png", frame=frame3)
		widget.ImageButton((130, 10), size=(30, 30), action=(self.change_type, "pic"), path="../image/pic_on.png", frame=frame3)
		widget.ImageButton((130, 50), size=(30, 30), action=(self.change_type, "pic intervalle"), path="../image/pic_on.png", frame=frame3)
		widget.ImageButton((130, 90), size=(30, 30), action=(self.change_type, "pic interrupteur"), path="../image/pic_on.png", frame=frame3)
		widget.ImageButton((170, 10), size=(30, 30), action=(self.change_type, "porte"), path="../image/porte.png", frame=frame3)
		widget.ImageButton((170, 50), size=(30, 30), action=(self.change_type, "interrupteur"), path="../image/interrupteur_off.png", frame=frame3)
		widget.ImageButton((170, 90), size=(30, 30), action=(self.change_type, "interrupteur timer"), path="../image/interrupteur_off.png", frame=frame3)
		widget.ImageButton((210, 10), size=(30, 30), action=(self.change_type, "bonus"), path="../image/bonus.png", frame=frame3)

		''' On construit enfin le niveau actuel '''
		self.build_level()
Example #3
0
 def notif(self, text):
     '''Crée le texte de notification'''
     self._notif = widget.Label(self.rect.topleft,
                                size=(200, 20),
                                text=text,
                                color=[0, 0, 0, 0],
                                centered=True,
                                bold=True)
     self._notif.rect.center = (self.rect.centerx, self.rect.y - 20)
Example #4
0
    def __init__(self):
        self.dimension = (config_info["taille_HUD"],
                          config_info["taille_level"]
                          )  #creer les dimension de l'hud
        self.largeur = config_info["taille_HUD"]  #donne la largeur de l'hud
        self.position = (
            config_info["taille_level"], 0
        )  #donne la position haute gauche de l'hud (en bord de niveau à droite)
        self.taille_level = config_info[
            "taille_level"]  #recupere la taille de l'evel

        self.image = config.getImage("hud")  #recupere l'image de l'hud
        self.image = pygame.transform.scale(
            self.image, self.dimension
        )  #redimensionne l'image (uniquement en cas de changement de taille de la fenetre)

        self.rect_hud = self.image.get_rect()
        self.rect_hud.topleft = (config_info["taille_level"], 0
                                 )  #permet l'affichage de l'hud

        self.widg_temps = widget.Label(
            ((self.taille_level + (self.largeur / 160) * 22),
             (self.taille_level / 800) * 227),
            size=(112, 36),
            color=(0, 0, 0, 0),
            text="temps",
            text_color=(255, 255, 255),
            centered=True,
            police=20,
            bold=True)  #texte du temps
        self.widg_score = widget.Label(
            ((self.taille_level + (self.largeur / 160) * 22),
             (self.taille_level / 800) * 382),
            size=(112, 36),
            color=(0, 0, 0, 0),
            text="score",
            text_color=(255, 255, 255),
            centered=True,
            police=20,
            bold=True)  #texte du score
Example #5
0
    def __init__(self, application):
        ''' Destruction préventive des widget precedant (comme les notif) '''
        for widg in widget.Widget.group:
            widg.kill()

        record_score = self.meilleur_score_menu()
        width = 200
        height = 50
        x = taille_ecran[0] / 2 - (width / 2)
        y = taille_ecran[1] / 3 - (height / 2)
        self.widg_jouer = widget.Button(
            (x, y),
            size=(width, height),
            text="JOUER",
            action=application.jeu,
            font="Razer Regular",
            centered=True,
            police=24,
            bold=True,
            hoover_color=(0, 255, 0))  # Bouton "JOUER"
        self.widg_quitter = widget.Button(
            (x, 2 * y),
            size=(width, height),
            text="QUITTER",
            action=application.quitter,
            font="Razer Regular",
            centered=True,
            police=24,
            bold=True,
            hoover_color=(255, 0, 0))  # Bouton "QUITTER"
        self.widg_record = widget.Label(
            (x, 1.5 * y),
            size=(width, height),
            text="Meilleur score: " + record_score,
            text_color=(255, 255, 255),
            font="Razer Regular",
            centered=True,
            police=26,
            bold=True,
            color=(255, 255, 255, 0))  # affichage du score

        fond = config.getImage(
            "fond menu")  # recuperation de l'image du fond menu
        fond = pygame.transform.scale(fond,
                                      taille_ecran)  #redimension de l'image
        pygame.display.get_surface().blit(fond, (0, 0))  # on colle le fond