def display_screen(self):
        self.timer = 4.0 * FRAMES_PER_SECOND
        sequence = 1 * FRAMES_PER_SECOND

        while self.timer:
            self.handle_events()

            self.screen.fill(FILL_COLOR)
            if self.music:
                utility.play_music(self.music)

            self.timer -= 1
            self.image.draw(self.screen)
            
            if self.timer >= 3 * FRAMES_PER_SECOND:
                utility.dim((sequence / (1.0 * FRAMES_PER_SECOND)) * 255)
                sequence -= 1

            if self.timer <= 1 * FRAMES_PER_SECOND:
                if self.fade_image:
                    utility.dim((sequence / (1.0 * FRAMES_PER_SECOND)) * 255)
                sequence += 1
                
            pygame.display.flip()
            self.clock.tick(FRAMES_PER_SECOND)
Example #2
0
    def __init__(self, screen, p: int = None): # init the stage
        super().__init__(screen, p)


        self.phase_list = [self.phase_0, self.phase_1, self.phase_2]
        self.player.fast_speed = 250*MEASURE_UNIT
        utility.play_music(self.MUSIC['kanata'])
Example #3
0
    def display_screen(self):
        self.timer = 4.0 * FRAMES_PER_SECOND
        sequence = 1 * FRAMES_PER_SECOND

        while self.timer:
            self.handle_events()

            self.screen.fill(FILL_COLOR)
            if self.music:
                utility.play_music(self.music)

            self.timer -= 1
            self.image.draw(self.screen)

            if self.timer >= 3 * FRAMES_PER_SECOND:
                utility.dim((sequence / (1.0 * FRAMES_PER_SECOND)) * 255)
                sequence -= 1

            if self.timer <= 1 * FRAMES_PER_SECOND:
                if self.fade_image:
                    utility.dim((sequence / (1.0 * FRAMES_PER_SECOND)) * 255)
                sequence += 1

            pygame.display.flip()
            self.clock.tick(FRAMES_PER_SECOND)
Example #4
0
    def boss_text(self):
        utility.fade_music()
        utility.play_music(self.boss_fight_music, True)

        # Display boss text
        display_stage = text.Text(FONT_PATH, 64, FONT_COLOR, 'Boss Fight!', 90)
        display_stage.position = vector.Vector2d((SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2))
        display_stage.set_alignment(CENTER_MIDDLE)
        self.text_group.add(display_stage)
Example #5
0
    def boss_text(self):
        utility.fade_music()
        utility.play_music(self.boss_fight_music, True)

        # Display boss text
        display_stage = text.Text(FONT_PATH, 64, FONT_COLOR, 'Boss Fight!', 90)
        display_stage.position = vector.Vector2d(
            (SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2))
        display_stage.set_alignment(CENTER_MIDDLE)
        self.text_group.add(display_stage)
Example #6
0
    def actor_update(self):
        utility.play_music(self.music, True)
        self.place_eye()

        if self.life_timer <= 30 * FRAMES_PER_SECOND and self.health == self.world.level+ 2:
            if self.life_timer == 30 * FRAMES_PER_SECOND:
                temp_image = self.how_to_kill
                help_bubble = infobubble.InfoBubble(temp_image, self.target, 5 * FRAMES_PER_SECOND)
                help_bubble.offset = vector.Vector2d(0.0, -100.0)
                self.text_group.add(help_bubble)

            self.life_timer += 1
            
        if not self.active and self.health > 0:
            self.active = True

        if self.active:
            if self.stunned:
                if self.charging:
                    self.speed -= 0.2
                    if self.speed <= 1.75:
                        self.speed = 1.75
                        self.charging = False
                        self.time_until_charge = 6 * FRAMES_PER_SECOND
                
                    self.velocity.make_normal()
                    self.velocity *= self.speed
                
                self.current_sequence = 1
                self.stunned -= 1

                if not self.stunned:
                    self.text_group.add(self.eye)
                    self.animation_list.play('idle')

                if not self.stunned % 4:
                    puffs_to_create = 4
                    
                    while puffs_to_create and settings_list[PARTICLES]:
                        puffs_to_create -= 1
                        temp_puff = particle.SmokeParticle(self.position, (1, 0))
                        temp_puff.velocity.set_angle(359 * random.random())
                        self.effects_group.add(temp_puff)

            else:
                self.current_sequence = 0
                self.process_ai()

        if self.health <= 0:
            self.active = False
            self.die()
            
            if not self.gave_bonus:
                self.world.give_bonus()
                self.gave_bonus = True
Example #7
0
    def update(self):
        if not self.boss_fight:
            utility.play_music(self.music)

        if self.after_bonus_pause >= 1:
            self.after_bonus_pause -= 1
            if self.after_bonus_pause < 1:
                if self.level >= MAX_LEVEL:
                    self.bonus_text.kill()
                    self.bonus_amount.kill()
                    self.done = True

                else:
                    self.load_level()

        if self.done:
            return self.done

        if self.bonus != -1:
            self.give_bonus()

        if self.pause_spawning:
            live = self.warmup()

            if not live:
                return

        if not self.boss_fight:
            self.defeat_stage -= 1

            if not self.defeat_stage:
                if self.stage < MAX_STAGE:
                    self.stage += 1
                    self.load_stage()

                else:
                    for enemy in self.enemy_group:
                        if enemy.actor_type == ACTOR_TYPE_BAAKE:
                            enemy.leave_screen = True

                    self.boss_fight = True
                    self.stage += 1
                    self.pause_spawning = 3 * FRAMES_PER_SECOND
                    self.boss_text()

        for enemy in self.enemy_list:
            if enemy[SPAWN_RATE] != -1:
                if not enemy[TIME_TO_SPAWN]:
                    self.create_actor(enemy[ACTOR_TYPE])
                    enemy[TIME_TO_SPAWN] = enemy[SPAWN_RATE]

                enemy[TIME_TO_SPAWN] -= 1
Example #8
0
    def update(self):
        if not self.boss_fight:
            utility.play_music(self.music)

        if self.after_bonus_pause >= 1:
            self.after_bonus_pause -= 1
            if self.after_bonus_pause < 1:
                if self.level >= MAX_LEVEL:
                    self.bonus_text.kill()
                    self.bonus_amount.kill()
                    self.done = True

                else:
                    self.load_level()

        if self.done:
            return self.done

        if self.bonus != -1:
            self.give_bonus()

        if self.pause_spawning:
            live = self.warmup()
            
            if not live:
                return

        if not self.boss_fight:
            self.defeat_stage -= 1

            if not self.defeat_stage:
                if self.stage < MAX_STAGE:
                    self.stage += 1
                    self.load_stage()

                else:
                    for enemy in self.enemy_group:
                        if enemy.actor_type == ACTOR_TYPE_BAAKE:
                            enemy.leave_screen = True

                    self.boss_fight = True
                    self.stage += 1
                    self.pause_spawning = 3 * FRAMES_PER_SECOND
                    self.boss_text()

        for enemy in self.enemy_list:
            if enemy[SPAWN_RATE] != -1:
                if not enemy[TIME_TO_SPAWN]:
                    self.create_actor(enemy[ACTOR_TYPE])
                    enemy[TIME_TO_SPAWN] = enemy[SPAWN_RATE]
                
                enemy[TIME_TO_SPAWN] -= 1
