示例#1
0
    def __init__(self, screen):
        self.start_button = StartButton(screen)
        self.exit_button = ExitButton(screen)

        self.background = pygame.sprite.Group()
        self.background.add(MenuBackground(screen))

        self.menu_sprites = pygame.sprite.Group()
        self.menu_sprites.add(LogoSprite(screen[0]), self.start_button,
                              self.exit_button)
示例#2
0
    def on_show(self):
        result = self.game.calculate_winner()
        self.bank = self.game.user.get_bank()

        #create message variable
        msg = ''

        # dEcide message based on result
        if result == None:
            msg = 'It\'s a tie'
        if result:
            msg = 'You won this hand'
        if result == False:
            if self.game.user.bust():
                msg = 'You bust'
            else:
                msg = 'The dealer won'

        self.msg = msg

        quit_button = ExitButton(100, 650, 90, 40, text="Quit")
        self.button_list.append(quit_button)

        submit_button = SubmitButton(self.WIDTH / 2 + 200,
                                     self.HEIGHT / 2 + 15,
                                     110,
                                     40,
                                     text="Continue")
        self.button_list.append(submit_button)
示例#3
0
class MenuState:
    def __init__(self, screen):
        self.start_button = StartButton(screen)
        self.exit_button = ExitButton(screen)

        self.background = pygame.sprite.Group()
        self.background.add(MenuBackground(screen))

        self.menu_sprites = pygame.sprite.Group()
        self.menu_sprites.add(LogoSprite(screen[0]), self.start_button,
                              self.exit_button)

    def update(self):
        new_state = States.MENU

        if self.start_button.check():
            pygame.mixer.music.play(-1)
            new_state = States.GAME

        if self.exit_button.check():
            new_state = States.EXIT

        self.menu_sprites.update()
        return new_state

    def draw(self, screen):
        self.background.draw(screen)
        self.menu_sprites.draw(screen)
示例#4
0
 def on_show(self):
     self.setup_theme()
     arcade.set_background_color(arcade.color.AMETHYST)
     self.play_button = PlayButton(550,
                                   100,
                                   80,
                                   80,
                                   theme=self.theme,
                                   text='play')
     self.exit_button = ExitButton(650,
                                   100,
                                   80,
                                   80,
                                   theme=self.theme_2,
                                   text='exit')
     self.button_list.append(self.play_button)
     self.button_list.append(self.exit_button)
示例#5
0
    def __init__(self, screen, image, state):
        self.logo = Logo(screen, image)
        self.retry_button = RetryButton(screen)
        self.go_to_menu_button = GoToMenuButton(screen)
        self.exit_button = ExitButton(screen)

        self.background_sprites_list = pygame.sprite.Group()
        self.background_sprites_list.add(Background(screen))

        self.panel_sprite_list = pygame.sprite.Group()
        self.panel_sprite_list.add(PausePanel(screen))

        self.buttons_sprite_list = pygame.sprite.Group()
        self.buttons_sprite_list.add(self.logo, self.exit_button,
                                     self.retry_button, self.go_to_menu_button)
        self.init_state = state
        self.new_state = self.init_state
示例#6
0
 def on_show(self):
     self.setup_theme()
     arcade.set_background_color(arcade.color.AMETHYST)
     self.play_button = PlayButton(self.WIDTH / 2 - 100,
                                   self.HEIGHT / 2 - 200,
                                   150,
                                   100,
                                   theme=self.theme,
                                   text='restart')
     self.exit_button = ExitButton(self.WIDTH / 2 + 100,
                                   self.HEIGHT / 2 - 200,
                                   150,
                                   100,
                                   theme=self.theme_2,
                                   text='exit')
     self.button_list.append(self.play_button)
     self.button_list.append(self.exit_button)
示例#7
0
 def on_show(self):
     arcade.set_background_color(arcade.color.AMAZON)
     increase1_button = ValueButton(1, 950, 400, 80, 30)
     decrease1_button = ValueButton(-1, 1050, 400, 80, 30)
     self.button_list.append(increase1_button)
     self.button_list.append(decrease1_button)
     increase5_button = ValueButton(5, 950, 350, 80, 30)
     decrease5_button = ValueButton(-5, 1050, 350, 80, 30)
     self.button_list.append(increase5_button)
     self.button_list.append(decrease5_button)
     increase10_button = ValueButton(10, 950, 300, 80, 30)
     decrease10_button = ValueButton(-10, 1050, 300, 80, 30)
     self.button_list.append(increase10_button)
     self.button_list.append(decrease10_button)
     increase25_button = ValueButton(25, 950, 250, 80, 30)
     decrease25_button = ValueButton(-25, 1050, 250, 80, 30)
     self.button_list.append(increase25_button)
     self.button_list.append(decrease25_button)
     exit_button = ExitButton(650, 100, 80, 80, None, text='quit')
     self.button_list.append(exit_button)
