Esempio n. 1
0
        def __init__(self, screen, screenw, screenh, spriteList, soundManager):
            self.sprites = spriteList
            self.screen = screen
            self.screenw = screenw
            self.screenh = screenh
            self.soundManager = soundManager
            self.state = "Main"
            self.mainButtons = []
            self.mainButtons.append(Button(self.screen, self.sprites.getSprite("login"), self.sprites.getSprite("loginHighlighted"), 368, 350, 281, 68, "Login", 'Start Button.ogg', soundManager))
            self.mainButtons.append(Button(self.screen, self.sprites.getSprite("start"), self.sprites.getSprite("startHighlighted"), 368, 442, 281, 68, "Game", 'Start Button.ogg', soundManager))
            self.mainButtons.append(Button(self.screen, self.sprites.getSprite("exit"), self.sprites.getSprite("exitHighlighted"), 368, 534, 281, 68, "Exit", 'Exit.ogg', soundManager))

            self.fontsize = 30
            self.font = pygame.font.Font(os.path.join('Fonts', 'nasalization-rg.ttf'), self.fontsize)

            self.loginButtons = []
            self.ip = textInput(self.screen, "Server IP", (50, 30), (self.font.get_height() * 8), 50, 15)
            self.port = textInput(self.screen, "Port", (300 + (self.font.get_height() * 8),  30), (self.font.get_height() * 5), 50, 5)
            self.username = textInput(self.screen, "Username", (self.screenw/2 - 200, 130), (self.font.get_height() * 8), 50, 8)
            self.password = textInput(self.screen, "Password", (self.screenw/2 - 200, 230), (self.font.get_height() * 8), 50, 8, True)
            self.loginButtons.append(Button(self.screen, self.sprites.getSprite("login"), self.sprites.getSprite("loginHighlighted"), 368, 442, 281, 68, "Lobby", 'Start Button.ogg', soundManager))
            self.loginButtons.append(Button(self.screen, self.sprites.getSprite("exit"), self.sprites.getSprite("exitHighlighted"), 368, 534, 281, 68, "Main", 'Exit.ogg', soundManager))

            self.mouseDelay = 50
            self.mouseNext = pygame.time.get_ticks()
            self.connected = False

            #for server
            self.socket = None
            self.loginStatus = ""