Example #9
0
    def actor_update(self):
        if not self.stunned:
            try:
                self.emitter.update()

            except:
                pass

        utility.play_music(self.music, True)
        if not self.active and self.health > 0:
            self.active = True

        if self.life_timer <= 30 * FRAMES_PER_SECOND and self.health == self.world.level + 2:
            if self.life_timer == 30 * FRAMES_PER_SECOND:
                temp_image = self.how_to_kill
                help_bubble = infobubble.InfoBubble(temp_image, self.target, 5 * FRAMES_PER_SECOND)
                help_bubble.offset = vector.Vector2d(0.0, -100.0)
                self.text_group.add(help_bubble)

            self.life_timer += 1

        if self.active:
            if self.stunned:
                self.stunned -= 1

                if not self.stunned % 4:
                    puffs_to_create = 4
                    
                    while puffs_to_create and settings_list[PARTICLES]:
                        puffs_to_create -= 1
                        temp_puff = particle.SmokeParticle(self.position, (1, 0))
                        temp_puff.velocity.set_angle(359 * random.random())
                        self.effects_group.add(temp_puff)

                if not self.stunned:
                    self.animation_list.play('idle')

            else:
                self.current_sequence = 0
                self.process_ai()

        if self.health <= 0:
            self.active = False
            self.die()
            
            if not self.gave_bonus and self.world.world_name != 'Tutorial':
                self.world.give_bonus()
                self.gave_bonus = True
Example #10
0
    def actor_update(self):
        utility.play_music(self.music, True)

        if not self.active and self.health > 0:
            self.active = True

        if self.life_timer <= 30 * FRAMES_PER_SECOND and self.health == (self.world.level + 1) * 25:
            if self.life_timer == 30 * FRAMES_PER_SECOND:
                temp_image = self.how_to_kill
                help_bubble = infobubble.InfoBubble(temp_image, self.target, 5 * FRAMES_PER_SECOND)
                help_bubble.offset = vector.Vector2d(0.0, -100.0)
                self.text_group.add(help_bubble)

            self.life_timer += 1

        if self.active:
            if self.stunned:
                if self.charging:
                    self.speed -= 0.2
                    if self.speed <= 1.75:
                        self.speed = 1.75
                        self.charging = False
                        self.time_until_charge = 10 * FRAMES_PER_SECOND
                
                    self.velocity.make_normal()
                    self.velocity *= self.speed

                self.stunned -= 1
                self.animation_list.play('vulnerable')
                
                if not self.stunned:
                    utility.play_sound(self.shieldRestore, PICKUP_CHANNEL)
                    self.animation_list.play('idle')
                
            else:
                self.current_sequence = 0
                self.process_ai()

        if self.health <= 0:
            self.active = False
            self.die()
            
            if not self.gave_bonus:
                self.world.give_bonus()
                self.gave_bonus = True
Example #11
0
    def give_bonus(self):
        increment_bonus = self.player.lives * 50

        if self.bonus == -1:
            self.boss_fight = False
            self.bonus = 0
            self.bonus_text = text.Text(FONT_PATH, 64, FONT_COLOR,
                                        'Bonus Points!')
            self.bonus_text.position = vector.Vector2d(
                (SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2 - 50))
            self.bonus_text.set_alignment(CENTER_MIDDLE)
            self.text_group.add(self.bonus_text)

            self.bonus_amount = text.Text(FONT_PATH, 48, FONT_COLOR)
            self.bonus_amount.position = vector.Vector2d(
                (SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2 + 50))
            self.bonus_amount.set_alignment(CENTER_MIDDLE)
            self.text_group.add(self.bonus_amount)

        if self.bonus < self.player.lives * 5000 - increment_bonus:
            self.bonus += increment_bonus
            self.bonus_amount.set_text(self.bonus)

        else:
            self.bonus_amount.set_text(self.player.lives * 5000)

            if self.level < MAX_LEVEL:
                self.bonus_text.set_timer(FRAMES_PER_SECOND)
                self.bonus_amount.set_timer(FRAMES_PER_SECOND)

            self.bonus = -1
            self.after_bonus_pause = 1.1 * FRAMES_PER_SECOND

            if self.level < MAX_LEVEL:
                self.level += 1

            self.boss_fight = False
            utility.fade_music()
            utility.play_music(self.music, True)

        utility.play_sound(self.bonus_tally_sound, BAAKE_CHANNEL)
        self.player.increment_score_no_text(increment_bonus)
        self.pause_spawning = 1.5 * FRAMES_PER_SECOND
Example #12
0
    def load_level(self):
        if self.done:
            return

        utility.fade_music()
        utility.play_music(self.music, True)
        self.stage = 0
        self.pause_spawning = 3 * FRAMES_PER_SECOND
        self.player.bullet_bonus = 0
        self.player.reflect_bonus = 0

        self.powerup_group.empty()
        self.enemy_group.empty()
        self.effects_group.empty()

        # Display Level text
        display_name = text.Text(FONT_PATH, 64, FONT_COLOR, self.world_name,
                                 90)
        display_name.set_alignment(CENTER_MIDDLE)
        display_name.position = vector.Vector2d(
            (SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2))
        self.group_list[TEXT_GROUP].add(display_name)

        display_level = text.Text(FONT_PATH, 32, FONT_COLOR,
                                  'Level ' + str(self.level + 1), 90)
        display_level.position = vector.Vector2d(
            (SCREEN_WIDTH / 2, SCREEN_HEIGHT * (2.0 / 3.0)))
        display_level.set_alignment(CENTER_MIDDLE)
        self.group_list[TEXT_GROUP].add(display_level)

        # Reset all information for the new level
        self.enemy_list = []
        self.load_stage()

        utility.play_sound(self.get_ready_sound, OW_CHANNEL)

        temp_image = text.TextSurface(FONT_PATH, 36, FONT_COLOR,
                                      'Get Ready...').image
        help_bubble = infobubble.InfoBubble(temp_image, self.player,
                                            2 * FRAMES_PER_SECOND)
        help_bubble.offset = vector.Vector2d(0.0, -100.0)
        self.effects_group.add(help_bubble)
Example #13
0
    def give_bonus(self):
        increment_bonus = self.player.lives * 50

        if self.bonus == -1:
            self.boss_fight = False
            self.bonus = 0
            self.bonus_text = text.Text(FONT_PATH, 64, FONT_COLOR, 'Bonus Points!')
            self.bonus_text.position = vector.Vector2d((SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2 - 50))
            self.bonus_text.set_alignment(CENTER_MIDDLE)
            self.text_group.add(self.bonus_text)

            self.bonus_amount = text.Text(FONT_PATH, 48, FONT_COLOR)
            self.bonus_amount.position = vector.Vector2d((SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2 + 50))
            self.bonus_amount.set_alignment(CENTER_MIDDLE)
            self.text_group.add(self.bonus_amount)

        if self.bonus < self.player.lives * 5000 - increment_bonus:
            self.bonus += increment_bonus
            self.bonus_amount.set_text(self.bonus)

        else:
            self.bonus_amount.set_text(self.player.lives * 5000)

            if self.level < MAX_LEVEL:
                self.bonus_text.set_timer(FRAMES_PER_SECOND)
                self.bonus_amount.set_timer(FRAMES_PER_SECOND)

            self.bonus = -1
            self.after_bonus_pause = 1.1 * FRAMES_PER_SECOND

            if self.level < MAX_LEVEL:
                self.level += 1

            self.boss_fight = False
            utility.fade_music()
            utility.play_music(self.music, True)

        utility.play_sound(self.bonus_tally_sound, BAAKE_CHANNEL)
        self.player.increment_score_no_text(increment_bonus)
        self.pause_spawning = 1.5 * FRAMES_PER_SECOND