示例#8
0
class BasicState:
    def __init__(self, screen, image, state):
        self.logo = Logo(screen, image)
        self.retry_button = RetryButton(screen)
        self.go_to_menu_button = GoToMenuButton(screen)
        self.exit_button = ExitButton(screen)

        self.background_sprites_list = pygame.sprite.Group()
        self.background_sprites_list.add(Background(screen))

        self.panel_sprite_list = pygame.sprite.Group()
        self.panel_sprite_list.add(PausePanel(screen))

        self.buttons_sprite_list = pygame.sprite.Group()
        self.buttons_sprite_list.add(self.logo, self.exit_button,
                                     self.retry_button, self.go_to_menu_button)
        self.init_state = state
        self.new_state = self.init_state

    def draw(self, screen):
        self.background_sprites_list.draw(screen)
        self.panel_sprite_list.draw(screen)
        self.buttons_sprite_list.draw(screen)

    def update(self):
        self.new_state = self.init_state
        if self.exit_button.check():
            self.new_state = States.EXIT

        if self.retry_button.check():
            pygame.mixer.music.load("Sounds/background_music")
            pygame.mixer.music.play(-1)
            self.new_state = States.RETRY

        if self.go_to_menu_button.check():
            pygame.mixer.music.load("Sounds/background_music")
            pygame.mixer.music.play(-1)
            self.new_state = States.GO_TO_MENU

        self.buttons_sprite_list.update()
        return self.new_state
示例#9
0
    def on_show(self):
        self.game.reset_hands()
        self.game.shuffle_deck()
        self.game.iterate_round()
        self.game.deal()
        stand_button = StandButton(self.WIDTH / 2 - 40,
                                   self.HEIGHT / 2,
                                   110,
                                   40,
                                   text="Stand")
        self.button_list.append(stand_button)

        hit_button = HitButton(self.WIDTH / 2 + 100,
                               self.HEIGHT / 2,
                               110,
                               40,
                               text="Hit")
        self.button_list.append(hit_button)

        quit_button = ExitButton(100, 650, 90, 40, text="Quit")
        self.button_list.append(quit_button)
示例#10
0
class StartView(arcade.View):
    """Class to display the starting View for the game"""
    def __init__(self, game, WIDTH, HEIGHT):
        super().__init__()
        self.game = game
        self.WIDTH = WIDTH
        self.HEIGHT = HEIGHT
        self.start_game = False

    def setup_theme(self):
        self.theme = Theme()
        self.theme_2 = Theme()
        self.theme.set_font(24, arcade.color.BLACK)
        self.set_button_textures()

    def on_show(self):
        self.setup_theme()
        arcade.set_background_color(arcade.color.AMETHYST)
        self.play_button = PlayButton(550,
                                      100,
                                      80,
                                      80,
                                      theme=self.theme,
                                      text='play')
        self.exit_button = ExitButton(650,
                                      100,
                                      80,
                                      80,
                                      theme=self.theme_2,
                                      text='exit')
        self.button_list.append(self.play_button)
        self.button_list.append(self.exit_button)

    def set_button_textures(self):
        #Play button
        normal = "img/buttons/green.png"
        hover = "img/buttons/pink.png"
        clicked = "img/buttons/red.png"
        locked = "img/buttons/blue.png"

        #Exit button
        self.theme.add_button_textures(normal, hover, clicked, locked)
        normal2 = "img/buttons/red.png"
        hover2 = "img/buttons/blue.png"
        clicked2 = "img/buttons/pink.png"
        locked2 = "img/buttons/green.png"
        self.theme_2.add_button_textures(normal2, hover2, clicked2, locked2)

    def on_draw(self):
        arcade.start_render()
        start_x = self.WIDTH / 2
        start_y = self.HEIGHT / 2
        arcade.draw_text(
            "Welcome to Black Jack! \n You start off with 100 chips.\n Try to make it to 250 chips by beating the dealer\'s cards.\n Would you like to play?",
            start_x,
            start_y,
            arcade.color.BLACK,
            font_size=30,
            anchor_x="center",
            anchor_y="center",
            align='center')
        super().on_draw()
        self.play_button.draw()
        self.exit_button.draw()
        if self.play_button.pressed:
            game_view = GameViewBid(self.WIDTH, self.HEIGHT)
            self.game.window.show_view(game_view)
        if self.exit_button.pressed:
            arcade.close_window()
示例#11
0
    def on_show(self):
        self.setup_theme()
        arcade.set_background_color(arcade.color.AMAZON)

        increase1_button = ValueButton(1,
                                       950,
                                       450,
                                       70,
                                       70,
                                       '1',
                                       theme=self.theme)
        decrease1_button = ValueButton(-1,
                                       1050,
                                       450,
                                       70,
                                       70,
                                       '-1',
                                       theme=self.theme)
        self.button_list.append(increase1_button)
        self.button_list.append(decrease1_button)
        increase5_button = ValueButton(5,
                                       950,
                                       375,
                                       70,
                                       70,
                                       '5',
                                       theme=self.theme_2)
        decrease5_button = ValueButton(-5,
                                       1050,
                                       375,
                                       70,
                                       70,
                                       '-5',
                                       theme=self.theme_2)
        self.button_list.append(increase5_button)
        self.button_list.append(decrease5_button)
        increase10_button = ValueButton(10,
                                        950,
                                        300,
                                        70,
                                        70,
                                        '10',
                                        theme=self.theme_3)
        decrease10_button = ValueButton(-10,
                                        1050,
                                        300,
                                        70,
                                        70,
                                        '-10',
                                        theme=self.theme_3)
        self.button_list.append(increase10_button)
        self.button_list.append(decrease10_button)
        increase25_button = ValueButton(25,
                                        950,
                                        225,
                                        70,
                                        70,
                                        '25',
                                        theme=self.theme_4)
        decrease25_button = ValueButton(-25,
                                        1050,
                                        225,
                                        70,
                                        70,
                                        '-25',
                                        theme=self.theme_4)
        self.button_list.append(increase25_button)
        self.button_list.append(decrease25_button)

        quit_button = ExitButton(100, 650, 90, 40, text="Quit")
        self.button_list.append(quit_button)

        submit_button = SubmitButton(1000, 150, 110, 40, text="Place Bet")
        self.button_list.append(submit_button)