Example #1
0
 def __init__(self):
     super().__init__()
     self.next = 'TITLE'
     self.bg = GFX['warning']
     self.timer = 300
     self.frame = 0
     self.transition: Transition = Transition()
Example #2
0
    def startup(self, persist: dict):
        self.players = pygame.sprite.Group()
        self.player_1 = pygame.sprite.Sprite()
        self.player_2 = pygame.sprite.Sprite()
        self.player_1_confirm = False
        self.player_2_confirm = False
        self.transition = Transition()
        self.done = False
        self.time_left = 20

        # Reset p1_ship_images since they haven't indicated they want to play yet
        self.p1_ship_image: pygame.Surface = None
        self.p1_ship_rect: pygame.Rect = None
        self.p2_ship_image: pygame.Surface = None
        self.p2_ship_rect: pygame.Rect = None

        self.persist = persist
        self.choice = self.persist[
            'choice']  # This denotes which player chose to start the game
        if self.choice['1p']:
            self.set_player_1()
        if self.choice['2p']:
            self.set_player_2()
        self.controls = self.persist['controls']
        self.coins = self.persist['coins']
        # Should always be done after controls initialized in "level" state where player actually starts giving input

        pygame.mixer.music.load(MUSIC['07_-_stars_dont_twinkle_0'])
        pygame.mixer.music.play(-1)
Example #3
0
    def __init__(self):
        super().__init__()
        self.background = GFX['controls']
        self.transition = Transition()
        self.next = 'TITLE'
        self.fade_away = False

        self.labels = pygame.sprite.Group()
        self.label_list: List[BlinkerLabel] = []
        self.hints = [
            'Arrow Keys To Navigate / Enter To Unlock',
            'Assign Your Own Key / Enter To Confirm'
        ]

        self.hint_1 = Label('Esc to return', {'center': (300, 750)},
                            self.labels,
                            font_path=GAMER,
                            font_size=25)
        self.hint_2 = Label(self.hints[0], {'center': (300, 780)},
                            self.labels,
                            font_path=GAMER,
                            font_size=25)

        self.changing_label = False
        self.chosen_control = 0

        self.texts = [
            '1p_coin', '1p_start', '1p_up', '1p_down', '1p_left', '1p_right',
            '1p_button_a', '1p_button_b', '2p_coin', '2p_start', '2p_up',
            '2p_down', '2p_left', '2p_right', '2p_button_a', '2p_button_b'
        ]
Example #4
0
    def __init__(self):
        super().__init__()
        self.choice: Dict[str, int] = {'1p': 0, '2p': 0}
        self.controls: Dict[str, int] = {}

        self.player_1: Player = pygame.sprite.Sprite()
        self.player_2: Player = pygame.sprite.Sprite()
        self.players = pygame.sprite.Group()

        self.labels = pygame.sprite.Group()
        self.enemy_hitboxes = pygame.sprite.Group()  # For showcase weapon

        self.player_1_confirm = False
        self.player_2_confirm = False
        self.next = 'LEVEL 1'
        self.time_left = 20

        self.p1_ship_img: cycle = None  # Selecting between the two
        self.p2_ship_img: cycle = None
        self.p1_star_img: cycle = None
        self.p2_star_img: cycle = None
        self.p1_name_img: cycle = None
        self.p2_name_img: cycle = None
        self.p1_ship_img_rects: cycle = None
        self.p2_ship_img_rects: cycle = None
        self.p1_ship_sprites: cycle = None
        self.p2_ship_sprites: cycle = None

        self.p1_power_image: pygame.Surface = None
        self.p1_power_rect: pygame.Rect = None
        self.p1_speed_image: pygame.Surface = None
        self.p1_speed_rect: pygame.Rect = None
        self.p1_name_image: pygame.Surface = None
        self.p1_name_rect: pygame.Rect = None

        self.p2_power_image: pygame.Surface = None
        self.p2_power_rect: pygame.Rect = None
        self.p2_speed_image: pygame.Surface = None
        self.p2_speed_rect: pygame.Rect = None
        self.p2_name_image: pygame.Surface = None
        self.p2_name_rect: pygame.Rect = None

        self.p1_ship_image: pygame.Surface = None
        self.p1_ship_rect: pygame.Rect = None
        self.p2_ship_image: pygame.Surface = None
        self.p2_ship_rect: pygame.Rect = None

        self.mask: pygame.Surface = None

        self.background = Background(3)
        self.transition = Transition()

        self.time_label: BlinkerLabel = None
        self.coin_label: Label = None

        self.load_images()
        self.load_labels()