Example #14
0
    def load_level(self):
        if self.done:
            return

        utility.fade_music()
        utility.play_music(self.music, True)
        self.stage = 0
        self.pause_spawning = 3 * FRAMES_PER_SECOND
        self.player.bullet_bonus = 0
        self.player.reflect_bonus = 0

        self.powerup_group.empty()
        self.enemy_group.empty()
        self.effects_group.empty()

        # Display Level text
        display_name = text.Text(FONT_PATH, 64, FONT_COLOR, self.world_name, 90)
        display_name.set_alignment(CENTER_MIDDLE)
        display_name.position = vector.Vector2d((SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2))
        self.group_list[TEXT_GROUP].add(display_name)

        display_level = text.Text(FONT_PATH, 32, FONT_COLOR, 'Level ' + str(self.level + 1), 90)
        display_level.position = vector.Vector2d((SCREEN_WIDTH / 2, SCREEN_HEIGHT * (2.0 / 3.0)))
        display_level.set_alignment(CENTER_MIDDLE)
        self.group_list[TEXT_GROUP].add(display_level)

        # Reset all information for the new level
        self.enemy_list = []
        self.load_stage()

        utility.play_sound(self.get_ready_sound, OW_CHANNEL)

        temp_image = text.TextSurface(FONT_PATH, 36, FONT_COLOR, 'Get Ready...').image
        help_bubble = infobubble.InfoBubble(temp_image, self.player, 2 * FRAMES_PER_SECOND)
        help_bubble.offset = vector.Vector2d(0.0, -100.0)
        self.effects_group.add(help_bubble)
Example #15
0
enemies.yurei.load_data()
enemies.bokko.load_data()
pygame.event.pump()
enemies.hakta.load_data()
enemies.raayu.load_data()
enemies.paajo.load_data()
pygame.event.pump()
enemies.boss.load_data()
particle.load_data()
menu.load_data()

for event in pygame.event.get():
    pass

splashscreen.SplashScreen(screen, 'pygamesplash')
utility.play_music(music_list[MENU_MUSIC])
splashscreen.SplashScreen(screen, 'gameSplash')

if settings_list[WORLD_UNLOCKED] == 0:
    new_scene = scene.TutorialScene()

elif settings_list[WORLD_UNLOCKED] == 1:
    new_scene = scene.ForestScene()

elif settings_list[WORLD_UNLOCKED] == 2:
    new_scene = scene.RockyScene()

elif settings_list[WORLD_UNLOCKED] == 3:
    new_scene = scene.PinkScene()

game_is_running = True
    def roll_credits(self):
        credit_group = pygame.sprite.Group()

        # Create Text Labels
        title_credit = text.Text(FONT_PATH, 48, FONT_COLOR, 'Credits')
        title_credit.set_position((SCREEN_WIDTH / 2, SCREEN_HEIGHT))

        big_jony = text.Text(FONT_PATH, 36, FONT_COLOR, 'Jony Fries')
        big_jony.set_position((SCREEN_WIDTH / 2, SCREEN_HEIGHT + 100))
        jony_credit0 = text.Text(FONT_PATH, 24, FONT_COLOR, 'Game Programming')
        jony_credit0.set_position((SCREEN_WIDTH / 2, SCREEN_HEIGHT + 150))
        jony_credit1 = text.Text(FONT_PATH, 24, FONT_COLOR, 'Sound Design')
        jony_credit1.set_position((SCREEN_WIDTH / 2, SCREEN_HEIGHT + 200))
        jony_credit2 = text.Text(FONT_PATH, 24, FONT_COLOR, 'Voice Acting')
        jony_credit2.set_position((SCREEN_WIDTH / 2, SCREEN_HEIGHT + 250))

        big_josh = text.Text(FONT_PATH, 36, FONT_COLOR, 'Joshua Skelton')
        big_josh.set_position((SCREEN_WIDTH / 2, SCREEN_HEIGHT + 350))
        josh_credit0 = text.Text(FONT_PATH, 24, FONT_COLOR, 'Game Programming')
        josh_credit0.set_position((SCREEN_WIDTH / 2, SCREEN_HEIGHT + 400))
        josh_credit1 = text.Text(FONT_PATH, 24, FONT_COLOR, ' Graphic Design')
        josh_credit1.set_position((SCREEN_WIDTH / 2, SCREEN_HEIGHT + 450))
        
        big_special = text.Text(FONT_PATH, 36, FONT_COLOR, 'Special Thanks To:')
        big_special.set_position((SCREEN_WIDTH / 2, SCREEN_HEIGHT + 550))
        special_credit0 = text.Text(FONT_PATH, 24, FONT_COLOR, 'Python Software Foundation')
        special_credit0.set_position((SCREEN_WIDTH / 2, SCREEN_HEIGHT + 600))
        special_credit1 = text.Text(FONT_PATH, 24, FONT_COLOR, 'PyGame')
        special_credit1.set_position((SCREEN_WIDTH / 2, SCREEN_HEIGHT + 650))
        special_credit2 = text.Text(FONT_PATH, 24, FONT_COLOR, 'ShyFonts Type Foundry')
        special_credit2.set_position((SCREEN_WIDTH / 2, SCREEN_HEIGHT + 700))
        
        thank_you = text.Text(FONT_PATH, 64, FONT_COLOR, 'Thank You For Playing!')
        thank_you.set_position((SCREEN_WIDTH / 2, SCREEN_HEIGHT + 800))

        # Add Labels to Group
        credit_group.add(title_credit)
        
        credit_group.add(big_jony)
        credit_group.add(jony_credit0)
        credit_group.add(jony_credit1)
        credit_group.add(jony_credit2)
        
        credit_group.add(big_josh)
        credit_group.add(josh_credit0)
        credit_group.add(josh_credit1)
        
        credit_group.add(big_special)
        credit_group.add(special_credit0)
        credit_group.add(special_credit1)
        credit_group.add(special_credit2)

        credit_group.add(thank_you)

        timer = 5 * FRAMES_PER_SECOND

        for credit in credit_group:
            credit.set_alignment(CENTER_MIDDLE)

        while self.rolling_credits:
            utility.play_music(self.music_list)

            for credit in credit_group:
                credit_position = credit.get_position()
                credit.set_position((credit_position[0], credit_position[1] + self.scroll_rate))

            credit_group.update()
            self.new_scene.draw(self.screen)
            credit_group.draw(self.screen)
            pygame.display.flip()
            self.handle_events()
            
            if special_credit2.get_position()[1] < 0:
                if self.finished:
                    self.rolling_credits = False

            if thank_you.get_position()[1] < (SCREEN_HEIGHT / 2):
                thank_you.set_position((SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2))
