def buttons(self): x = self.x - self.y y = self.y buttons_setup = button.ButtonSetup(x, y, 7) startstop_button = button.Button(buttons_setup.position(2), self.colour_button, 'Start') clear_button = button.Button(buttons_setup.position(3), self.colour_button, 'Clear') turn_button = button.Button(buttons_setup.position(4), self.colour_button, 'Turn') random_button = button.Button(buttons_setup.position(5), self.colour_button, 'Random') menu_button = button.Button(buttons_setup.position(6), self.colour_button, 'Menu') buttons = [ startstop_button, clear_button, turn_button, random_button, menu_button ] for i in range(len(buttons)): buttons[i].x = buttons[i].x + self.y return buttons
def __init__(self, main): self.mode = "test" self.main = main self.screen = main.screen self.nn = main.nn #self.batchList = main.batchList self.font = pygame.font.SysFont(None, 30) #textrect = text.get_rect() #textrect.centerx = screen.get_rect().centerx #textrect.centery = screen.get_rect().centery self.buttonList = [ button.Button(self.screen, pygame.Rect(720, 400, 100, 30), "testt", 40, self.do_test), button.Button(self.screen, pygame.Rect(720, 100, 30, 30), ">", 40, self.button_0), button.Button(self.screen, pygame.Rect(685, 100, 30, 30), "<", 40, self.button_1), button.Button(self.screen, pygame.Rect(685, 250, 100, 30), "Output", 30, self.getDigitOutput) ] self.digitNum = 0 self.digitData = None self.digitOutput = None # used to render self.testOutput = ""
def __init__(self): # background self.background = dist.imagedist['screen_game'] self.rect = self.background.get_rect() self.rect.x = 0 self.rect.y = 0 # score self.scorePlayer = 0 self.scoreAI = 0 x = 15 y = 0.5 * dist.SCREEN_HEIGHT delta = dist.BTN_HEIGHT + dist.BTN_GAP_SPACE # button self.btnMenu = button.Button(dist.imagedist['btnMenu'], x, y) self.btnHuongDan = button.Button(dist.imagedist['btnHuongDan'], x, y + delta) self.btnThoat = button.Button(dist.imagedist['btnThoat'], x, y + 2 * delta) # label self.lblPlayer = label.Label('PLAYER', dist.FONTSIZE, 200, 330) self.lblScorePlayer = label.Label('SCORE', dist.FONTSIZE, 450, 400) self.lblValueScorePlayer = label.Label(str(self.scorePlayer), dist.FONTSIZE, 560, 400) self.lblAI = label.Label('COMPUTER', dist.FONTSIZE, 200, 120) self.lblScoreAI = label.Label('SCORE', dist.FONTSIZE, 450, 50) self.lblValueScoreAI = label.Label(str(self.scorePlayer), dist.FONTSIZE, 560, 50)
def __init__(self): # super(Menu, self).__init__() self.batDau = False self.x = 0 self.y = 0 self.image = dist.imagedist['screen_menu'] self.rect = self.image.get_rect() self.rect.x = 0 self.rect.y = 0 x = dist.SCREEN_WIDTH / 2 - dist.BTN_WIDTH / 2 y = dist.SCREEN_HEIGHT / 2 delta = dist.BTN_HEIGHT + dist.BTN_GAP_SPACE self.btnBatDau = button.Button(dist.imagedist['btnBatDau'], x, y) # de cuoi cung` se lam self.btnHuongDan = button.Button(dist.imagedist['btnHuongDan'], x, y + delta) self.btnThoat = button.Button(dist.imagedist['btnThoat'], x, y + 2 * delta) self.btnCapDo = map( lambda i: button.Button(dist.imagedist['btnCapMinimax%s' % (i)], x, y + (i - 1) * delta), range(1, 4, 1))
def setup_qwer(self): self.buttons = { pygame.K_q: button.Button('q', Q_ICON_PATH, Q_LOCATION, pygame.K_q), pygame.K_w: button.Button('w', W_ICON_PATH, W_LOCATION, pygame.K_w), pygame.K_e: button.Button('e', E_ICON_PATH, E_LOCATION, pygame.K_e), pygame.K_r: button.Button('r', R_ICON_PATH, R_LOCATION, pygame.K_r) }
def __init__(self, screen, rect, title, data, minValue=0, maxValue=0): self.screen = screen self.rect = rect self.colour = (200,200,200) # Background colour self.title = title self.font = pygame.font.SysFont(None, 30) self.data = data self.oldLength = len(self.data) # Initialise min/max values for the graph to render with self.minValue = minValue self.maxValue = maxValue for i in self.data: if i>self.maxValue: self.maxValue = i elif i<self.minValue: self.minValue = i self.scale = 0 self.buttonList = [ button.Button(self.screen, pygame.Rect(self.rect.right-40, self.rect.top+10, 30, 30), ">", 40, self.scale_up), button.Button(self.screen, pygame.Rect(self.rect.right-75, self.rect.top+10, 30, 30), "<", 40, self.scale_down) ]
def __init__(self): self.pygame_init() self.keep_looping = True self.event_var = None # ----------------------- self.pos = None self.current_action = None # ----------------------- self.clear_button = button.Button("clear", con.ORANGE, x=10, y=10, width=235, height=50, text="Clear", message="clear", font=self.font) self.randomButton = button.Button("random", con.ORANGE, x=255, y=10, width=235, height=50, text="Random", message="random", font=self.font) self.primary_color_btn = button.Button("primary", con.BLUE, x=500, y=10, width=90, height=235, text="P", message="primary", font=self.font) self.background_color_btn = button.Button("background", con.WHITE, x=500, y=255, width=90, height=235, text="B", message="background", font=self.font) self.main_window = button.Button("main", con.WHITE, x=10, y=70, width=480, height=420, text="main window", message="main window", font=self.font) self.buttons = [] self.buttons.append(self.clear_button) self.buttons.append(self.randomButton) self.buttons.append(self.main_window) self.buttons.append(self.primary_color_btn) self.buttons.append(self.background_color_btn) self.main_window.message = "none"
def __init__(self): Look.screen = pygame.display.set_mode((con.WIDTH, con.HEIGHT), pygame.RESIZABLE) # nazwa gry pygame.display.set_caption("szachy stupolowe", "szachy stupolowe") # board Look.plansza_img = pygame.image.load("assets/board.jpg") # gracz Look.white_pawn_img = pygame.image.load("assets/white_pawn_32px.png") Look.black_pawn_img = pygame.image.load("assets/black_pawn_32px.png") Look.white_queen_img = pygame.image.load("assets/white_queen_32px.png") Look.black_queen_img = pygame.image.load("assets/black_queen_32px.png") # Tekst ruchu Look.font = pygame.font.Font('freesansbold.ttf', 32) Look.textX = con.WIDTH / 2 - con.BOARD / 2 Look.textY = con.HEIGHT / 2 - con.BOARD / 2 - con.FIELD #Tworzenie przyciskow Look.restart_button \ = button.Button(con.BUTTON_LIME, (con.BOARD_X + con.BOARD + con.BOARD / con.SIZE + 2, con.BOARD_Y + 2), con.BUTTON_PROP, "Restart") Look.test_hit_button \ = button.Button(con.BUTTON_LIME, (con.WIDTH/100, con.HEIGHT/100), con.BUTTON_PROP, "Test bicia") Look.test_promo_button \ = button.Button(con.BUTTON_LIME, (con.WIDTH / 100, 2 * con.HEIGHT / 100 + 50), con.BUTTON_PROP, "Test wyniesienia") Look.test_win_button \ = button.Button(con.BUTTON_LIME, (con.WIDTH/100, 3 * con.HEIGHT/100 + 100), con.BUTTON_PROP, "Test wygranej") # ikona gry icon = pygame.image.load("assets/icon_32px.png") pygame.display.set_icon(icon)
def __init__(self, width=800, height=600): """ Initializes a Controller object Args: self (Controller): a Controller object width (int): the display's width height (int): the display's height Returns: (None): None """ pygame.font.init() self.width = width self.height = height self.windowSurface = pygame.display.set_mode((self.width, self.height)) pygame.display.set_caption("Skeleton Eats Three Apples Then Dies") self.background = pygame.Surface(self.windowSurface.get_size()) self.running = True self.player = character.Character((self.width / 2, self.height / 2), self.windowSurface) self.obstacles = pygame.sprite.Group() self.buttons = [ button.Button("Play Game", (self.width / 2 - 35, self.height / 2 - 15), 70, 30, (0, 0, 0), (0, 255, 0)), button.Button("Play Again?", (self.width / 2 - 35, self.height / 2 - 15), 70, 30, (0, 0, 0), (255, 0, 0)) ] self.setGame()
def show_main_menu(f1, f2, f3): global menu_title global menu_subti global menu_calls global menu_items global menu_titbg global menu_chars global menu_visib global menu_runan menu_runan = 0 menu_visib = True menu_titbg = shape.Shape(PATH_MENU_TIT_BG, "", "", 0, 235, 1, 1) menu_title = label.Label("TURTLE RACE", colors.get("title"), 0, 250, 48) menu_subti = label.Label("THE BEST BETTING GAME", colors.get("subti"), 150, 200, 18) menu_calls = [f1, f2, f3] menu_items = [ button.Button(" START ", 0, 30, callback1), button.Button(" SETTINGS ", 0, -30, callback2), button.Button(" ABOUT ", 0, -90, callback3), button.Button(" EXIT ", 0, -150, callback4) ] menu_chars = [ shape.Shape(PATH_MENU_CHAR1[0], "", "", 0, 350, 1, 1), shape.Shape(PATH_MENU_CHAR2[0], "", "", -400, 200, 1, 1), shape.Shape(PATH_MENU_CHAR3[0], "", "", 400, 0, 1, 1), shape.Shape(PATH_MENU_CHAR4[0], "", "", -300, -200, 1, 1), shape.Shape(PATH_MENU_CHAR5[0], "", "", 300, -200, 1, 1), ] menu_char_anim()
def __init__(self, title, message): title = basic.Label(title) main = table.Table() import app warningIcon = basic.Image( app.App.app.theme.get('warningdialog.warning', '', 'image')) if type(message) is list: if len(message) >= 1: main.tr() main.td(warningIcon, rowspan=len(message), style={'margin': 5}) main.td(basic.Label(message[0]), align=-1) for aMessage in message[1:]: main.tr() main.td(basic.Label(aMessage), align=-1, colspan=2) else: main.tr() main.td(warningIcon) main.td(basic.Label(message), align=-1, colspan=2) main.tr() self.okayButton = button.Button("Okay") self.okayButton.connect(CLICK, self.okayClicked) self.cancelButton = button.Button("Cancel") self.cancelButton.connect(CLICK, self.close) main.td(basic.Spacer(1, 1)) main.td(self.okayButton, align=1, style={'margin': 10}) main.td(self.cancelButton, align=-1, style={'margin': 10}) Dialog.__init__(self, title, main)
def __init__(self, value=None, **params): params.setdefault('cls', 'select') table.Table.__init__(self, **params) self.top_selected = button.Button(cls=self.cls + ".selected") table.Table.add(self, self.top_selected) #,hexpand=1,vexpand=1)#,0,0) self.top_selected.value = basic.Label(" ", cls=self.cls + ".option.label") self.top_arrow = button.Button(basic.Image(self.style.arrow), cls=self.cls + ".arrow") table.Table.add(self, self.top_arrow) #,hexpand=1,vexpand=1) #,1,0) self.options = table.Table() #style={'border':3}) self.options_first = None self.options.tr() self.spacer_top = basic.Spacer(0, 0) self.options.add(self.spacer_top) self.options.tr() self._options = table.Table(cls=self.cls + ".options") self.options.add(self._options) self.options.tr() self.spacer_bottom = basic.Spacer(0, 0) self.options.add(self.spacer_bottom) self.options.connect(BLUR, self._close, None) self.spacer_top.connect(CLICK, self._close, None) self.spacer_bottom.connect(CLICK, self._close, None) self.values = [] self.value = value
def end_game(): # Labels and buttons. end_gamex = end_game_label.get_width() // 2 end_gamey = end_game_label.get_height() // 2 # Exit button. exitx = windowWidth // 2 + 80 exity = end_gamey + 180 exitWidth = 100 exitHeight = 50 exit_button = button.Button(exitx, exity, exitWidth, exitHeight, EXITB, surface, "Exit!") # Replay button. replayx = windowWidth // 2 - 190 replayy = exity replayWidth = 180 replayHeight = 50 replay_button = button.Button(replayx, replayy, replayWidth, replayHeight, EXITB, surface, "Play again!") run = True while run: quit_event() surface.blit( end_game_label, (windowWidth // 2 - end_gamex, windowHeigth // 2 - end_gamey)) exit_button.draw_button() if mouse_over(exitx, exity, exitWidth, exitHeight): pygame.quit() sys.exit() pygame.display.update()
def __init__(self): self.list = area.List(width=350, height=150) okButton = button.Button("Okay", style={ 'width': 80, 'height': 28, 'margin': 8 }) okButton.connect(CLICK, self.okayClicked) cancelButton = button.Button("Cancel", style={ 'width': 80, 'height': 28, 'margin': 8 }) cancelButton.connect(CLICK, self.close) body = table.Table() body.tr() body.td(basic.Label("Select your teacher"), colspan=2) body.tr() body.td(self.list, colspan=2) body.tr() body.td(okButton) body.td(cancelButton) Dialog.__init__(self, basic.Label("Teachers"), body)
def CheckContinueGame(self, score, time, screen): myFont = pygame.font.SysFont(None, 16) textSurface = myFont.render( "TIME: " + str(round(time, 1)) + " seconds", True, BLACK) start_img = pygame.image.load( 'assets/play_again_btn.png').convert_alpha() score_btn = button.Button(screen_width / 3, screen_height / 3, score, 1) start_button = button.Button(screen_width / 3, screen_height / 3 + 60, start_img, 1) while True: screen = pygame.display.set_mode(size) screen.fill(WHITE) isClicked = start_button.draw(screen) screen.blit(textSurface, (screen_width / 3, screen_height / 3 + 120)) score_btn.draw(screen) for event in pygame.event.get(): if event.type == pygame.QUIT: sys.exit() if (event.type == pygame.MOUSEBUTTONDOWN and isClicked): print("clicked") screen.fill(WHITE) return True pygame.display.update()
def __init__(self, title, width, height): self.Title = title self.Height = height self.Width = width self.Screen = pygame.display.set_mode((self.Width, self.Height)) #This is to initialize the framerate (fps) self.Clock = pygame.time.Clock() #This color is a refrence to the color object, in there all different colors are defined self.Color = clr.Color() self.DefaultFont = pygame.font.SysFont(None, 30) #Initialize text messages self.StartText = Text.Text(self.Color.Black, self.DefaultFont, "Welcom to my pygame template!!!") #Initialize the soundprovider self.BackgroundMusic = sp.SoundProvider( "9th_Symphony_Finale_by_Beethoven.mp3") #Set the background music to play self.BackgroundMusic.Play(5) #Create all game characters here self.Player1 = c.Component(c.Position(400, 100), "enemy.png") #Create a button self.ExitButton = button.Button( 300, 250, 50, 200, self.Color.Red, Text.Text(self.Color.Black, self.DefaultFont, "Exit"), lambda: sys.exit()) self.StartButton = button.Button( 600, 250, 50, 200, self.Color.Green, Text.Text(self.Color.Black, self.DefaultFont, "Start"))
def start(self): self.background_group = pygame.sprite.LayeredDirty() self.game_group = pygame.sprite.LayeredDirty() self.ui_group = pygame.sprite.LayeredDirty() self.game.player_inputs = [] self.player_index = 0 res = self.game.game_resolution self.instructions = text.Text( "Click or press START to join the battle!", "small", V2(res.x/2, 40), multiline_width=400, ) self.instructions.offset = (0.5, 0) self.ui_group.add(self.instructions) self.back = button.Button(V2(10,10), "[*circle*] Back", "big", self.on_back) self.ui_group.add(self.back) self.start_btn = button.Button(V2(res.x/2,res.y - 40), "[*x*] Ready", "big", None) self.start_btn.disabled = True self.start_btn.offset = (0.5, 0) self.start_btn.visible = False self.ui_group.add(self.start_btn) self.sm = states.Machine(MultiplayerUIState(self)) self.game.input_mode = game.Game.INPUT_MULTIPLAYER self.player_panels = [] self.mode = "add_players"
def init_content(self): info_box = TextBox(200, 400, bgcolor=colors['white'], alpha=150) info_box.set_position([self.terrain.pixel_size[0] + 25, 250]) info_box.add_default_text("Tower Defence\n\nPlace turrets on the map to protect your base from enemies. You gain money by winning rounds and killing enemies.", align="center") self.box_group = pygame.sprite.Group(info_box) cannon_button = button.TowerButton(CannonTower, self.terrain, info_box) artillery_button = button.TowerButton(ArtilleryTower, self.terrain, info_box) self.tower_buttons = GridGroup(pos=[self.terrain.pixel_size[0] + 25, 15], cols=3, rows=3, margin=10) self.tower_buttons.add(cannon_button, artillery_button) for _ in range(7): empty = button.Button(colors['white'], 60, 60) self.tower_buttons.add(empty) empty.lock() start_button = button.Button(colors['green'], 200, 90) start_button.set_position((self.terrain.pixel_size[0] + 25, 670)) start_button.set_icon_text("Start", font_size=50) start_button.set_description("Start round 1", info_box) start_button.function = self.start_round self.description = info_box self.start_button = start_button self.buttons = pygame.sprite.Group(start_button)
def __init__(self, surface): self.surface = surface self.iso = isoboard.IsoBoard.createBaseBoard() self.is_main = True self.moving = False self.addColButton = button.Button(self.makeText("Add Column"), self.addCol, rect=pygame.Rect(0, 0, 100, 50)) self.addRowButton = button.Button(self.makeText("Add Row"), self.addRow, rect=pygame.Rect(105, 0, 100, 50)) self.selectedTile = None self.heightChanging = False self.images = [] self.spritesRect = pygame.Rect(105, self.surface.get_rect().height - 100, self.surface.get_rect().width - 110, 100) self.imageRects = [] self.spritePaths = [] self.imageLabels = [] self.changingSprite = False self.saveMapButton = button.Button( self.makeText("Save"), self.exportToJSON, rect=pygame.Rect(0, self.surface.get_rect().height - 50, 100, 50)) self.loadMapButton = button.Button( self.makeText("Open"), self.openMapFile, rect=pygame.Rect(0, self.surface.get_rect().height - 100, 100, 50)) self.main_loop()
def __init__(self, window, root, title="File Chooser"): self.__window = window self.__size_y, self.__size_x = self.__window.getmaxyx() self.__root = os.path.expanduser(root) self.__cwd = self.__root self.__title = title self.__action = FILE_CHOOSER_ACTION_OPEN self.__show_hidden = False self.__cursor_idx = 0 listgen = os.walk(self.__cwd) [root, dirs, files] = listgen.next() dirs.sort() filelist = [] for entry in dirs: if not entry.startswith('.'): filelist.append(entry) print(filelist) self.refresh() # dialog items self.__diredit = editbox.EditBox(self.__window, self.__size_x-4, 3, 2, self.__cwd) self.__filelist = listbox.ListBox(self.__window, self.__size_y-10, self.__size_x-4, 5, 2, files) self.__ok_button = button.Button(self.__window, self.__size_y-3, 15, "OK") self.__cancel_button = button.Button(self.__window, self.__size_y-3, 3, "Cancel")
def buttons(self): button_setup = b.ButtonSetup(int(self.x / 2), self.y, 5) back_button_setup = b.ButtonSetup(self.x, self.y, 5) buttons = [] for i in range(int(len(self.cell_size_options) / 2)): size = button_setup.position(i + 1) buttons.append( b.Button(size, self.colour_button, str(self.cell_size_options[i]))) for j in range(int(len(self.cell_size_options) / 2)): size = button_setup.position(j + 1) size[0] = int(size[0] + self.x / 2) buttons.append( b.Button( size, self.colour_button, str(self.cell_size_options[ j + int(len(self.cell_size_options) / 2)]))) back_button = b.Button(back_button_setup.position(5), self.colour_button, 'back') for k in range(len(self.cell_size_options)): if self.settings[1] == self.cell_size_options[k]: buttons[k].colour = self.colour_button_chosen buttons.append(back_button) return buttons
def initialize_buttons(GAME): button_width, button_height = 400, 60 button_x, button_y = GAME.screen_x-button_width, GAME.screen_y-button_height resolution_button = button.Button(button_x*0.5, button_y*0.5, button_width, button_height, (0, 255, 0), 0) button_outline = button.Button(button_x*0.5, button_y*0.5, button_width, button_height, (0, 0, 0), 3) return resolution_button, button_outline
def make_descriptions(self): self.tiber = button.Button(image=IMAGES["tiber"], x=25, y=450) self.tiber.scale = 4.0 self.tiber_descript = text.TextBox(x=100, y=550, font_name=config.FONT_TYPE, font_size=self.font_size, color=(0, 0, 0, 255), text=""" A greedy elf warrior, in spite of Tiberius's Christmas spirit he was doomed to a life of no presents. Now he returns for his rightful tribute.""") self.gwen = button.Button(image=IMAGES["gwen"], x=25, y=175) self.gwen.scale = 4.0 self.gwen_descript = text.TextBox(x=100, y=300, font_name=config.FONT_TYPE, font_size=self.font_size, color=(0, 0, 0, 255), text=""" Gwendayln was once a promissing young snowmancer until she turned rotten with greed.""")
def buttons(self): button_setup = b.ButtonSetup(self.x, self.y, rows=5, columns=9, x_margin=0) survive_text = b.Button( button_setup.position(row=1, column=1, column_size=9), self.screen_fill, 'When cell survive') survive_buttons = [] for i in range(9): survive_buttons.append( b.Button(button_setup.position(row=2, column=i + 1), self.colour_button, '{}'.format(i))) alive_text = b.Button( button_setup.position(row=3, column=1, column_size=9), self.screen_fill, 'When cell is born') alive_buttons = [] for j in range(9): alive_buttons.append( b.Button(button_setup.position(row=4, column=j + 1), self.colour_button, '{}'.format(j))) back_button = b.Button( button_setup.position(row=5, column=1, column_size=9), self.colour_button, 'back') buttons = [ survive_text, survive_buttons, alive_text, alive_buttons, back_button ] return buttons
def menu(self): newgame = button.Button(black, 170, 40, 10, 150, "NEW GAME", 20) options_button = button.Button(black, 170, 40, 10, 200, "OPTIONS", 20) score_button = button.Button(black, 170, 40, 10, 250, "SCOREBOARD", 20) quitbutton = button.Button(black, 170, 40, 10, 360, "QUIT", 20) options_ok = button.Button(black, 170, 40, 370, 400, "OK", 20, 255, True) music_button = button.Button(black, 170, 40, 370, 200, "Music", 20, 255, True) sound_button = button.Button(black, 170, 40, 370, 300, "Sounds", 20, 255, True) name_button = button.Button(black, 150, 40, 470, 0, str(self.name), 20, 150) options_box = button.Button(white, 300, 400, 320 + 50, 240, "", 20, 150, True) score_box = button.Button(white, 300, 400, 320 + 50, 240, "", 20, 150, True) self.button_group.add(newgame, options_button, quitbutton, score_button, name_button) music_button.active(self.settings[0]) sound_button.active(self.settings[1]) while True: mouse = pygame.mouse.get_pos() for event in pygame.event.get(): if event.type == QUIT: quit() if event.type == MOUSEBUTTONUP: for pressed_button in self.button_group: pressed_button.active(0) if quitbutton.rect.collidepoint(mouse): return if event.type == pygame.MOUSEBUTTONDOWN: for pressed_button in self.button_group: if pressed_button.rect.collidepoint(pygame.mouse.get_pos()): pressed_button.active() self.window.blit(self.background, (0, 0)) self.button_group.draw(self.window) pygame.display.update()
def __init__(self, score, width=640, height=480): self.game = bem.Game(width, height, "burn1.jpg") # 20pixels from the edge (640,480) self.newgame = button.Button(black, 230, 70, 20, 390, "NEW GAME") self.menubutton = button.Button(black, 130, 70, 300, 390, "MENU") self.quitbutton = button.Button(black, 130, 70, 490, 390, "QUIT") self.button_group = pygame.sprite.Group() self.button_group.add(self.quitbutton, self.newgame, self.menubutton) self.checked_score_values = self.game.check_score()[1] self.checked_settings = self.game.check_settings() self.game.update_score(self.checked_settings['name'], score) clock = pygame.time.Clock() fps = 120 while True: for event in pygame.event.get(): if event.type == pygame.QUIT: quit() if event.type == pygame.MOUSEBUTTONUP: self.quitbutton.active(0) self.newgame.active(0) self.menubutton.active(0) if self.quitbutton.rect.collidepoint( pygame.mouse.get_pos()): quit() if self.newgame.rect.collidepoint(pygame.mouse.get_pos()): return if self.menubutton.rect.collidepoint( pygame.mouse.get_pos()): menu.Menu() return if event.type == pygame.MOUSEBUTTONDOWN: if self.quitbutton.rect.collidepoint( pygame.mouse.get_pos()): self.quitbutton.active() if self.newgame.rect.collidepoint(pygame.mouse.get_pos()): self.newgame.active() if self.menubutton.rect.collidepoint( pygame.mouse.get_pos()): self.menubutton.active() self.game.window.blit(self.game.background, (0, 0)) self.button_group.draw(self.game.window) if score > self.checked_score_values[0]: self.game.write(" NEW HIGH SCORE! ", 50, [640 / 2, 480 / 2 - 100], red, self.game.window, white, 'center', 200) self.game.write(" Score: " + str(score) + " ", 40, [320, 20], black, self.game.window, white, 'center') clock.tick(fps) pygame.display.update()
def menu(g_settings, screen, text): start(g_settings, screen, text) b1 = btt.Button(screen, g_settings.button1_position, "Show rules", g_settings) b2 = btt.Button(screen, g_settings.button2_position, "Start a new game", g_settings) check_buttons(b1, b2, text, g_settings) if g_settings.show_rules == True: text.show_rules()
def create_buttons(): global menu_button, user_info_button, records_button, exit_button menu_button = button.Button(menu_display, 90, 50, 210, 50, "Menu", False) user_info_button = button.Button(menu_display, 90, 133, 210, 50, "Fill your info", False) records_button = button.Button(menu_display, 90, 216, 210, 50, "Records", False) exit_button = button.Button(menu_display, 90, 299, 210, 50, "Exit", True)
def loadButtons(self): self.boardButtons.append( button.Button(20, 40, 120, 40, "Quit Game", self.quitGame)) self.boardButtons.append( button.Button(240, 40, 120, 40, "Play Again", self.playAgain)) self.boardButtons.append( button.Button(460, 40, 120, 40, "Show Solution", self.showSolution))
def init(): for i in range(10): sprite_box = pygame.Rect(830, 30 * (i + 1) + 30, 25, 25) info_box = pygame.Rect(1110, 30 * (i + 1) + 20, 50, 30) sprite_button = button_class.Button(sprite_box, use_button, i) text_button = button_class.Button(info_box, info_button, i) settings.buttons.append(sprite_button) settings.buttons.append(text_button)