Esempio n. 2
0
 def initialize_buttons(self):
     self.restart_button = Button(self.game_display,
                                  (self.width // 2 + C.rb_length,
                                   self.height // 2 - C.rb_height - 10),
                                  C.rb_length,
                                  C.rb_height,
                                  C.rb_color,
                                  C.rb_text,
                                  C.rb_text_size,
                                  C.rb_text_color,
                                  C.rb_font,
                                  mod=2,
                                  border=C.rb_border,
                                  extend=True)
     self.pause_button = Button(
         self.game_display,
         (self.width // 2 + C.ps_length,
          self.height // 2 - C.ps_height - 10 - C.ps_height - 10),
         C.ps_length,
         C.ps_height,
         C.ps_color,
         C.ps_text,
         C.ps_text_size,
         C.ps_text_color,
         C.ps_font,
         mod=2,
         border=C.ps_border,
         extend=True)
    def __init__(self, text, pos, size, color, alpha, functions):
        super(Confirmation_Menu, self).__init__(pos, size, color, alpha)
        self.functions = functions + [lambda: self.set_response(True)]
        self.response_received = False

        self.main_text = Text(
            str(text),
            [self.pos[0] + self.size[0] / 2, self.pos[1] + self.size[1] / 2],
            (255, 255, 255), 20, "tahoma")
        self.confirm_button = Button([
            self.pos[0] + self.size[0] * 0.1, self.pos[1] + self.size[1] * 0.95
        ], [self.size[0] * 0.35, self.size[1] * 0.3], (0, 200, 0), (0, 255, 0),
                                     self.alpha, self.functions)
        self.confirm_button.add_text("Confirm", [
            self.confirm_button.get_size()[0] / 2,
            self.confirm_button.get_size()[1] / 2
        ], (255, 255, 255), 20, "tahoma")
        self.cancel_button = Button([
            self.pos[0] + self.size[0] * 0.5, self.pos[1] + self.size[1] * 0.95
        ], [self.size[0] * 0.35, self.size[1] * 0.3], (200, 0, 0), (255, 0, 0),
                                    self.alpha,
                                    [lambda: self.set_response(True)])
        self.cancel_button.add_text("Cancel", [
            self.cancel_button.get_size()[0] / 2,
            self.cancel_button.get_size()[1] / 2
        ], (255, 255, 255), 20, "tahoma")
Esempio n. 4
0
def drawBoard(my_score, devils_score):
    # draw score increments of 10
    font = pygame.font.SysFont(None, 48)
    for i in range(1, 11):
        x = dis_width / 15
        y = dis_height - (i * (dis_height / 10))
        img = font.render(str(i * 10), True, BLACK)
        dis.blit(img, (x, y))

    # Draw user and devil text
    my_x = dis_width / 3
    devil_x = dis_width / 3 * 2
    y = dis_height - 30
    user = font.render("User", True, BLUE)
    dis.blit(user, (my_x, y))
    devil = font.render("Devil", True, DARK_RED)
    dis.blit(devil, (devil_x, y))

    # draw buttons
    roll_die = Button(dis, LIGHT_GREY, dis_width / 2 - 15, dis_height / 2, 100, 50, "roll")
    roll_die.draw()
    roll_die.add_text("Roll", 48, BLACK)
    pass_turn = Button(dis, LIGHT_GREY, dis_width / 2 - 15, dis_height / 2 + dis_height / 10, 100, 50, "pass")
    pass_turn.draw()
    pass_turn.add_text("Pass", 48, BLACK)

    # draw player score bars
    pygame.draw.rect(dis, BLUE, [my_x, dis_height - ((dis_height / 10) * (my_score / 10)), dis_width / 10,
                                 (dis_height / 10) * (my_score / 10) - 30])
    pygame.draw.rect(dis, DARK_RED, [devil_x, dis_height - ((dis_height / 10) * (devils_score / 10)), dis_width / 10,
                                     (dis_height / 10) * (devils_score / 10) - 30])
Esempio n. 5
0
    def __init__(self):
        self.result = -1  # переменная для отслеживания состояния экрана

        # индекс отображаемого персонажа и выбранного персонажа, соответственно
        self.ind_chr = self.character = int(settings_values['character'])
        self.volume = settings_values['music_volume']  # громкость музыки

        pygame.mixer.music.load(load_music(
            character_theme[self.character]))  # загрузка музыки
        pygame.mixer.music.set_volume(0.1 * int(self.volume))
        pygame.mixer.music.play(-1)

        # имена и координаты имен персонажей
        self.names_chr = (('Flandre', (415, 110)), ('Marisa', (420, 110)),
                          ('Reimu', (440, 110)), ('Remilia', (425, 110)),
                          ('Sakuya', (430, 110)))

        # кнопки переключения персонажа
        self.left_button = Button(200, 310, 100, 100, '', left_button_image)
        self.right_button = Button(820, 310, 100, 100, '', right_button_image)

        # кнопки выхода к экрану выбора карт(exit_btn) и подтверждению выбора персонажа(confirm_btn)
        self.exit_btn = Button(-30, 615, 236, 92, '', exit_button_image,
                               self.back)
        self.confirm_btn = Button(908, 650, 222, 92, '', confirm_button_image,
                                  self.confirm_chr)
    def __init__(self, screen_dimension_pixels, screen_dimension_inches):
        py.init()

        self.dimension_pixels = screen_dimension_pixels
        self.dimension_inches = screen_dimension_inches
        self.origin_x = self.dimension_inches / 2
        self.origin_y = self.dimension_inches / 2

        # Creates the window and defines its dimensions
        self.window = py.display.set_mode(
            (self.dimension_pixels, self.dimension_pixels))

        # Title
        self.caption = ''
        py.display.set_caption(self.caption)

        self.points = []
        self.linkages = []
        self.deleted_points = []
        self.buttons = []
        self.key_commanders = []

        self.point_index = 0
        self.current_point = 0

        self.xy = True
        self.planar_path = True
        self.xy_modifier = Button(self, 10, 25, "XY SCREEN", True, v.green)
        self.planar_path_modifier = Button(self, 50, 25, "Keep Path Planar",
                                           True, v.green)
Esempio n. 7
0
 def __init__(self, win, mobTeam):
     self.win = win
     self.buttonList = [
         Button((270, 190 + i), mobTeam[i].name)
         for i in range(len(mobTeam))
     ]
     self.returnButton = Button((270, 290), u"返回")
Esempio n. 8
0
    def __init__(self, win, x, y, width, height):
        self.win = win
        self.x = x
        self.y = y
        self.width = width
        self.height = height

        self.ioBoxOuter = Button(self.win, self.x, self.y, BLACK, BLACK, BLACK,
                                 '')
        self.ioBoxInner = Button(self.win, self.x, self.y, WHITE, WHITE, WHITE,
                                 '')

        self.ioBoxOuter.width = self.width
        self.ioBoxOuter.height = self.height

        self.ioBoxInner.width = self.ioBoxOuter.width - 10
        self.ioBoxInner.height = self.ioBoxOuter.height - 10
        self.ioBoxInner.x = self.ioBoxOuter.x + (self.ioBoxOuter.width -
                                                 self.ioBoxInner.width) / 2
        self.ioBoxInner.y = self.ioBoxOuter.y + (self.ioBoxOuter.height -
                                                 self.ioBoxInner.height) / 2

        self.text = Text(self.win, 0, 0, '', size=70)
        self.text.x = self.ioBoxInner.x + self.text.text.get_rect(
        ).width / 2 + 10
        self.text.y = self.ioBoxInner.y + self.text.text.get_rect(
        ).height / 2 + 40
Esempio n. 9
0
    def __init__(self, _windows):
        """初始化首页方法。

        Args:
            _windows: 由 Pygame 创建的当前游戏窗口
        """
        self.__windows = _windows

        # 加载背景图并将其缩放至适合窗口的大小。
        self.__background_img = pygame.transform.scale(
            pygame.image.load('./resource/image/background.jpg'),
            [SCREEN_WIDTH, SCREEN_HEIGHT])

        # 创建首页上标题。
        self.__title_text = Text(None, TITLE_HEIGHT, 'Gobang',
                                 WHITE_COLOR, (TITLE_X, TITLE_Y))

        # 创建首页上按钮。
        self.__start_button = Button('Start', BUTTON_COLOR, True,
                                     (TITLE_X - BUTTON_WIDTH // 2,
                                      TITLE_Y + TITLE_HEIGHT))
        self.__model_button = Button('PVE', MODULE_BUTTON_COLOR, True,
                                     (TITLE_X - BUTTON_WIDTH // 2,
                                      TITLE_Y + TITLE_HEIGHT + 60))
        self.__exit_button = Button('Exit', BUTTON_COLOR, True,
                                    (TITLE_X - BUTTON_WIDTH // 2,
                                     TITLE_Y + TITLE_HEIGHT + 120))
Esempio n. 10
0
    def _initNew(self):

        # Setting instruction text accordingly
        self.instructionText.setText("Please select your group type: ")

        # Buttons for each type of group
        businessButton = Button(self.window,
                                "Business (1)",
                                16,
                                Point(175, 250),
                                150,
                                100,
                                clickHandler=self.businessButtonCallback)
        self.addSubView(businessButton)

        touristButton = Button(self.window,
                               "Tourists (2)",
                               16,
                               Point(400, 250),
                               150,
                               100,
                               clickHandler=self.touristButtonCallback)
        self.addSubView(touristButton)

        self.familyButton = Button(self.window,
                                   "Family (3-5)",
                                   16,
                                   Point(625, 250),
                                   150,
                                   100,
                                   clickHandler=self.familyButtonCallback)
        self.addSubView(self.familyButton)
Esempio n. 11
0
def main_menu():
    playBtn = Button(f"{menuPath}start_normal.png", f"{menuPath}start_hover.png", (700, 200), WIN)
    settingsBtn = Button(f"{menuPath}settings_normal.png", f"{menuPath}settings_hover.png", (700, 500), WIN)
    while True:
        WIN.fill((0, 0, 0))
        clock.tick(FPS)

        mousePos = pygame.mouse.get_pos()

        playBtn.hovered = playBtn.imagerect.collidepoint(mousePos)
        playBtn.draw()
        settingsBtn.hovered = settingsBtn.imagerect.collidepoint(mousePos)
        settingsBtn.draw()

        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                pygame.quit()
                quit()
                break
            elif event.type == pygame.MOUSEBUTTONDOWN and event.button == 1:
                if playBtn.hovered:
                    Game(WIN, clock).run()
                elif settingsBtn.hovered:
                    settings()

        pygame.display.update()
Esempio n. 12
0
def run_game():
	pygame.init()
	
	while True: #main loop for the game
		pygame.display.set_caption("Sudoku World") #window name
		screen = pygame.display.set_mode((400,500),0,32) #window size
		background = pygame.Surface(screen.get_size())#draw the background
		bg_color = (230,230,230)#designate the background's color
		background.fill(bg_color)
		font = pygame.font.Font('Calib.ttf',30)#设定字体
		text = font.render("Welcome to Sudoku World!",True,(50,150,255))#设定文本与颜色
		center = (background.get_width()/2, background.get_height()/2-100)#get the corrdinates of the center
		textposition = text.get_rect(center = center)
		button_register = Button('Graphs/register_btn_on.png','Graphs/register_btn_off.png',(200,300))
		button_login = Button('Graphs/login_btn_on.png','Graphs/login_btn_off.png',(200,400))
		background.blit(text, textposition)#add text to background according to coordiante
		screen.blit(background,(0,0))#paste backgroud to the screen
		button_register.render(screen)#render the button
		button_login.render(screen)#render the button

		for main_event in pygame.event.get():#event decision
			if main_event.type == pygame.QUIT:
				sys.exit()
			elif (main_event.type == pygame.MOUSEBUTTONDOWN and button_register.isOver() == True):
				register_window(screen,background,bg_color)
			elif (main_event.type == pygame.MOUSEBUTTONDOWN and button_login.isOver() == True):
				login_window(screen,background,bg_color)

		pygame.display.update()	#update the display
Esempio n. 13
0
    def InitializeGui(self):
        self.setWindowTitle(self.__title)
        self.setWindowIcon(QtGui.QIcon(self.__icon))
        self.setGeometry(self.__x, self.__y, self.__width, self.__height)

        self.__scene = QGraphicsScene()
        self.__view = QGraphicsView(self.__scene, self)
        self.__view.setFixedSize(self.__width, self.__height)
        self.__view.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
        self.__view.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
        self.__scene.setSceneRect(0, 0, self.__width, self.__height)

        self.__view.setBackgroundBrush(
            QtGui.QBrush(
                QtGui.QImage('x.png').scaled(self.__width, self.__height)))

        self.button1 = Button('okienko.png')
        self.button1.clicked.connect(self.DisplayMainMenu)
        #self.__scene.addItem(self.button1)
        self.button2 = Button('okienko.png')
        self.button2.clicked.connect(self.DisplayMainMenu)
        # self.__scene.addItem(self.button2)

        self.gauge = Gauge(0)
        self.__scene.addItem(self.gauge)

        self.button1.setPos(50, 150)
        self.button2.setPos(200, 150)
        self.gauge.setPos(100, 100)

        self.thread = MyThread()
        self.thread.my_thread.connect(self.setGauge)
        self.thread.start()
Esempio n. 14
0
def makeMainMenuButtons(data):
    (x, y, width, height) = (100, 600, 150, 100)
    data.trainButton = Button(x, y, width, height, "Train the\nCar")
    (x, y, width, height) = (750, 600, 150, 100)
    data.runButton = Button(x, y, width, height, "Run the\nCar")
    (x, y, width, height) = (data.width/2 - 150, 700, 300, 80)
    data.howItWorksButton = Button(x, y, width, height, "How it Works")
Esempio n. 15
0
    def __init__(self, surface, pos, width, height,
                 color=(255, 255, 255), border_color=(0, 0, 0), typeface='Arial', text_color=(0, 0, 0), mod=0,
                 button=True, button_length=None, button_text='Enter'):
        self.surface = surface
        self.pos = list(pos)
        self.width = width
        self.height = height
        self.typeface = typeface            # fancy name for font, since i use 'font' elsewhere
        self.color = color
        self.border_color = border_color    # same thing as in button function
        self.text_color = text_color
        self.mod = mod

        self.button = button
        self.button_length = button_length
        self.button_text = button_text

        self.size = Box.shift_size('A', 1, self.typeface, self.height-2, dec_by=-1)

        if self.button_length is None:
            self.button_length = self.width // 4

        if self.button and mod == 1:
            self.enter_button = Button(self.surface, (self.pos[0] + self.width, self.pos[1]),
                                       self.button_length, self.height, self.color, self.button_text, self.size,
                                       self.text_color, self.typeface, mod=2, border=self.border_color)

        if self.button and mod == 0:
            self.enter_button = Button(self.surface, (self.pos[0] + self.width, self.pos[1]),
                                       self.button_length, self.height, self.color, self.button_text, self.size,
                                       self.text_color, self.typeface, mod=1, border=self.border_color)

        # self.bar_pos = (self.pos[0], self.pos[1] + 1)
        self.font = pygame.font.SysFont(self.typeface, self.size)
Esempio n. 16
0
def make_objs():
    ui_mouse = DrawObj()
    ui_mouse.load_img('img/Title.png')
    ui_mouse.pos = np.array(ui_mouse.get_halfsize())

    Button(10, 10, 200, 100, "1920", set_window_size_1920)
    Button(10, 110, 200, 200, "1280", set_window_size_1280)
Esempio n. 17
0
    def WinSit(self):
        """Game class method to check if player won then show next screen.

        """
        global Dx, Dy

        if self.dungeon.room_current.type == "endboss" and self.dungeon.room_current.cleared:
            pygame.mouse.set_visible(True)
            self.state = 'WIN'
            self.actual_screen.blit(self.imageLoader.WinImg, (0, 0))
            self.Quitbtn = Button(400, 450, 150, 50, 'Quit', (200, 20, 20, 0),
                                  (180, 0, 0, 0), self.imageLoader.font1,
                                  self.imageLoader.font2)
            self.Nextbtn = Button(200, 450, 150, 50, 'Next', (200, 20, 20, 0),
                                  (180, 0, 0, 0), self.imageLoader.font1,
                                  self.imageLoader.font2)
            self.Quitbtn.show(self.imageLoader.WinImg)
            self.Nextbtn.show(self.imageLoader.WinImg)
            if self.Quitbtn.is_mouse_clicked():
                pygame.quit()
                quit()
            if self.Nextbtn.is_mouse_clicked():
                self.levelcleared += 1
                self.clearcount = 0
                self.check = True
                cfg.DUNGEON_SIZE = (Dx, Dy)
                self.state = 'GAME'
                self.new()
                Dx = Dx + 1
                Dy = Dy + 1
Esempio n. 18
0
    def GameOverr(self):
        """Game class method to check if player is dead and game is over.

        """
        global Dx, Dy
        if self.player.Dead == True:
            self.state = 'GAME OVER'
            pygame.mouse.set_visible(True)
            self.actual_screen.blit(self.imageLoader.GameOverImg, (0, 0))
            self.Quitbtn = Button(400, 450, 150, 50, 'Quit', (200, 20, 20, 0),
                                  (180, 0, 0, 0), self.imageLoader.font1,
                                  self.imageLoader.font2)
            self.Nextbtn = Button(200, 450, 150, 50, 'Restart',
                                  (200, 20, 20, 0), (180, 0, 0, 0),
                                  self.imageLoader.font1,
                                  self.imageLoader.font2)
            self.Quitbtn.show(self.imageLoader.GameOverImg)
            self.Nextbtn.show(self.imageLoader.GameOverImg)
            if self.Quitbtn.is_mouse_clicked():
                pygame.quit()
                quit()
            if self.Nextbtn.is_mouse_clicked():
                self.levelcleared = 1
                self.clearcount = 0
                Dx = 5
                Dy = 5
                self.pistolpick = True
                self.machinegunpick = False
                self.check = True
                cfg.DUNGEON_SIZE = (Dx, Dy)
                self.state = 'GAME'
                self.new()
Esempio n. 19
0
    def side_panel_display(self):
        self.game_moves_display = Button(820, 40, 320, 80, Game.BLACK, Game.BUTTON_FONT, f"Game Moves: {self.game_moves}", self.screen)
        self.game_moves_display.draw_button()

        # self.resign_button = Button(820, 160, 320, 80, Game.GRAY, Game.BUTTON_FONT, "Resign", self.screen)
        # self.resign_button.draw_button()

        

        if self.game_moves % 2 == 0 and not self.game_over:
            self.X_color = Game.MELLOW_YELLOW
            self.O_color = Game.GRAY

        elif self.game_moves % 2 == 1 and not self.game_over:
            self.O_color = Game.MELLOW_YELLOW
            self.X_color = Game.GRAY

        else:
            self.X_color = Game.GRAY
            self.O_color = Game.GRAY

        self.X_icon = Button(860, 160, 80, 80, self.X_color, Game.BUTTON_FONT, "X", self.screen)
        self.X_icon.draw_button()

        self.O_icon = Button(1020, 160, 80, 80, self.O_color, Game.BUTTON_FONT, "O", self.screen)
        self.O_icon.draw_button()

        self.replay_button = Button(820, 540, 320, 80, Game.GREEN, Game.BUTTON_FONT, "Replay", self.screen)
        self.replay_button.draw_button()

        self.quit_to_title = Button(820, 660, 320, 80, Game.BLACK, Game.BUTTON_FONT, "Quit to Title", self.screen)
        self.quit_to_title.draw_button()

        pygame.display.update()
Esempio n. 20
0
def process_menu_hover(window, mouseClickPos, button_list):
    """Processes the hover event on the main menu"""

    for button in button_list:
        if button.rect.collidepoint(mouseClickPos):
            # Creates the highlighted button
            highlight = (255, 140, 0)
            rect = pygame.Rect(button.rect.x, button.rect.y, button.rect.width,
                               button.rect.height)
            highlightedButton = Button(rect, button.font, highlight,
                                       button.text)

            Draw.draw_button(window, highlightedButton)
            button.highlighted = True
        elif button.highlighted:
            # Lowlights the button when the mouse is no longer hovering over it

            highlight = button.colour
            rect = pygame.Rect(button.rect.x, button.rect.y, button.rect.width,
                               button.rect.height)
            highlightedButton = Button(rect, button.font, highlight,
                                       button.text)

            Draw.draw_button(window, highlightedButton)
            button.highlighted = False
Esempio n. 21
0
    def __init__(self, count_combo, score, marks, accuracy, map):
        self.result = -1
        self.count_combo = str(count_combo) + 'x'
        self.score = str(score)
        self.marks = [str(i) + 'x' for i in marks.values()]

        if accuracy == 100:
            self.rank = load_image('skin/rank_SS.png')
        elif accuracy > 95:
            self.rank = load_image('skin/rank_S.png')
        elif accuracy > 90:
            self.rank = load_image('skin/rank_A.png')
        elif accuracy > 80:
            self.rank = load_image('skin/rank_B.png')
        elif accuracy > 70:
            self.rank = load_image('skin/rank_C.png')
        else:
            self.rank = load_image('skin/rank_D.png')
        self.accuracy = str('%.2f' % accuracy) + '%'

        self.back_btn = Button(-30, 630, 236, 92, '', back_button_image, self.back)

        self.restart_btn = Button(908, 630, 236, 92, '', restart_button_image, self.restart)

        map_id = map[2].map_id
        mapset_id = map[2].mapset_id
        time = str(dt.datetime.now().time()).split('.')[0]
        date = str(dt.datetime.now().date())
        con = sqlite3.connect('records.db')
        cur = con.cursor()
        cur.execute(
            f"INSERT INTO Records(map_id, mapset_id, score, accuracy, combo, date, time) VALUES({map_id}, {mapset_id}, {score}, {accuracy}, {count_combo}, '{date}', '{time}')")
        con.commit()
Esempio n. 22
0
    def reinitialize_variables_for_new_game(self):

        self.is_finished_screen_showing = False
        #blanks the note board
        self.create_blank_note_board()
        self.create_new_board()
        self.initialize_boolean_board()
        self.backtracker = Backtracking(self, self.board, self.boolean_board, True)

        self.reset_in_game_variables()
        #need to add this so that new puzzle after finish goes back to blue
        self.finish_button = Button(Constants.BLUE, Constants.BLACK,
                                    Constants.WINDOW_WIDTH // 2 - Constants.FINISHED_BUTTON_WIDTH // 2,
                                    Constants.WINDOW_HEIGHT // 2 - Constants.FINISHED_BUTTON_HEIGHT // 2, Constants.FINISHED_BUTTON_WIDTH,
                                    Constants.FINISHED_BUTTON_HEIGHT, 'New Puzzle', Constants.BLACK, 15)
        #need to add this so that finish animation button goes back to blue
        self.finish_animation_button = Button(Constants.BLUE, Constants.BLACK,
                                              Constants.PADDING * 2 + Constants.BACKTRACKING_BUTTON_WIDTH,
                                              3 * Constants.PADDING + Constants.NUM_ROWS * Constants.RECT_HEIGHT + Constants.NEW_GAME_BUTTON_HEIGHT,
                                              Constants.FINISH_ANIMATION_BUTTON_WIDTH, Constants.FINISH_ANIMATION_BUTTON_HEIGHT, 'Finish Animation',
                                              Constants.BLACK, Constants.MENU_FONT_SIZE)

        self.scene.fill(Constants.BLUE)
        self.redraw_screen(-1, -1, Constants.BLUE)


        #time
        self.start_time = pygame.time.get_ticks()
        self.prev_time_seconds = -1
        pygame.display.update()
Esempio n. 23
0
    def pauseSetup(self):
        self.canvasWidgets['pauseQuitButton'] = Button(
            self.canvas, 2, 2,
            gameSettings[State.PAUSE]['quitButton']['width'],
            gameSettings[State.PAUSE]['quitButton']['height'],
            gameSettings[State.PAUSE]['quitButton']['border'],
            gameSettings[State.PAUSE]['quitButton']['color'],
            gameSettings[State.PAUSE]['quitButton']['text'])

        self.canvasWidgets['pauseRestartButton'] = Button(
            self.canvas, 102, 2,
            gameSettings[State.PAUSE]['restartButton']['width'],
            gameSettings[State.PAUSE]['restartButton']['height'],
            gameSettings[State.PAUSE]['restartButton']['border'],
            gameSettings[State.PAUSE]['restartButton']['color'],
            gameSettings[State.PAUSE]['restartButton']['text'])

        self.canvasWidgets['pauseRect'] = self.canvas.create_rectangle(
            gameSettings['canvas']['width'] // 2 - 150,
            gameSettings['canvas']['height'] // 2 - 50,
            gameSettings['canvas']['width'] // 2 + 150,
            gameSettings['canvas']['height'] // 2 + 50,
            width=gameSettings[State.PAUSE]['rect']['width'],
            fill=gameSettings[State.PAUSE]['rect']['color'],
            stipple="gray50")

        self.canvasWidgets['pauseText'] = self.canvas.create_text(
            gameSettings['canvas']['width'] // 2,
            gameSettings['canvas']['height'] // 2,
            text=gameSettings[State.PAUSE]['text']['text'],
            fill=gameSettings[State.PAUSE]['text']['color'],
            font=gameSettings[State.PAUSE]['text']['font'])
        self.canvas.update()
Esempio n. 24
0
def makeDrivingButtons(data):
    (x, y, width, height) = (10, 10, 150, 70)
    data.drivingToMainMenuButton = Button(x, y, width, height, "Main Menu")
    (x, y, width, height) = (170, 10, 150, 70)
    data.showBrainButton = Button(x, y, width, height, "Show Brain")
    (x, y, width, height) = (330, 10, 150, 70)
    data.pauseButton = Button(x, y, width, height, "Pause")
Esempio n. 25
0
def makeTrainButtons(data):
    (x, y, width, height) = (data.width/2 - 150, 300, 300, 80)
    data.trainYourselfButton = Button(x, y, width, height, "Train it Yourself")
    (x, y, width, height) = (data.width/2 - 150, 450, 300, 80)
    data.learnAutoButton = Button(x, y, width, height, "Learn Automatically")
    (x, y, width, height) = (data.width/2 - 150, 600, 300, 80)
    data.trainToMainMenuButton = Button(x, y, width, height, "Main Menu")
Esempio n. 26
0
def showChooseAnimal(canvas, data):
    data.button5 = Button(Vector(data.width // 2, data.height // 5), canvas,
                          data, 'Plants', 100, 100)
    data.button5.showButton()

    data.button6 = Button(Vector(data.width // 2, data.height // 5 + 140),
                          canvas, data, 'Animals', 100, 100)
    data.button6.showButton()
Esempio n. 27
0
    def __init__(self, director):
        from resources import Textures, Fonts
        self.dir = director

        self.play_button = Button(Textures["play"], (432, 465), self.play)
        self.exit_button = Button(Textures["exit"], (1488 - 315, 500),
                                  self.quitt)
        self.background = Textures["menu"]
Esempio n. 28
0
 def __init__(self):
     self.newGameBtn = Button("New Game", 350, 290, self.BTN_WIDTH,
                              self.BTN_HEIGHT)
     self.docBtn = Button("Documentation", 350, 390, self.BTN_WIDTH,
                          self.BTN_HEIGHT)
     self.exitBtn = Button("Exit", 350, 490, self.BTN_WIDTH,
                           self.BTN_HEIGHT)
     self.font = loadFont("Videophreak-56.vlw")
Esempio n. 29
0
def changeBackground(screen):
    global bgOptions
    bgOptions = []
    Button(screen, (255, 255, 255), 870, 400, 100, 50, "Background color")
    bgOptions.append(Button(screen, red, 840, 470, 30, 30))
    bgOptions.append(Button(screen, blue, 880, 470, 30, 30))
    bgOptions.append(Button(screen, purple, 920, 470, 30, 30))
    bgOptions.append(Button(screen, green, 960, 470, 30, 30))
Esempio n. 30
0
    def gui_init(self):

        pygame.init()
        pygame.font.init()

        self.win = pygame.display.set_mode((self.width, self.height))
        pygame.display.set_caption("Tower of Hanoi")

        gui_rect = self.x_off, self.y_off, self.gui_width, self.gui_height
        self.guiWin = self.win.subsurface(gui_rect)

        self.win.fill(MID_BLACK)
        self.guiWin.fill(STEEL_BLUE)

        self.clock = pygame.time.Clock()

        self.titlefont = pygame.font.SysFont(TITLE_FONT, TITLE_FONT_SIZE)
        self.panelfont = pygame.font.SysFont(BUTTON_FONT,
                                             int(BUTTON_FONT_SIZE * 1.2))

        self.title = self.titlefont.render("3 Towers of Hanoi", 1, GOLD)
        w, h = self.title.get_size()
        pos = (self.width - w) // 2, (self.y_off - h) // 2
        self.win.blit(self.title, pos)

        # self.button_p = pygame.transform.scale(pygame.image.load(BUTTON_PRESSED).convert_alpha(), (240, 80))
        # self.button_up = pygame.transform.scale(pygame.image.load(BUTTON_UNPRESS).convert_alpha(), (240, 80))

        self.button_p = pygame.image.load(BUTTON_PRESSED).convert_alpha()
        self.button_up = pygame.image.load(BUTTON_UNPRESS).convert_alpha()

        self.up_button = Button(180 - self.x_off, BUTTONS_Y - self.y_off, "Up",
                                self.button_p, self.button_up)
        self.down_button = Button(240 - self.x_off, BUTTONS_Y - self.y_off,
                                  "Down", self.button_p, self.button_up)

        self.up_button.set_multipliers(2, 1.5)

        # self.up_button = pygame.transform.scale(self.up_button, (DELTA_BUTTON_WIDTH, DELTA_BUTTON_HEIGHT))
        # self.down_button = pygame.transform.scale(self.down_button, (DELTA_BUTTON_WIDTH, DELTA_BUTTON_HEIGHT))

        self.restartButton = Button(730 - self.x_off, BUTTONS_Y - self.y_off,
                                    "Restart", self.button_p, self.button_up)
        self.solveButton = Button(860 - self.x_off, BUTTONS_Y - self.y_off,
                                  "Solve!", self.button_p, self.button_up)

        self.buttons.append(self.restartButton)
        self.buttons.append(self.solveButton)
        self.buttons.append(self.up_button)
        self.buttons.append(self.down_button)

        self.towerS = Tower(TOWER_S_X, 1)
        self.towerT = Tower(TOWER_T_X, 2)
        self.towerD = Tower(TOWER_D_X, 3)

        self.towers = [self.towerS, self.towerT, self.towerD]

        self.reset_disks()