Exemple #1
0
    def __init__(self):
        super().__init__()
        self._text_label = engine.Label(x=400,
                                        y=250,
                                        text="Enter ID here",
                                        font_size=40)

        self._test_line_input = engine.LineInput(x=400,
                                                 y=300,
                                                 width=400,
                                                 height=50)

        self._submit_button = engine.Button(x=525,
                                            y=400,
                                            width=150,
                                            height=50,
                                            text="Create")
        self._submit_button.BindCallback(self.Submit)

        self._back_button = engine.Button(x=275,
                                          y=400,
                                          width=150,
                                          height=50,
                                          text="Back")
        self._back_button.BindCallback(engine._scene_factory.SetPreviousScene)
Exemple #2
0
    def __init__(self):
        super().__init__()
        self._cols = 20
        self._rows = 20
        self._scale = 20
        self._matrix = engine.Matrix(self._cols, self._rows)
        self._matrix[0] = 1
        self._matrix[len(self._matrix) - 1] = 2

        self._was_cut = False
        self._is_cutting = False
        self._start_cut_pos = [0, 0]
        self._end_cut_pos = [0, 0]
        self._mesh = Mesh(self._cols, self._rows, self._scale)

        self._matrix_copy = [0] * len(self._matrix)

        self._current_player = 1
        self._current_area = randint(1, 10)
        self._count_of_turns = 2

        self._current_area_label = engine.Label(
            x=650, y=200, text=f"Current area is {self._current_area}.")

        self._current_player_label = engine.Label(
            x=650, y=100, text=f"{self._current_player}'s player turn.")

        self._send_button = engine.Button(x=650,
                                          y=300,
                                          text="Send",
                                          width=150,
                                          height=50)
        self._send_button.BindCallback(self.SendMessage)

        self._settings_button = engine.Button(x=650,
                                              y=400,
                                              width=150,
                                              height=50,
                                              text="Settings")
        self._settings_button.BindCallback(
            engine._scene_factory.SetCurrentScene, ["settings_menu"])

        self._quit_button = engine.Button(x=650,
                                          y=500,
                                          width=150,
                                          height=50,
                                          text="Quit")
        self._quit_button.BindCallback(self.Quit)
Exemple #3
0
 def __init__(self):
     super().__init__()
     self._back_button = engine.Button(x=400,
                                       y=500,
                                       width=250,
                                       height=50,
                                       text="Back")
     self._back_button.BindCallback(engine._scene_factory.SetPreviousScene)
Exemple #4
0
    def __init__(self):
        super().__init__()
        self._ready_label = engine.Label(x=400,
                                         y=150,
                                         text="Are you ready?",
                                         font_size=100)

        self._ready_button = engine.Button(x=525,
                                           y=500,
                                           width=150,
                                           height=50,
                                           text="I'm ready!")
        self._ready_button.BindCallback(self.ReadyCallback)

        self._back_button = engine.Button(x=275,
                                          y=500,
                                          width=150,
                                          height=50,
                                          text="No, I'm not.")
        self._back_button.BindCallback(self.BackCallback)
Exemple #5
0
    def __init__(self):
        super().__init__()
        self._dicor_label = engine.Label(x=400,
                                         y=100,
                                         text="SERVER GAME",
                                         font_size=75)

        self._create_button = engine.Button(x=400,
                                            y=200,
                                            width=250,
                                            height=50,
                                            text="Create a game")
        self._create_button.BindCallback(engine._scene_factory.SetCurrentScene,
                                         ["create_game_menu"])

        self._join_button = engine.Button(x=400,
                                          y=300,
                                          width=250,
                                          height=50,
                                          text="Join the game")
        self._join_button.BindCallback(engine._scene_factory.SetCurrentScene,
                                       ["join_the_game_menu"])

        self._settings_button = engine.Button(x=400,
                                              y=400,
                                              width=250,
                                              height=50,
                                              text="Settings")
        self._settings_button.BindCallback(
            engine._scene_factory.SetCurrentScene, ["settings_menu"])

        self._quit_button = engine.Button(x=400,
                                          y=500,
                                          width=250,
                                          height=50,
                                          text="Quit")
        self._quit_button.BindCallback(engine.EventsEmmiter().Emit, ["QUIT"])