Example #5
0
 def startup(self, persist: dict):
     self.labels = pygame.sprite.Group()
     self.persist = persist
     self.changing_label = False
     self.done = False
     self.controls = self.persist['controls']
     self.chosen_control = 0
     self.transition = Transition()
     self.fade_away = False
     self.init_labels()
Example #6
0
 def startup(self, persist: dict):
     self.frame = 0
     self.done = False
     self.transition = Transition()
     self.fade_away = False
     self.persist = persist
     with open(SCORE, 'r') as f:
         self.scoreboard = self.persist[
             'scoreboard'] if 'scoreboard' in self.persist else json.load(f)
     self.labels = pygame.sprite.Group()
     self.init_labels()
     self.controls = self.persist['controls']
Example #7
0
 def startup(self, persist: dict):
     self.frame = 0
     self.done = False
     self.persist = persist
     self.text_input.reset()
     self.scoreboard = persist['scoreboard']
     self.check_done()
     self.fade_away = False
     self.transition = Transition()
     self.event_block = False
     self.prompt_label = Label('', {
         'center': (300, 200)}, font_path=ARCADE_CLASSIC, font_size=40)
Example #8
0
 def update(self):
     self.frame += 1
     self.screen_saver += 1
     self.transition.fade_in()
     # If we have waited for 5 seconds, not transitioning
     if self.screen_saver == 300 and not self.fade_away:
         self.fade_away = True
         self.next = 'HIGHSCORE'
     if self.fade_away:
         self.done = self.transition.fade_out()
     elif self.transition.frame > 0:
         self.transition = Transition()  # Reset fadeaway
     self.update_labels()
Example #9
0
 def __init__(self):
     super().__init__()
     self.background = Background(5)
     self.labels = pygame.sprite.Group()
     self.scoreboard: dict = None
     self.title = GFX['scoreboard']
     self.title_rect = self.title.get_rect(center=(300, 100))
     self.transition = Transition()
     self.next = 'TITLE'
     self.fade_away = False
     self.images = [
         pygame.transform.scale(GFX[f'player{x}'], (40, 60))
         for x in range(1, 5)
     ]
Example #10
0
 def startup(self, persist: dict):
     self.done = False
     self.next = 'SELECT'
     self.persist = persist
     self.choice = self.persist.get('choice', {'1p': 0, '2p': 0})
     self.coins = self.persist.get('coins', 0)
     self.frame = 0
     self.screen_saver = 0
     pygame.mixer.music.load(MUSIC['06_-_space_troopers_0'])
     pygame.mixer.music.play(-1)  # -1 means looping music
     with open(CONTROLS, 'r') as f:
         self.controls = self.persist.get('controls', json.load(f))
     self.transition = Transition()
     self.fade_away = False
     self.event_block = False
Example #11
0
    def __init__(self):
        super().__init__()
        self.background = Background(1)
        self.text_input = TextInput(font_family=ARCADE_CLASSIC, font_size=50, text_color=(255, 255, 255),
                                    cursor_color=(255, 255, 255), max_length=15)
        self.next = 'HIGHSCORE'
        self.scoreboard = {}
        self.p1_done = False
        self.p2_done = False
        self.event_block = False
        self.p1_idx = 0
        self.p2_idx = 0
        self.fade_away = False
        self.transition = Transition()

        self.title = GFX['entername']
        self.title_rect = self.title.get_rect(center=(300, 100))
        self.prompt_label: Label = None
Example #12
0
    def __init__(self):
        super().__init__()
        self.background = GFX['title_screen']
        self.coins = 0
        self.fade_away = False
        self.event_block = False
        self.transition = Transition()

        self.controls: dict = None

        self.coin_label: Label = None
        self.control_label: Label = None
        self.hint_label: BlinkerLabel = None
        self.labels = pygame.sprite.Group()

        self.make_labels()
        self.choice = {'1p': 0, '2p': 0}

        self.screen_saver = 0