Example #17
0
    def show(self):
        self.menu_selection_pointer[self.current_selection].set_font(48, FONT_COLOR, FONT_PATH)
        pygame.mouse.get_rel()
        mouse_timeout = 10
        sample_mouse = True
        
        while True:
            # Music Stuff
            utility.play_music(self.music_list)

            # Drawing Stuff
            self.screen.fill(FILL_COLOR)
            self.menu_group.update()
            self.menu_tooltip_group.update()
            self.cursor_group.update()
            try:
                self.screen.blit(self.background_image, self.background_image.get_rect())
            except:
                self.background_image.draw(self.screen)

            self.menu_group.draw(self.screen)
            self.menu_tooltip_pointer[self.current_selection].draw(self.screen)
            self.cursor_group.draw(self.screen)

            pygame.display.flip()

            self.cursor.position = vector.Vector2d(pygame.mouse.get_pos()) + vector.Vector2d(32, 32)

            # Event Handling
            for event in pygame.event.get():
                if event.type == pygame.KEYDOWN and (event.key == pygame.K_SPACE or event.key == pygame.K_RETURN):
                    utility.play_sound(self.menu_forward_sound)

                    return list(self.menu_dictionary.keys())[self.current_selection]

                elif event.type == pygame.MOUSEBUTTONDOWN and event.button == 1:
                    utility.play_sound(self.menu_forward_sound)

                    return list(self.menu_dictionary.keys())[self.current_selection]

                elif event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE:
                    utility.play_sound(self.menu_back_sound)

                    return False

                elif event.type == pygame.MOUSEBUTTONDOWN and event.button == 3:
                    utility.play_sound(self.menu_back_sound)

                    return False

                elif event.type == pygame.KEYDOWN and event.key == pygame.K_UP:
                    self.menu_selection_pointer[self.current_selection].set_font(32, FONT_INACTIVE_COLOR, FONT_PATH)
                    self.current_selection -= 1

                    if self.current_selection < 0:
                        self.current_selection = len(self.menu_dictionary) - 1

                    self.menu_selection_pointer[self.current_selection].set_font(48, FONT_COLOR, FONT_PATH)
                    utility.play_sound(self.menu_beep_sound)

                elif event.type == pygame.KEYDOWN and event.key == pygame.K_DOWN:
                    self.menu_selection_pointer[self.current_selection].set_font(32, FONT_INACTIVE_COLOR, FONT_PATH)
                    self.current_selection += 1

                    if self.current_selection > len(self.menu_dictionary) - 1:
                        self.current_selection = 0

                    self.menu_selection_pointer[self.current_selection].set_font(48, FONT_COLOR, FONT_PATH)
                    utility.play_sound(self.menu_beep_sound)

                elif event.type == pygame.MOUSEMOTION:
                    for element in self.menu_group:
                        if element.mouse_over():
                            if element.text_index != self.current_selection:
                                self.menu_selection_pointer[self.current_selection].set_font(32, FONT_INACTIVE_COLOR, FONT_PATH)
                                mouse_selection = element.text_index
                                self.current_selection = mouse_selection
                                self.menu_selection_pointer[self.current_selection].set_font(48, FONT_COLOR, FONT_PATH)
                                utility.play_sound(self.menu_beep_sound)

                """
                elif event.type == pygame.KEYDOWN and event.key == pygame.K_q:
                    for element in self.menuTooltipGroup:
                        print 'ELEMENT: ', element.text_index
                        element.mouseOverDump()

                elif event.type == pygame.MOUSEMOTION:
                    mouseInput = list(pygame.mouse.get_rel())
                    if sample_mouse:
                        if mouseInput[1] < -10:
                            self.menuSelectionPointer[self.currentSelection].setFont(32, FONT_INACTIVE_COLOR, FONT_PATH)
                            self.currentSelection -= 1
                            if self.currentSelection < 0:
                                self.currentSelection = len(self.menuDictionary) - 1
                            self.menuSelectionPointer[self.currentSelection].setFont(48, FONT_COLOR, FONT_PATH)
                            sample_mouse = False
                            utility.playSound(self.menuBeep)

                        elif mouseInput[1] > 10:
                            self.menuSelectionPointer[self.currentSelection].setFont(32, FONT_INACTIVE_COLOR, FONT_PATH)
                            self.currentSelection += 1
                            if self.currentSelection > len(self.menuDictionary) - 1:
                                self.currentSelection = 0
                            self.menuSelectionPointer[self.currentSelection].setFont(48, FONT_COLOR, FONT_PATH)
                            sample_mouse = False
                            utility.playSound(self.menuBeep)   
                """

            if not sample_mouse:
                mouse_timeout -= 1
                
            if mouse_timeout == 0:
                sample_mouse = True
                mouse_timeout = 3
                
            self.timer.tick(30)
Example #18
0
enemies.yurei.load_data()
enemies.bokko.load_data()
pygame.event.pump()
enemies.hakta.load_data()
enemies.raayu.load_data()
enemies.paajo.load_data()
pygame.event.pump()
enemies.boss.load_data()
particle.load_data()
menu.load_data()

for event in pygame.event.get():
    pass

splashscreen.SplashScreen(screen, 'pygamesplash')
utility.play_music(music_list[MENU_MUSIC])
splashscreen.SplashScreen(screen, 'gameSplash')

if settings_list[WORLD_UNLOCKED] == 0:
    new_scene = scene.TutorialScene()

elif settings_list[WORLD_UNLOCKED] == 1:
    new_scene = scene.ForestScene()

elif settings_list[WORLD_UNLOCKED] == 2:
    new_scene = scene.RockyScene()

elif settings_list[WORLD_UNLOCKED] == 3:
    new_scene = scene.PinkScene()

game_is_running = True
Example #19
0
    def run(self):
        while not self.done:
            if self.world_done:
                if self.world_number < MAX_WORLD:
                    self.world_beat()

                    # Resetting player lives so that it isn't in their best
                    # interest to play easier worlds just to have extra lives.
                    self.player.lives = 3
                    self.player.life_board.set_text('x' +
                                                    str(self.player.lives))

                    self.player.score = 0
                    self.player.next_bonus = 50000

                    # Loading the new world
                    self.world_number += 1

                    if self.world_number == 0:
                        self.new_scene = scene.TutorialScene()

                    elif self.world_number == 1:
                        self.new_scene = scene.ForestScene()

                    elif self.world_number == 2:
                        self.new_scene = scene.RockyScene()

                    elif self.world_number == 3:
                        self.new_scene = scene.PinkScene()

                    if self.world_number > settings_list[WORLD_UNLOCKED]:
                        settings_list[WORLD_UNLOCKED] = self.world_number

                    utility.play_music(self.music_list[self.world_number],
                                       True)
                    self.current_world = world.World(
                        self.world_list[self.world_number],
                        self.music_list[self.world_number])
                    self.current_world.load()
                    self.world_done = False

                else:
                    self.game_beat()

            self.check_collision()
            self.update()
            self.draw()
            self.handle_events()

            pygame.mouse.set_pos(MOUSE_DEFAULT_POSITION)
            pygame.mouse.get_rel()
            self.mouse_last_move = pygame.mouse.get_pos()

            self.timer.tick(FRAMES_PER_SECOND)

            if self.player.dead:
                high_score = read_high_scores()

                if self.player.score < high_score[self.world_number]:
                    end_game_dictionary = {
                        HIGH_SCORE: [
                            'High Score For This World: ' +
                            str(high_score[self.world_number]),
                            'You would need to score ' +
                            str(high_score[self.world_number] -
                                self.player.score) + ' more to beat it!'
                        ],
                        NEXT_WORLD: ['Exit', 'Return To The Menu']
                    }

                elif self.player.score == high_score[self.world_number]:
                    end_game_dictionary = {
                        HIGH_SCORE: [
                            'High Score For This World: ' +
                            str(high_score[self.world_number]),
                            'You Tied the High Score!'
                        ],
                        NEXT_WORLD: ['Exit', 'Return To The Menu']
                    }

                else:
                    end_game_dictionary = {
                        HIGH_SCORE: [
                            'High Score For This World: ' +
                            str(high_score[self.world_number]),
                            'You Beat the High Score!'
                        ],
                        NEXT_WORLD: ['Exit', 'Return To The Menu']
                    }

                    high_score[self.world_number] = self.player.score
                    write_high_scores(high_score)

                utility.dim(128, FILL_COLOR)

                end_game_menu = menu.Menu(
                    self.screen, self.music_list[self.world_number],
                    self.screen.convert(),
                    [0, SCREEN_HEIGHT / 3, SCREEN_WIDTH, SCREEN_HEIGHT],
                    ['Game Over', 128, SCREEN_WIDTH / 2, SCREEN_HEIGHT / 4],
                    end_game_dictionary)

                end_game_menu.show()

                self.done = True
                utility.fade_music()
                utility.play_music(self.music_list[MENU_MUSIC], True)
