def __init__(self, x, y, game): self.x = x self.y = y self.WIDTH = 720 self.HEIGHT = 100 self.BORDER_THICKNESS = 5 self.game = game self.clear_button = TextButton( self.x + self.WIDTH - 150, self.y + 25, 100, 50, (128, 128, 128), "Clear") self.eraser_button = TextButton( self.x + self.WIDTH - 300, self.y + 25, 100, 50, (128, 128, 128), "Eraser") self.color_buttons = [Button(self.x + 20, self.y + 5, 30, 30, self.COLORS[0]), Button(self.x + 50, self.y + 5, 30, 30, self.COLORS[1]), Button(self.x + 80, self.y + 5, 30, 30, self.COLORS[2]), Button(self.x + 20, self.y + 35, 30, 30, self.COLORS[3]), Button(self.x + 50, self.y + 35, 30, 30, self.COLORS[4]), Button(self.x + 80, self.y + 35, 30, 30, self.COLORS[5]), Button(self.x + 20, self.y + 65, 30, 30, self.COLORS[6]), Button(self.x + 50, self.y + 65, 30, 30, self.COLORS[7]), Button(self.x + 80, self.y + 65, 30, 30, self.COLORS[8])]
def __init__(self): ''' Constructs a MainMenu Object :pre: an Arcade window object exists so a View can be displayed on it ''' super().__init__() self.button_list = [] play_button = TextButton(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 3, self.play_game, "Start") quit_button = TextButton(SCREEN_WIDTH / 2, (SCREEN_HEIGHT / 3) - 55, self.quit_game, "Quit") self.button_list.append(play_button) self.button_list.append(quit_button)
def __init__(self, x, y, width, height, game): """ :param x: int :param y: int :param width: int :param height: int :param game: Game object """ self.x = x self.y = y self.width = width self.height = height self.game = game self.clear_button = TextButton(self.x + self.width - 125, self.y+self.height/2-25, 100, 50, "Clear") self.eraser_button = TextButton(self.x + self.width - 250, self.y+self.height/2-25, 100, 50, "Erase") self.color_buttons = [Button(self.x+25+50*i, self.y+self.height/2-25, 50, 50, c) for i, c in enumerate(COLORS)]
def __init__(self, x, y, game): self.x = x self.y = y self.WIDTH = 608 self.HEIGHT = 80 self.BORDER_THICKNESS = 3 self.game = game self.clear_button = TextButton(self.x + self.WIDTH - 150, self.y + 15, 100, 50, (128, 128, 128), "Clear") self.eraser_button = TextButton(self.x + self.WIDTH - 300, self.y + 15, 100, 50, (128, 128, 128), "Eraser") self.color_buttons = [Button(self.x + 20, self.y + 5, 20, 20, self.COLORS[0]), Button(self.x + 40, self.y + 5, 20, 20, self.COLORS[1]), Button(self.x + 60, self.y + 5, 20, 20, self.COLORS[2]), Button(self.x + 20, self.y + 25, 20, 20, self.COLORS[3]), Button(self.x + 40, self.y + 25, 20, 20, self.COLORS[4]), Button(self.x + 60, self.y + 25, 20, 20, self.COLORS[5]), Button(self.x + 20, self.y + 45, 20, 20, self.COLORS[6]), Button(self.x + 40, self.y + 45, 20, 20, self.COLORS[7]), Button(self.x + 60, self.y + 45, 20, 20, self.COLORS[8])]
def __init__(self): """ Constructs a new MainMenuGUI object and sets the background color of the window. :return: returns none. :pre: The MainMenu class has been run and the user pressed the play_button """ super().__init__() self.button_list = [] self.button_1 = TextButton(110, 320, self.number_1, "1") self.button_2 = TextButton(250, 320, self.number_2, "2") self.button_3 = TextButton(390, 320, self.number_3, "3") self.button_4 = TextButton(530, 320, self.number_4, "4") self.button_5 = TextButton(670, 320, self.number_5, "5") self.button_list.append(self.button_1) self.button_list.append(self.button_2) self.button_list.append(self.button_3) self.button_list.append(self.button_4) self.button_list.append(self.button_5)
def __init__(self): pygame.init() self.screen = pygame.display.set_mode((600, 560)) pygame.display.set_caption("sortingVisualizer") self.clock = pygame.time.Clock() self.bars = [Bar() for i in range(48)] self.bubbleSortButton = TextButton(self.screen, 'BubbleSort', 12, 520) self.insertionSortButton = TextButton(self.screen, 'InsertionSort', 195, 520) self.startButton = ImageButton(self.screen, 'assets/start.png', 495, 514) self.resetButton = ImageButton(self.screen, 'assets/reset.png', 540, 514) self.started = False self.algorithm = self.bubbleSort self.bubbleSortButton.text_color = WHITE while True: self.check_events() self.update_screen()
def __init__(self, win, conn: Network=None): pygame.font.init() self.win = win self.conn = conn self.leader_board = LeaderBoard(50, 125) self.board = Board(310, 125) self.top_bar = TopBar(10, 10, 1280, 100) self.top_bar.change_round(1) self.players = [] self.skip_button = TextButton(90, 800, 125, 50, (255, 255, 0), "Skip") self.bottom_bar = BottomBar(310, 880, self) self.chat = Chat(1050, 120) self.draw_color = (0, 0, 0)
def __init__(self, win, connection=None): pygame.font.init() self.connection = connection self.win = win self.leaderboard = Leaderboard(50, 125) self.board = Board(305, 125) self.top_bar = TopBar(10, 10, 1280, 100) self.top_bar.change_round(1) self.players = [] self.skip_button = TextButton(85, 830, 125, 60, (255, 255, 0), "Skip") self.bottom_bar = BottomBar(305, 880, self) self.chat = Chat(1050, 125) self.draw_color = (0, 0, 0) self.drawing = False
def __init__(self): ''' Constructs a MainMenu Object :pre: an Arcade window object exists so a View can be displayed on it ''' super().__init__() self.button_list = [] play_button = TextButton(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 3 + 100, self.play_game, "Start") easy_button = TextButton(SCREEN_WIDTH / 2, (SCREEN_HEIGHT / 3 + 50), self.easy_mode, "Easy AI Mode") mid_button = TextButton(SCREEN_WIDTH / 2, (SCREEN_HEIGHT / 3), self.mid_mode, " Medium AI Mode") hard_button = TextButton(SCREEN_WIDTH / 2, (SCREEN_HEIGHT / 3 - 50), self.hard_mode, "Hard AI Mode") quit_button = TextButton(SCREEN_WIDTH / 2, (SCREEN_HEIGHT / 3) - 100, self.quit_game, "Quit") self.button_list.append(play_button) self.button_list.append(easy_button) self.button_list.append(mid_button) self.button_list.append(hard_button) self.button_list.append(quit_button)
def __init__(self, win, connection=None): pygame.font.init() self.connection = connection self.win = win self.leaderboard = Leaderboard(30, 95) self.board = Board(200, 100) self.top_bar = TopBar(10, 10, 1080, 80) self.bottom_bar = BottomBar(200, 714, self) self.top_bar.change_round(1) self.players = [] self.chat = Chat(860, 95) self.skip_button = TextButton(70, 700, 100, 45, (255, 255, 0), "Skip") self.draw_color = (0, 0, 0) self.drawing = False
def __init__(self, life): super().__init__() self.font = pygame.font.SysFont("default", 24) self.textColor = (255, 0, 0) self.backgroundColor = (69, 69, 69) self.life = life self.startButton = TextButton('Start', (10, 10, 150, 50), self.onStart) self.stopButton = TextButton('Stop', (10, 10, 150, 50), self.onStop) self.clearButton = TextButton('Clear', (10, 80, 150, 25), self.onClear) self.randomButton = TextButton('Random', (10, 110, 150, 25), self.onRandomFill) self.stencils = [ TemplateButton('line', ['001', '010', '100'], lambda: self.selectTool('line')) ] stencilsDefs = Stencils().stencil for name in stencilsDefs: but = TemplateButton(name, stencilsDefs[name], lambda name=name: self.selectTool(name)) self.stencils.append(but)
def __init__(self): self.WIDTH = 1300 self.HEIGHT = 1000 self.win = pygame.display.set_mode((self.WIDTH, self.HEIGHT)) self.leaderboard = Leaderboard(50, 125) self.board = Board(305, 125) self.top_bar = TopBar(10, 10, 1280, 100) self.top_bar.change_round(1) self.players = [ Player("Tim"), Player("Joe"), Player("Bill"), Player("Jeff"), Player("TBob") ] self.skip_button = TextButton(85, 830, 125, 60, (255, 255, 0), "Skip") self.bottom_bar = BottomBar(305, 880, self) self.chat = Chat(1050, 125) self.draw_color = (0, 0, 0) for player in self.players: self.leaderboard.add_player(player)