def startup(self, game): self.game = game self.current_player = self.game.deal_queue[ self.game.current_player_index] self.player_buttons = ButtonGroup() self.animations = pg.sprite.Group() self.timer = 0 self.time_limit = 600 if self.current_player is self.game.dealer: self.next = "Show Cards" else: self.next = "Player Turn" if self.current_player is self.game.player: x, y = self.screen_rect.centerx - 120, 695 NeonButton((x, y - 55), "Stay", self.stay, None, self.player_buttons) NeonButton((x, y + 55), "Pass", self.stay_out, None, self.player_buttons) if self.current_player is self.game.dealer: stays = [x for x in self.game.players if x.stayed] if not stays: self.stay() else: self.current_player.play_hand(self.game)
def make_buttons(self, screen_rect): buttons = ButtonGroup() y = screen_rect.bottom - NeonButton.height - 10 lobby = NeonButton((20, y), "Lobby", self.back_to_lobby, None, buttons) NeonButton((lobby.rect.right + 20, y), "Roll", self.roll, None, buttons) return buttons
def startup(self, game): self.game = game sr = self.screen_rect title = Label(self.font, 128, "Two-Card Guts", "gold3", {"midtop": (sr.centerx, 5)}, bg=prepare.FELT_GREEN) title.image.set_alpha(160) title2 = Label(self.font, 96, "${} Ante".format(self.game.bet), "darkred", {"midtop": (sr.centerx, title.rect.bottom)}, bg=prepare.FELT_GREEN) title2.image.set_alpha(140) self.titles = [title, title2] self.player_buttons = ButtonGroup() w, h = NeonButton.width, NeonButton.height pos = sr.centerx - (w // 2), sr.centery - (h // 2) NeonButton(pos, "Ante Up", self.start_game, None, self.player_buttons) pos2 = sr.centerx - (w // 2), sr.centery + (h // 2) + 50 self.tutorial_button = NeonButton(pos2, "Tutorial", self.to_tutorial, None, self.player_buttons) self.advisor.queue_text("Ante Up ${} to play".format(self.game.bet), dismiss_after=2500) self.advisor.queue_text("Press Tutorial to learn how to play", dismiss_after=2500) self.advisor.queue_text("Press the Lobby button to exit", dismiss_after=2500)
def make_buttons(self): self.buttons = ButtonGroup() self.new_game_button = NeonButton( (0, 0), "Change", self.new_game_click, None, self.buttons) self.quick_bet_button = NeonButton( (0, 0), "Again", self.quick_bet_click, None, self.buttons) self.quick_bet_button.rect.midbottom = (self.screen_rect.centerx, self.screen_rect.centery - 30) self.new_game_button.rect.center = (self.screen_rect.centerx, self.screen_rect.centery + 30)
def __init__(self): """Initialise the bingo game""" # self.verbose = False self.sound_muted = prepare.ARGS['debug'] # self.screen_rect = pg.Rect((0, 0), prepare.RENDER_SIZE) self.auto_pick = S['debug-auto-pick'] # self.ui = common.ClickableGroup() # self.lobby_button = NeonButton(S['lobby-position'], 'Lobby', self.return_to_lobby) self.new_game_button = NeonButton( S['new-game-position'], 'New', lambda x: self.restart_game(None, None)) # # The controls to allow selection of different numbers of cards self.card_selector = cardselector.CardSelector('card-selector', self) self.card_selector.linkEvent(events.E_NUM_CARDS_CHANGED, self.change_number_of_cards) self.ui.append(self.card_selector.ui) # self.create_card_collection() self.ui.extend(self.cards) # self.winning_pattern = patterns.PATTERNS[0] # self.pattern_buttons = common.DrawableGroup() self.debug_buttons = common.DrawableGroup() self.buttons = common.DrawableGroup([self.pattern_buttons]) # if prepare.DEBUG: self.buttons.append(self.debug_buttons) # super(Bingo, self).__init__() # # The machine for picking balls self.ball_machine = ballmachine.BallMachine('ball-machine', self) self.ball_machine.start_machine() self.ui.append(self.ball_machine.buttons) # self.all_cards = common.DrawableGroup() self.all_cards.extend(self.cards) self.all_cards.extend(self.dealer_cards) # B.linkEvent(events.E_PLAYER_PICKED, self.player_picked) B.linkEvent(events.E_PLAYER_UNPICKED, self.player_unpicked) B.linkEvent(events.E_CARD_COMPLETE, self.card_completed) # self.current_pick_sound = 0 self.last_pick_time = 0
def make_buttons(self, screen_rect): buttons = ButtonGroup() x, y = (screen_rect.centerx - (NeonButton.width // 2) - 170, screen_rect.bottom - (NeonButton.height + 10)) NeonButton((x, y), "Lobby", self.back_to_x, "lobby", buttons) x = screen_rect.centerx - (NeonButton.width // 2) + 170 NeonButton((x, y), "Back", self.back_to_x, "stats_menu", buttons, bindings=[pg.K_ESCAPE]) return buttons
def make_main_buttons(self, screen_rect): buttons = ButtonGroup() pos = (9, screen_rect.bottom-(NeonButton.height+11)) NeonButton(pos, "Credits", 32, self.change_state, "credits", buttons) pos = (screen_rect.right-(NeonButton.width+10), screen_rect.bottom-(NeonButton.height+11)) NeonButton(pos, "High Scores", 28, self.change_state, "high_scores", buttons) pos = (screen_rect.centerx-(NeonButton.width//2), screen_rect.bottom-(NeonButton.height+11)) NeonButton(pos, "Exit", 32, self.exit_game, None, buttons, bindings=[pg.K_ESCAPE]) rect_style = (screen_rect.left, screen_rect.top, 150, 95) return buttons
def make_player_buttons(self, free_ride): self.player_buttons = ButtonGroup() w, h = NeonButton.width, NeonButton.height sr = self.screen_rect pos = sr.centerx - (w // 2), sr.centery + 120 text = "OK" if free_ride else "Ante Up" NeonButton(pos, text, self.new_game, None, self.player_buttons)
def make_buttons(self): side_margin = 10 vert_space = 12 left = self.screen_rect.right - (NeonButton.width + side_margin) top = self.screen_rect.bottom - ( (NeonButton.height * 5) + vert_space * 5) self.hit_button = NeonButton((left, top), "Hit", self.hit_click) top += NeonButton.height + vert_space self.stand_button = NeonButton((left, top), "Stand", self.stand) top += NeonButton.height + vert_space self.double_down_button = NeonButton((left, top), "Double", self.double_down) top += NeonButton.height + vert_space self.split_button = NeonButton((left, top), "Split", self.split_hand) self.buttons = ButtonGroup(self.hit_button, self.stand_button, self.double_down_button, self.split_button)
def make_buttons(self): x = self.screen_rect.centerx - (NeonButton.width // 2) y = 600 new_game = NeonButton((x, y), "New", self.load_or_new, False, self.buttons, visible=False) y = new_game.rect.bottom + 50 load_game = NeonButton((x, y), "Load", self.load_or_new, True, self.buttons, visible=False) return new_game, load_game
def __init__(self): super(DealerTurn, self).__init__() pos = (self.screen_rect.right - (NeonButton.width + 10), self.screen_rect.bottom - (NeonButton.height + 15)) self.lobby_button = NeonButton(pos, "Lobby", self.back_to_lobby, bindings=[pg.K_ESCAPE])
def __init__(self): super(VideoPoker, self).__init__() w, h = prepare.RENDER_SIZE self.screen_rect = pg.Rect((0, 0), (w, h)) self.machine = Machine((0, 0), (w - 300, h)) pos = (self.screen_rect.right - 330, self.screen_rect.bottom - 120) self.lobby_button = NeonButton(pos, "lobby", self.back_to_lobby) self.casino_player = None
def __init__(self): super(ShowResults, self).__init__() pos = (self.screen_rect.right - (NeonButton.width + 10), self.screen_rect.bottom - (NeonButton.height + 15)) self.lobby_button = NeonButton(pos, "Lobby", self.back_to_lobby, bindings=[pg.K_ESCAPE]) self.coin_sound = prepare.SFX["coins"]
def make_buttons(self): self.buttons = ButtonGroup() side_margin = 10 vert_space = 15 left = self.screen_rect.right - (NeonButton.width + side_margin) top = self.screen_rect.bottom - ( (NeonButton.height * 5) + vert_space * 4) self.deal_button = NeonButton((left, top), "Deal", self.deal, None, self.buttons)
def make_buttons(self, screen_rect): buttons = ButtonGroup() pos = (self.screen_rect.right - (NeonButton.width + 10), self.screen_rect.bottom - (NeonButton.height + 15)) NeonButton(pos, "Lobby", self.back_to_lobby, None, buttons, bindings=[pg.K_ESCAPE]) return buttons
def __init__(self): super(Betting, self).__init__() self.make_buttons() pos = (self.screen_rect.right - (NeonButton.width + 10), self.screen_rect.bottom - (NeonButton.height + 15)) self.lobby_button = NeonButton(pos, "Lobby", self.back_to_lobby, None, self.buttons, bindings=[pg.K_ESCAPE])
def __init__(self): super(ShowResults, self).__init__() self.buttons = ButtonGroup() pos = (self.screen_rect.right - (NeonButton.width + 10), self.screen_rect.bottom - (NeonButton.height + 10)) self.lobby_button = NeonButton(pos, "Lobby", self.warn, None, self.buttons, bindings=[pg.K_ESCAPE])
def make_buttons(self, games, screen_rect, col=2): spacer_x = 20 spacer_y = 20 start_y = 410 start_x = (screen_rect.w - NeonButton.width * col - spacer_x * (col - 1)) // 2 buttons = ButtonGroup() for i, game in enumerate(games): y, x = divmod(i, col) pos = (start_x + x * (NeonButton.width + spacer_x), start_y + y * (NeonButton.height + spacer_y)) button = NeonButton(pos, game, self.view_game_stats, game, buttons) pos = (screen_rect.centerx - (NeonButton.width // 2), screen_rect.bottom - (NeonButton.height + 10)) NeonButton(pos, "Lobby", self.back_to_lobby, None, buttons, bindings=[pg.K_ESCAPE]) return buttons
def make_main_buttons(self, screen_rect): buttons = ButtonGroup() pos = (9, screen_rect.bottom - (NeonButton.height + 11)) NeonButton(pos, "Credits", self.change_state, "credits", buttons) pos = (screen_rect.right - (NeonButton.width + 10), screen_rect.bottom - (NeonButton.height + 11)) NeonButton(pos, "Stats", self.change_state, "stats_menu", buttons) pos = (screen_rect.centerx - (NeonButton.width // 2), screen_rect.bottom - (NeonButton.height + 11)) NeonButton(pos, "Exit", self.exit_game, None, buttons, bindings=[pg.K_ESCAPE]) rect_style = (screen_rect.left, screen_rect.top, 150, 95) Button(rect_style, buttons, idle_image=prepare.GFX["atm_dim"], hover_image=prepare.GFX["atm_bright"], call=self.change_state, args="atm") return buttons
def __init__(self): super(CreditsScreen, self).__init__() self.screen = pg.Rect((0, 0), prepare.RENDER_SIZE) self.next = "lobby" self.font = prepare.FONTS["Saniretro"] self.dev_names = DEVELOPERS self.artist_names = ARTISTS self.assets_names = ASSETS_NAMES self.software_names = SOFTWARE self.zipper_blocks = [] self.zipper_block = None self.chip_curtain = None pos = (self.screen.centerx - (NeonButton.width // 2), self.screen.bottom - NeonButton.height - 10) self.done_button = NeonButton(pos, "Lobby", self.back_to_lobby) self.use_music_handler = False
def __init__(self): self.done = False self.quit = False self.next = None rect = self.advisor_back.get_rect().union( self.advisor_front.get_rect()) self.advisor_button = Button(rect, call=self.toggle_advisor) self.buttons = ButtonGroup() pos = (self.screen_rect.right - (NeonButton.width + 10), self.screen_rect.bottom - (NeonButton.height + 10)) lobby_button = NeonButton(pos, "Lobby", self.back_to_lobby, None, self.buttons, bindings=[pg.K_ESCAPE]) self.animations = pg.sprite.Group()
def __init__(self): super(Keno, self).__init__() self.screen_rect = pg.Rect((0, 0), prepare.RENDER_SIZE) self.game_started = False self.font = prepare.FONTS["Saniretro"] self.advisor = KenoAdvisor() self.mock_label = Label(self.font, 64, 'KENO [WIP]', 'gold3', {'center': (672, 102)}) b_width = 360 b_height = 90 side_margin = 10 w = self.screen_rect.right - (b_width + side_margin) h = self.screen_rect.bottom - (b_height + 15) self.buttons = ButtonGroup() NeonButton((w, h), "Lobby", self.back_to_lobby, None, self.buttons) self.turns = 16 self.play_max_active = False ball_path = os.path.join('resources', 'keno', 'balls', '64x64', 'sheet.png') ball_sheet = pg.image.load(ball_path).convert_alpha() self.balls = tools.strip_from_sheet(ball_sheet, (0, 0), (64, 64), 10, 8) self.keno_card = KenoCard(self.balls) #self.keno_card = KenoCard() -- no ball graphics self.prev_spot_count = 0 self.pay_table = PayTable(self.keno_card) self.pay_table.update(0) self.round_history = RoundHistory(self.keno_card) self.alert = None self.quick_picking = Action( pg.Rect(370, 760, 150, 75), Label(self.font, 32, 'QUICK PICK', 'gold3', {'center': (0, 0)}), self.activate_quick_pick) self.betting = Action( pg.Rect(682, 760, 150, 75), Label(self.font, 32, 'BET 1', 'gold3', {'center': (0, 0)}), self.activate_bet) self.clearing = Action( pg.Rect(526, 760, 150, 75), Label(self.font, 32, 'CLEAR', 'gold3', {'center': (0, 0)}), self.activate_clear) self.playing = Action( pg.Rect(838, 760, 156, 75), Label(self.font, 32, 'PLAY', 'gold3', {'center': (0, 0)}), self.activate_play) self.playing_max = Action( pg.Rect(838, 840, 156, 75), Label(self.font, 32, 'PLAY MAX', 'gold3', {'center': (0, 0)}), self.activate_playmax) self.actions = { 'quick pick': self.quick_picking, 'betting': self.betting, 'clearing': self.clearing, 'playing': self.playing, 'playing max': self.playing_max, } self.gui_widgets = { 'title': self.mock_label, 'card': self.keno_card, 'quick_pick': self.quick_picking, 'play': self.playing, 'play_max': self.playing_max, 'pay_table': self.pay_table, 'round_history': self.round_history, 'balance': None, 'bet_action': None, 'clear': None, 'bet': None, 'won': None, 'spot': None, }