Example #20
0
    def handle_events(self):
        for event in pygame.event.get():
            if (event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE) or (event.type == pygame.MOUSEBUTTONDOWN and event.button == 3) or (event.type == pygame.ACTIVEEVENT and event.gain == 0):
                utility.dim(128, FILL_COLOR)

                # Grab a copy of the screen to show behind the menu
                screen_grab = self.screen.copy()
                pause_menu_running = True
                
                while pause_menu_running:
                    pause_menu = menu.Menu(self.screen,
                                           self.music_list[self.world_number],
                                           screen_grab,
                                           [0, SCREEN_HEIGHT / 3, SCREEN_WIDTH, SCREEN_HEIGHT],
                                           ['Pause', 128, SCREEN_WIDTH / 2, SCREEN_HEIGHT / 4],
                                           pause_menu_dictionary)

                    menu_result = pause_menu.show()
    
                    if menu_result == OPTION_MENU:
                        option_result = True
                        last_highlighted = 0

                        while option_result:
    
                            option_menu_dictionary = {
                                SOUND_MENU: ['Sound Options', 'Change Sound Options'],
                                DISPLAY_MENU: ['Video Options', 'Change Video Options'],
                                CHANGE_SENSITIVITY: ['Mouse Sensitivity: ' + prettyprint.mouse_sensitivity(settings_list[SENSITIVITY]), 'Change Mouse Sensitivity'],
                                EXIT_OPTIONS: ['Back', 'Go Back to the Main Menu']
                            }
    
                            sensitivity_menu_dictionary = {
                                0: ['Very Low', 'Change Sensitivity to Very Low'],
                                1: ['Low', 'Change Sensitivity to Low'],
                                2: ['Normal', 'Change Sensitivity to Normal'],
                                3: ['High', 'Change Sensitivity to High'],
                                4: ['Very High', 'Change Sensitivity to Very High']
                            }
                            
                            sound_menu_dictionary = {
                                TOGGLE_SFX: ['Sound Effects: ' + prettyprint.on(settings_list[SFX]), 'Turn ' + prettyprint.on(not settings_list[SFX]) + ' Sound Effects'],
                                TOGGLE_MUSIC: ['Music: ' + prettyprint.on(settings_list[MUSIC]), 'Turn ' + prettyprint.on(not settings_list[MUSIC]) + ' Music'],
                                EXIT_OPTIONS: ['Back', 'Go Back to the Option Menu']
                            }
                            
                            display_menu_dictionary = {
                                TOGGLE_PARTICLES: ['Particles: ' + prettyprint.able(settings_list[PARTICLES]), 'Turn ' + prettyprint.on(not settings_list[PARTICLES]) + ' Particle Effects'],
                                TOGGLE_FULLSCREEN: ['Video Mode: ' + prettyprint.screen_mode(settings_list[SETTING_FULLSCREEN]), 'Switch To ' + prettyprint.screen_mode(not settings_list[SETTING_FULLSCREEN]) + ' Mode'],
                                EXIT_OPTIONS: ['Back', 'Go Back to the Main Menu']
                            }
    
                            option_result = menu.Menu(self.screen,
                                                      self.music_list[self.world_number],
                                                      screen_grab,
                                                      [0, SCREEN_HEIGHT / 3, SCREEN_WIDTH, SCREEN_HEIGHT],
                                                      ['Options', 96,SCREEN_WIDTH / 2, SCREEN_HEIGHT / 4],
                                                      option_menu_dictionary,
                                                      last_highlighted).show()
                            
                            if option_result == SOUND_MENU:
                                sound_result = True
                                last_highlighted = 0

                                while sound_result:
                                    sound_menu = menu.Menu(self.screen,
                                                           self.music_list[self.world_number],
                                                           screen_grab,
                                                           [0, SCREEN_HEIGHT / 3, SCREEN_WIDTH, SCREEN_HEIGHT],
                                                           ['Sound Options', 96,SCREEN_WIDTH / 2, SCREEN_HEIGHT / 4],
                                                           sound_menu_dictionary,
                                                           last_highlighted)

                                    sound_result = sound_menu.show()
                                    
                                    if sound_result == TOGGLE_SFX:
                                        settings_list[SFX] = not settings_list[SFX]
                                        last_highlighted = 0
                                    
                                    elif sound_result == TOGGLE_MUSIC:
                                        settings_list[MUSIC] = not settings_list[MUSIC]

                                        if not settings_list[MUSIC]:
                                            pygame.mixer.Channel(MUSIC_CHANNEL).stop()

                                        last_highlighted = 1
                                        
                                    elif sound_result == EXIT_OPTIONS:
                                        sound_result = False
                                        
                                    sound_menu_dictionary = {
                                        TOGGLE_SFX: ['Sound Effects: ' + prettyprint.on(settings_list[SFX]), 'Turn ' + prettyprint.on(not settings_list[SFX]) + ' Sound Effects'],
                                        TOGGLE_MUSIC: ['Music: ' + prettyprint.on(settings_list[MUSIC]), 'Turn ' + prettyprint.on(not settings_list[MUSIC]) + ' Music'],
                                        EXIT_OPTIONS: ['Back', 'Go Back to the Option Menu']
                                    }
                                        
                            if option_result == DISPLAY_MENU:
                                display_result = True
                                last_highlighted = 0

                                while display_result:
                                    
                                    display_menu = menu.Menu(self.screen,
                                                             self.music_list[self.world_number],
                                                             screen_grab,
                                                             [0, SCREEN_HEIGHT / 3, SCREEN_WIDTH, SCREEN_HEIGHT],
                                                             ['Video Options', 96,SCREEN_WIDTH / 2, SCREEN_HEIGHT / 4],
                                                             display_menu_dictionary,
                                                             last_highlighted)

                                    display_result = display_menu.show()
                            
                                    if display_result == TOGGLE_PARTICLES:
                                        settings_list[PARTICLES] = not settings_list[PARTICLES]
                                        last_highlighted = 0
                                        
                                    elif display_result == TOGGLE_FULLSCREEN:
                                        settings_list[SETTING_FULLSCREEN] = not settings_list[SETTING_FULLSCREEN]
                                        last_highlighted = 1
                                        pygame.mixer.quit()
                                        pygame.mixer.init()
                                        
                                        if settings_list[SETTING_FULLSCREEN]:
                                            utility.set_fullscreen()
                                        else:
                                            utility.set_fullscreen(False)
                                            
                                        pygame.mouse.set_visible(False)
                                        
                                    elif display_result == EXIT_OPTIONS:
                                        display_result = False
                                        
                                    display_menu_dictionary = {
                                        TOGGLE_PARTICLES: ['Particles: ' + prettyprint.able(settings_list[PARTICLES]), 'Turn ' + prettyprint.on(not settings_list[PARTICLES]) + ' Particle Effects'],
                                        TOGGLE_FULLSCREEN: ['Video Mode: ' + prettyprint.screen_mode(settings_list[SETTING_FULLSCREEN]), 'Switch To ' + prettyprint.screen_mode(not settings_list[SETTING_FULLSCREEN]) + ' Mode'],
                                        EXIT_OPTIONS: ['Back', 'Go Back to the Main Menu']
                                    }
                            
                            elif option_result == EXIT_OPTIONS:
                                option_result = False
                            
                            elif option_result == CHANGE_SENSITIVITY:
                                sensitivity_result = True
                                last_highlighted = 0

                                while sensitivity_result:
                                    sensitivity_menu = menu.Menu(self.screen,
                                                                 self.music_list[self.world_number],
                                                                 screen_grab,
                                                                 [0, SCREEN_HEIGHT / 3, SCREEN_WIDTH, SCREEN_HEIGHT],
                                                                 ['Mouse Sensitivity', 96,SCREEN_WIDTH / 2, SCREEN_HEIGHT / 4],
                                                                 sensitivity_menu_dictionary,
                                                                 last_highlighted)

                                    sensitivity_result = sensitivity_menu.show()
                                    mouse_sensitivities = [0.5, 0.75, 1, 1.25, 1.5]
                                    settings_list[SENSITIVITY] = mouse_sensitivities[sensitivity_result]

                                    if sensitivity_result > 0:
                                        sensitivity_result = False
                                
                    elif menu_result == RESUME_GAME or menu_result == False:
                        pause_menu_running = False
                        pygame.mouse.get_rel()
    
                    elif menu_result == EXIT_GAME:
                        utility.fade_music()
                        utility.play_music(self.music_list[MENU_MUSIC], True)
                        self.done = True
                        pause_menu_running = False
                                       
            elif event.type == pygame.MOUSEMOTION and self.player.lives:
                mouse_input = [pygame.mouse.get_pos()[0] - 512.0, pygame.mouse.get_pos()[1] - 384.0]

                if mouse_input[0] != 0 and mouse_input[1] != 0:
                    self.player.fire()
                    self.player.velocity = (self.player.velocity + mouse_input) / 1.5 * settings_list[SENSITIVITY]