Exemple #6
0
    def menu(self):
        self.is_running = True
        self.current_level = 1
        # title = engine.Element("assets/menu/title", 1, settings.screen_width/2, 50, 1, 0.07)

        text_group = pygame.sprite.Group()
        # text_group.add(title)
        

        singleplayer_button = engine.Button(
            "assets/sg_btn/singleplayer", 13, settings.screen_width/2, 400, 0.6, 0.07)
        
        #multiplayer_button = engine.Button("assets/mp_btn/multiplayer", 12, settings.screen_width/2, 550, 0.6, 0.07)

        button_group = pygame.sprite.Group()
        button_group.add(singleplayer_button)
        #button_group.add(multiplayer_button)

        mouse = engine.Mouse()
        mouse_group = pygame.sprite.Group()
        mouse_group.add(mouse)

        settings.zombie_theme.play()

        while self.is_running:
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    pygame.quit()
                    sys.exit()
                
                # se apertou alguma tecla
                if event.type == pygame.KEYDOWN:
                    if event.key == pygame.K_ESCAPE:
                        self.state = "menu"
                        self.is_running = False
                
                if event.type == pygame.MOUSEBUTTONDOWN:
                    if pygame.sprite.spritecollide(mouse, button_group, False):
                        collision_button = pygame.sprite.spritecollide(
                            mouse, button_group, False)[0].rect
                        print(collision_button.bottom)
                        if collision_button.bottom <= 500:
                            settings.button_sound.play()
                            self.state = "level1"
                            self.is_running = False
                        # elif collision_button.bottom <= 800:
                        #     settings.button_sound.play()
                        #     print("multiplayer")
                        #     self.state = "menu"
                        #     self.is_running = False
                        
            
            settings.screen.fill(settings.bg_color)
            self.background_group.draw(settings.screen)
            self.background_group.update()

            button_group.draw(settings.screen)
            text_group.draw(settings.screen)
            mouse_group.draw(settings.screen)

            button_group.update()
            text_group.update()
            mouse_group.update()

            pygame.display.update()
            settings.clock.tick(120)