Example #21
0
    def run(self):
        while not self.done:
            if self.world_done:
                if self.world_number < MAX_WORLD:
                    self.world_beat()

                    # Resetting player lives so that it isn't in their best
                    # interest to play easier worlds just to have extra lives.
                    self.player.lives = 3
                    self.player.life_board.set_text('x' + str(self.player.lives))
                    
                    self.player.score = 0
                    self.player.next_bonus = 50000

                    # Loading the new world
                    self.world_number += 1
                    
                    if self.world_number == 0:
                        self.new_scene = scene.TutorialScene()

                    elif self.world_number == 1:
                        self.new_scene = scene.ForestScene()

                    elif self.world_number == 2:
                        self.new_scene = scene.RockyScene()

                    elif self.world_number == 3:
                        self.new_scene = scene.PinkScene()
                    
                    if self.world_number > settings_list[WORLD_UNLOCKED]:
                        settings_list[WORLD_UNLOCKED] = self.world_number

                    utility.play_music(self.music_list[self.world_number], True)
                    self.current_world = world.World(self.world_list[self.world_number], self.music_list[self.world_number])
                    self.current_world.load()
                    self.world_done = False
                        
                else:
                    self.game_beat()

            self.check_collision()
            self.update()
            self.draw()
            self.handle_events()
            
            pygame.mouse.set_pos(MOUSE_DEFAULT_POSITION)
            pygame.mouse.get_rel()
            self.mouse_last_move = pygame.mouse.get_pos()
            
            self.timer.tick(FRAMES_PER_SECOND)
     
            if self.player.dead:
                high_score = read_high_scores()

                if self.player.score < high_score[self.world_number]:
                    end_game_dictionary = {
                        HIGH_SCORE: ['High Score For This World: ' + str(high_score[self.world_number]), 'You would need to score ' + str(high_score[self.world_number] - self.player.score) + ' more to beat it!'],
                        NEXT_WORLD: ['Exit', 'Return To The Menu']
                    }

                elif self.player.score == high_score[self.world_number]:
                    end_game_dictionary = {
                        HIGH_SCORE: ['High Score For This World: ' + str(high_score[self.world_number]), 'You Tied the High Score!'],
                        NEXT_WORLD: ['Exit', 'Return To The Menu']
                    }

                else:
                    end_game_dictionary = {
                        HIGH_SCORE: ['High Score For This World: ' + str(high_score[self.world_number]), 'You Beat the High Score!'],
                        NEXT_WORLD: ['Exit', 'Return To The Menu']
                    }

                    high_score[self.world_number] = self.player.score
                    write_high_scores(high_score)

                utility.dim(128, FILL_COLOR)

                end_game_menu = menu.Menu(self.screen,
                                          self.music_list[self.world_number],
                                          self.screen.convert(),
                                          [0, SCREEN_HEIGHT / 3, SCREEN_WIDTH, SCREEN_HEIGHT],
                                          ['Game Over', 128, SCREEN_WIDTH / 2, SCREEN_HEIGHT / 4],
                                          end_game_dictionary)

                end_game_menu.show()

                self.done = True
                utility.fade_music()
                utility.play_music(self.music_list[MENU_MUSIC], True)