Exemple #7
0
def settings():
    global game

    font40 = pygame.font.Font(None, 40)
    game.screen.fill((0, 0, 0))
    font30 = pygame.font.Font(None, 30)
    setting = 1
    # configuration du bouton retour
    backEvent = pygame.USEREVENT + 5
    backButton = engine.Button((0, 690), (100, 30),
                               "Retour",
                               backEvent,
                               fontSize=30)

    # configuration des configurateurs de touches
    # mouvements
    editUpButton = engine.KeyCustomizerButton((490, 40), (100, 50),
                                              playerKeyConfig["up"],
                                              playerKeyConfigUnicode["up"],
                                              fontSize=50,
                                              background=(100, 100, 100))
    editDownButton = engine.KeyCustomizerButton((490, 100), (100, 50),
                                                playerKeyConfig["down"],
                                                playerKeyConfigUnicode["down"],
                                                fontSize=50,
                                                background=(100, 100, 100))
    editLeftButton = engine.KeyCustomizerButton((490, 160), (100, 50),
                                                playerKeyConfig["left"],
                                                playerKeyConfigUnicode["left"],
                                                fontSize=50,
                                                background=(100, 100, 100))
    editRightButton = engine.KeyCustomizerButton(
        (490, 220), (100, 50),
        playerKeyConfig["right"],
        playerKeyConfigUnicode["right"],
        fontSize=50,
        background=(100, 100, 100))
    # objets
    editORightButton = engine.KeyCustomizerButton(
        (490, 280), (100, 50),
        playerKeyConfig["useRight"],
        playerKeyConfigUnicode["useRight"],
        fontSize=50,
        background=(100, 100, 100))
    editOLeftButton = engine.KeyCustomizerButton(
        (490, 340), (100, 50),
        playerKeyConfig["useLeft"],
        playerKeyConfigUnicode["useLeft"],
        fontSize=50,
        background=(100, 100, 100))
    editCraftButton = engine.KeyCustomizerButton(
        (490, 400), (100, 50),
        playerKeyConfig["openCraft"],
        playerKeyConfigUnicode["openCraft"],
        fontSize=50,
        background=(100, 100, 100))
    while setting == 1:
        events = game.runEvents()
        game.screen.fill((0, 0, 0))  # effacer l'écran
        game.screen.blit(font40.render("Touches :", 1, (255, 255, 255)),
                         (480, 10))
        game.screen.blit(font30.render("Haut :", 1, (255, 255, 255)),
                         (400, 50))
        game.screen.blit(font30.render("Bas :", 1, (255, 255, 255)),
                         (400, 110))
        game.screen.blit(font30.render("Gauche :", 1, (255, 255, 255)),
                         (400, 170))
        game.screen.blit(font30.render("Droite :", 1, (255, 255, 255)),
                         (400, 230))
        game.screen.blit(font30.render("Objet droite :", 1, (255, 255, 255)),
                         (350, 290))
        game.screen.blit(font30.render("Objet gauche :", 1, (255, 255, 255)),
                         (350, 350))
        game.screen.blit(font30.render("Menu Craft :", 1, (255, 255, 255)),
                         (350, 410))
        # bouton retour
        game.screen.blit(backButton.render(), backButton.position)
        backButton.update(events)
        # affichage des configurateurs des touches
        game.screen.blit(editUpButton.render(), editUpButton.position)
        game.screen.blit(editLeftButton.render(), editLeftButton.position)
        game.screen.blit(editRightButton.render(), editRightButton.position)
        game.screen.blit(editDownButton.render(), editDownButton.position)
        game.screen.blit(editORightButton.render(), editORightButton.position)
        game.screen.blit(editOLeftButton.render(), editOLeftButton.position)
        game.screen.blit(editCraftButton.render(), editCraftButton.position)
        # actualisation des configurateurs des touches
        playerKeyConfig["left"] = editLeftButton.update(events)
        playerKeyConfig["down"] = editDownButton.update(events)
        playerKeyConfig["right"] = editRightButton.update(events)
        playerKeyConfig["up"] = editUpButton.update(events)
        playerKeyConfig["useRight"] = editORightButton.update(events)
        playerKeyConfig["useLeft"] = editOLeftButton.update(events)
        playerKeyConfig["openCraft"] = editCraftButton.update(events)
        for event in events:

            if event.type == pygame.KEYUP:
                if event.key == pygame.K_ESCAPE:
                    events = []
                    setting = 0
            if event.type == backEvent:
                events = []
                setting = 0
        events = []
        game.waitFramerate()
    playerKeyConfigUnicode["left"] = editLeftButton.text
    playerKeyConfigUnicode["right"] = editRightButton.text
    playerKeyConfigUnicode["up"] = editUpButton.text
    playerKeyConfigUnicode["down"] = editDownButton.text
    playerKeyConfigUnicode["useLeft"] = editOLeftButton.text
    playerKeyConfigUnicode["useRight"] = editORightButton.text
    playerKeyConfigUnicode["openCraft"] = editCraftButton.text
    file = open("keys", "wb")
    pickle.dump((playerKeyConfig, playerKeyConfigUnicode), file)
    file.close()
Exemple #8
0
    pickle.dump((playerKeyConfig, playerKeyConfigUnicode), file)
    file.close()
else:
    file = open("keys", "rb")
    out = pickle.load(file)
    file.close()
    playerKeyConfig = out[0]
    playerKeyConfigUnicode = out[1]

playEvent = pygame.USEREVENT + 4
creditsEvent = pygame.USEREVENT + 3
settingsEvent = pygame.USEREVENT + 2

playButton = engine.Button((10, 10), (130, 50),
                           "Jouer",
                           playEvent,
                           fontSize=60,
                           focusedBackground=(100, 100, 100))
creditsButton = engine.Button((10, 70), (110, 40),
                              "Crédits",
                              creditsEvent,
                              fontSize=40,
                              focusedBackground=(100, 100, 100))
fullScreenButton = engine.Button((10, 120), (170, 40),
                                 "Plein Écran",
                                 game.fullscreenEvent,
                                 fontSize=40,
                                 focusedBackground=(100, 100, 100))
settingsButton = engine.Button((10, 170), (170, 40),
                               "Paramètres",
                               settingsEvent,