Example #22
0
    def handle_events(self):
        for event in pygame.event.get():
            if (event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE
                ) or (event.type == pygame.MOUSEBUTTONDOWN and event.button
                      == 3) or (event.type == pygame.ACTIVEEVENT
                                and event.gain == 0):
                utility.dim(128, FILL_COLOR)

                # Grab a copy of the screen to show behind the menu
                screen_grab = self.screen.copy()
                pause_menu_running = True

                while pause_menu_running:
                    pause_menu = menu.Menu(
                        self.screen, self.music_list[self.world_number],
                        screen_grab,
                        [0, SCREEN_HEIGHT / 3, SCREEN_WIDTH, SCREEN_HEIGHT],
                        ['Pause', 128, SCREEN_WIDTH / 2, SCREEN_HEIGHT / 4],
                        pause_menu_dictionary)

                    menu_result = pause_menu.show()

                    if menu_result == OPTION_MENU:
                        option_result = True
                        last_highlighted = 0

                        while option_result:

                            option_menu_dictionary = {
                                SOUND_MENU:
                                ['Sound Options', 'Change Sound Options'],
                                DISPLAY_MENU:
                                ['Video Options', 'Change Video Options'],
                                CHANGE_SENSITIVITY: [
                                    'Mouse Sensitivity: ' +
                                    prettyprint.mouse_sensitivity(
                                        settings_list[SENSITIVITY]),
                                    'Change Mouse Sensitivity'
                                ],
                                EXIT_OPTIONS:
                                ['Back', 'Go Back to the Main Menu']
                            }

                            sensitivity_menu_dictionary = {
                                0:
                                ['Very Low', 'Change Sensitivity to Very Low'],
                                1: ['Low', 'Change Sensitivity to Low'],
                                2: ['Normal', 'Change Sensitivity to Normal'],
                                3: ['High', 'Change Sensitivity to High'],
                                4: [
                                    'Very High',
                                    'Change Sensitivity to Very High'
                                ]
                            }

                            sound_menu_dictionary = {
                                TOGGLE_SFX: [
                                    'Sound Effects: ' +
                                    prettyprint.on(settings_list[SFX]),
                                    'Turn ' +
                                    prettyprint.on(not settings_list[SFX]) +
                                    ' Sound Effects'
                                ],
                                TOGGLE_MUSIC: [
                                    'Music: ' +
                                    prettyprint.on(settings_list[MUSIC]),
                                    'Turn ' +
                                    prettyprint.on(not settings_list[MUSIC]) +
                                    ' Music'
                                ],
                                EXIT_OPTIONS:
                                ['Back', 'Go Back to the Option Menu']
                            }

                            display_menu_dictionary = {
                                TOGGLE_PARTICLES: [
                                    'Particles: ' +
                                    prettyprint.able(settings_list[PARTICLES]),
                                    'Turn ' + prettyprint.on(
                                        not settings_list[PARTICLES]) +
                                    ' Particle Effects'
                                ],
                                TOGGLE_FULLSCREEN: [
                                    'Video Mode: ' + prettyprint.screen_mode(
                                        settings_list[SETTING_FULLSCREEN]),
                                    'Switch To ' + prettyprint.screen_mode(
                                        not settings_list[SETTING_FULLSCREEN])
                                    + ' Mode'
                                ],
                                EXIT_OPTIONS:
                                ['Back', 'Go Back to the Main Menu']
                            }

                            option_result = menu.Menu(
                                self.screen,
                                self.music_list[self.world_number],
                                screen_grab, [
                                    0, SCREEN_HEIGHT / 3, SCREEN_WIDTH,
                                    SCREEN_HEIGHT
                                ], [
                                    'Options', 96, SCREEN_WIDTH / 2,
                                    SCREEN_HEIGHT / 4
                                ], option_menu_dictionary,
                                last_highlighted).show()

                            if option_result == SOUND_MENU:
                                sound_result = True
                                last_highlighted = 0

                                while sound_result:
                                    sound_menu = menu.Menu(
                                        self.screen,
                                        self.music_list[self.world_number],
                                        screen_grab, [
                                            0, SCREEN_HEIGHT / 3, SCREEN_WIDTH,
                                            SCREEN_HEIGHT
                                        ], [
                                            'Sound Options', 96,
                                            SCREEN_WIDTH / 2, SCREEN_HEIGHT / 4
                                        ], sound_menu_dictionary,
                                        last_highlighted)

                                    sound_result = sound_menu.show()

                                    if sound_result == TOGGLE_SFX:
                                        settings_list[
                                            SFX] = not settings_list[SFX]
                                        last_highlighted = 0

                                    elif sound_result == TOGGLE_MUSIC:
                                        settings_list[
                                            MUSIC] = not settings_list[MUSIC]

                                        if not settings_list[MUSIC]:
                                            pygame.mixer.Channel(
                                                MUSIC_CHANNEL).stop()

                                        last_highlighted = 1

                                    elif sound_result == EXIT_OPTIONS:
                                        sound_result = False

                                    sound_menu_dictionary = {
                                        TOGGLE_SFX: [
                                            'Sound Effects: ' +
                                            prettyprint.on(settings_list[SFX]),
                                            'Turn ' + prettyprint.on(
                                                not settings_list[SFX]) +
                                            ' Sound Effects'
                                        ],
                                        TOGGLE_MUSIC: [
                                            'Music: ' + prettyprint.on(
                                                settings_list[MUSIC]),
                                            'Turn ' + prettyprint.on(
                                                not settings_list[MUSIC]) +
                                            ' Music'
                                        ],
                                        EXIT_OPTIONS:
                                        ['Back', 'Go Back to the Option Menu']
                                    }

                            if option_result == DISPLAY_MENU:
                                display_result = True
                                last_highlighted = 0

                                while display_result:

                                    display_menu = menu.Menu(
                                        self.screen,
                                        self.music_list[self.world_number],
                                        screen_grab, [
                                            0, SCREEN_HEIGHT / 3, SCREEN_WIDTH,
                                            SCREEN_HEIGHT
                                        ], [
                                            'Video Options', 96,
                                            SCREEN_WIDTH / 2, SCREEN_HEIGHT / 4
                                        ], display_menu_dictionary,
                                        last_highlighted)

                                    display_result = display_menu.show()

                                    if display_result == TOGGLE_PARTICLES:
                                        settings_list[
                                            PARTICLES] = not settings_list[
                                                PARTICLES]
                                        last_highlighted = 0

                                    elif display_result == TOGGLE_FULLSCREEN:
                                        settings_list[
                                            SETTING_FULLSCREEN] = not settings_list[
                                                SETTING_FULLSCREEN]
                                        last_highlighted = 1
                                        pygame.mixer.quit()
                                        pygame.mixer.init()

                                        if settings_list[SETTING_FULLSCREEN]:
                                            utility.set_fullscreen()
                                        else:
                                            utility.set_fullscreen(False)

                                        pygame.mouse.set_visible(False)

                                    elif display_result == EXIT_OPTIONS:
                                        display_result = False

                                    display_menu_dictionary = {
                                        TOGGLE_PARTICLES: [
                                            'Particles: ' + prettyprint.able(
                                                settings_list[PARTICLES]),
                                            'Turn ' + prettyprint.on(
                                                not settings_list[PARTICLES]) +
                                            ' Particle Effects'
                                        ],
                                        TOGGLE_FULLSCREEN: [
                                            'Video Mode: ' +
                                            prettyprint.screen_mode(
                                                settings_list[
                                                    SETTING_FULLSCREEN]),
                                            'Switch To ' + prettyprint.
                                            screen_mode(not settings_list[
                                                SETTING_FULLSCREEN]) + ' Mode'
                                        ],
                                        EXIT_OPTIONS:
                                        ['Back', 'Go Back to the Main Menu']
                                    }

                            elif option_result == EXIT_OPTIONS:
                                option_result = False

                            elif option_result == CHANGE_SENSITIVITY:
                                sensitivity_result = True
                                last_highlighted = 0

                                while sensitivity_result:
                                    sensitivity_menu = menu.Menu(
                                        self.screen,
                                        self.music_list[self.world_number],
                                        screen_grab, [
                                            0, SCREEN_HEIGHT / 3, SCREEN_WIDTH,
                                            SCREEN_HEIGHT
                                        ], [
                                            'Mouse Sensitivity', 96,
                                            SCREEN_WIDTH / 2, SCREEN_HEIGHT / 4
                                        ], sensitivity_menu_dictionary,
                                        last_highlighted)

                                    sensitivity_result = sensitivity_menu.show(
                                    )
                                    mouse_sensitivities = [
                                        0.5, 0.75, 1, 1.25, 1.5
                                    ]
                                    settings_list[
                                        SENSITIVITY] = mouse_sensitivities[
                                            sensitivity_result]

                                    if sensitivity_result > 0:
                                        sensitivity_result = False

                    elif menu_result == RESUME_GAME or menu_result == False:
                        pause_menu_running = False
                        pygame.mouse.get_rel()

                    elif menu_result == EXIT_GAME:
                        utility.fade_music()
                        utility.play_music(self.music_list[MENU_MUSIC], True)
                        self.done = True
                        pause_menu_running = False

            elif event.type == pygame.MOUSEMOTION and self.player.lives:
                mouse_input = [
                    pygame.mouse.get_pos()[0] - 512.0,
                    pygame.mouse.get_pos()[1] - 384.0
                ]

                if mouse_input[0] != 0 and mouse_input[1] != 0:
                    self.player.fire()
                    self.player.velocity = (
                        self.player.velocity +
                        mouse_input) / 1.5 * settings_list[SENSITIVITY]
Example #23
0
    def roll_credits(self):
        credit_group = pygame.sprite.Group()

        # Create Text Labels
        title_credit = text.Text(FONT_PATH, 48, FONT_COLOR, 'Credits')
        title_credit.set_position((SCREEN_WIDTH / 2, SCREEN_HEIGHT))

        big_jony = text.Text(FONT_PATH, 36, FONT_COLOR, 'Jony Fries')
        big_jony.set_position((SCREEN_WIDTH / 2, SCREEN_HEIGHT + 100))
        jony_credit0 = text.Text(FONT_PATH, 24, FONT_COLOR, 'Game Programming')
        jony_credit0.set_position((SCREEN_WIDTH / 2, SCREEN_HEIGHT + 150))
        jony_credit1 = text.Text(FONT_PATH, 24, FONT_COLOR, 'Sound Design')
        jony_credit1.set_position((SCREEN_WIDTH / 2, SCREEN_HEIGHT + 200))
        jony_credit2 = text.Text(FONT_PATH, 24, FONT_COLOR, 'Voice Acting')
        jony_credit2.set_position((SCREEN_WIDTH / 2, SCREEN_HEIGHT + 250))

        big_josh = text.Text(FONT_PATH, 36, FONT_COLOR, 'Joshua Skelton')
        big_josh.set_position((SCREEN_WIDTH / 2, SCREEN_HEIGHT + 350))
        josh_credit0 = text.Text(FONT_PATH, 24, FONT_COLOR, 'Game Programming')
        josh_credit0.set_position((SCREEN_WIDTH / 2, SCREEN_HEIGHT + 400))
        josh_credit1 = text.Text(FONT_PATH, 24, FONT_COLOR, ' Graphic Design')
        josh_credit1.set_position((SCREEN_WIDTH / 2, SCREEN_HEIGHT + 450))

        big_special = text.Text(FONT_PATH, 36, FONT_COLOR,
                                'Special Thanks To:')
        big_special.set_position((SCREEN_WIDTH / 2, SCREEN_HEIGHT + 550))
        special_credit0 = text.Text(FONT_PATH, 24, FONT_COLOR,
                                    'Python Software Foundation')
        special_credit0.set_position((SCREEN_WIDTH / 2, SCREEN_HEIGHT + 600))
        special_credit1 = text.Text(FONT_PATH, 24, FONT_COLOR, 'PyGame')
        special_credit1.set_position((SCREEN_WIDTH / 2, SCREEN_HEIGHT + 650))
        special_credit2 = text.Text(FONT_PATH, 24, FONT_COLOR,
                                    'ShyFonts Type Foundry')
        special_credit2.set_position((SCREEN_WIDTH / 2, SCREEN_HEIGHT + 700))

        thank_you = text.Text(FONT_PATH, 64, FONT_COLOR,
                              'Thank You For Playing!')
        thank_you.set_position((SCREEN_WIDTH / 2, SCREEN_HEIGHT + 800))

        # Add Labels to Group
        credit_group.add(title_credit)

        credit_group.add(big_jony)
        credit_group.add(jony_credit0)
        credit_group.add(jony_credit1)
        credit_group.add(jony_credit2)

        credit_group.add(big_josh)
        credit_group.add(josh_credit0)
        credit_group.add(josh_credit1)

        credit_group.add(big_special)
        credit_group.add(special_credit0)
        credit_group.add(special_credit1)
        credit_group.add(special_credit2)

        credit_group.add(thank_you)

        timer = 5 * FRAMES_PER_SECOND

        for credit in credit_group:
            credit.set_alignment(CENTER_MIDDLE)

        while self.rolling_credits:
            utility.play_music(self.music_list)

            for credit in credit_group:
                credit_position = credit.get_position()
                credit.set_position((credit_position[0],
                                     credit_position[1] + self.scroll_rate))

            credit_group.update()
            self.new_scene.draw(self.screen)
            credit_group.draw(self.screen)
            pygame.display.flip()
            self.handle_events()

            if special_credit2.get_position()[1] < 0:
                if self.finished:
                    self.rolling_credits = False

            if thank_you.get_position()[1] < (SCREEN_HEIGHT / 2):
                thank_you.set_position((SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2))
Example #24
0
    def show(self):
        self.menu_selection_pointer[self.current_selection].set_font(
            48, FONT_COLOR, FONT_PATH)
        pygame.mouse.get_rel()
        mouse_timeout = 10
        sample_mouse = True

        while True:
            # Music Stuff
            utility.play_music(self.music_list)

            # Drawing Stuff
            self.screen.fill(FILL_COLOR)
            self.menu_group.update()
            self.menu_tooltip_group.update()
            self.cursor_group.update()
            try:
                self.screen.blit(self.background_image,
                                 self.background_image.get_rect())
            except:
                self.background_image.draw(self.screen)

            self.menu_group.draw(self.screen)
            self.menu_tooltip_pointer[self.current_selection].draw(self.screen)
            self.cursor_group.draw(self.screen)

            pygame.display.flip()

            self.cursor.position = vector.Vector2d(
                pygame.mouse.get_pos()) + vector.Vector2d(32, 32)

            # Event Handling
            for event in pygame.event.get():
                if event.type == pygame.KEYDOWN and (
                        event.key == pygame.K_SPACE
                        or event.key == pygame.K_RETURN):
                    utility.play_sound(self.menu_forward_sound)

                    return list(
                        self.menu_dictionary.keys())[self.current_selection]

                elif event.type == pygame.MOUSEBUTTONDOWN and event.button == 1:
                    utility.play_sound(self.menu_forward_sound)

                    return list(
                        self.menu_dictionary.keys())[self.current_selection]

                elif event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE:
                    utility.play_sound(self.menu_back_sound)

                    return False

                elif event.type == pygame.MOUSEBUTTONDOWN and event.button == 3:
                    utility.play_sound(self.menu_back_sound)

                    return False

                elif event.type == pygame.KEYDOWN and event.key == pygame.K_UP:
                    self.menu_selection_pointer[
                        self.current_selection].set_font(
                            32, FONT_INACTIVE_COLOR, FONT_PATH)
                    self.current_selection -= 1

                    if self.current_selection < 0:
                        self.current_selection = len(self.menu_dictionary) - 1

                    self.menu_selection_pointer[
                        self.current_selection].set_font(
                            48, FONT_COLOR, FONT_PATH)
                    utility.play_sound(self.menu_beep_sound)

                elif event.type == pygame.KEYDOWN and event.key == pygame.K_DOWN:
                    self.menu_selection_pointer[
                        self.current_selection].set_font(
                            32, FONT_INACTIVE_COLOR, FONT_PATH)
                    self.current_selection += 1

                    if self.current_selection > len(self.menu_dictionary) - 1:
                        self.current_selection = 0

                    self.menu_selection_pointer[
                        self.current_selection].set_font(
                            48, FONT_COLOR, FONT_PATH)
                    utility.play_sound(self.menu_beep_sound)

                elif event.type == pygame.MOUSEMOTION:
                    for element in self.menu_group:
                        if element.mouse_over():
                            if element.text_index != self.current_selection:
                                self.menu_selection_pointer[
                                    self.current_selection].set_font(
                                        32, FONT_INACTIVE_COLOR, FONT_PATH)
                                mouse_selection = element.text_index
                                self.current_selection = mouse_selection
                                self.menu_selection_pointer[
                                    self.current_selection].set_font(
                                        48, FONT_COLOR, FONT_PATH)
                                utility.play_sound(self.menu_beep_sound)
                """
                elif event.type == pygame.KEYDOWN and event.key == pygame.K_q:
                    for element in self.menuTooltipGroup:
                        print 'ELEMENT: ', element.text_index
                        element.mouseOverDump()

                elif event.type == pygame.MOUSEMOTION:
                    mouseInput = list(pygame.mouse.get_rel())
                    if sample_mouse:
                        if mouseInput[1] < -10:
                            self.menuSelectionPointer[self.currentSelection].setFont(32, FONT_INACTIVE_COLOR, FONT_PATH)
                            self.currentSelection -= 1
                            if self.currentSelection < 0:
                                self.currentSelection = len(self.menuDictionary) - 1
                            self.menuSelectionPointer[self.currentSelection].setFont(48, FONT_COLOR, FONT_PATH)
                            sample_mouse = False
                            utility.playSound(self.menuBeep)

                        elif mouseInput[1] > 10:
                            self.menuSelectionPointer[self.currentSelection].setFont(32, FONT_INACTIVE_COLOR, FONT_PATH)
                            self.currentSelection += 1
                            if self.currentSelection > len(self.menuDictionary) - 1:
                                self.currentSelection = 0
                            self.menuSelectionPointer[self.currentSelection].setFont(48, FONT_COLOR, FONT_PATH)
                            sample_mouse = False
                            utility.playSound(self.menuBeep)   
                """

            if not sample_mouse:
                mouse_timeout -= 1

            if mouse_timeout == 0:
                sample_mouse = True
                mouse_timeout = 3

            self.timer.tick(30)