Esempio n. 1
0
def load_option_menu():
    game_controller = controller.get_game_controller()
    game_controller.display_option_menu()
    misc_group.empty()
    option_menu_sprite = option.Menu()
    misc_group.add(option_menu_sprite)
    # attack_bar_sprite = attack_bar.Bar()
    # misc_group.add(attack_bar_sprite)
    misc_group.update()
Esempio n. 2
0
def gen_cloud():
    center = config.screen_center
    game_controller = controller.get_game_controller()
    y_offset = random.randint(125, 280)
    cloud_sprite = cloud.Cloud((center[0] + 300, center[1] + y_offset))
    misc_group.add(cloud_sprite)
    misc_group.update()
    game_controller.block_new_cloud()
    pg.time.set_timer(event_store.event["ALLOW_NEW_CLOUD"]["object"], 1000,
                      True)
Esempio n. 3
0
def gen_item():
    center = config.screen_center
    game_controller = controller.get_game_controller()
    y_offset = random.randint(225, 285)
    item_sprite = item.Item((center[0] + 300, center[1] + y_offset))
    misc_group.add(item_sprite)
    misc_group.update()
    print("CALLING NEW ITEM")
    game_controller.block_new_item()
    pg.time.set_timer(event_store.event["ALLOW_NEW_ITEM"]["object"], 2000,
                      True)
Esempio n. 4
0
def load_game_over(screen_center: Tuple[int, int], screen):
    music.stop_music()
    music.play_game_over_music()
    misc_group.empty()
    obstacles_group.empty()
    gameplay_group.empty()
    misc_group.update()

    game_over_sprite = game_over.Menu()
    misc_group.add(game_over_sprite)

    gameplay_group.update()
    misc_group.update()
Esempio n. 5
0
def load_main_menu(screen_center: Tuple[int, int]):
    misc_group.empty()
    misc_group.update()
    music.play_menu_bgm()
    heart_sprite = heart.Heart(screen_center)
    title_sprite = title.Title(screen_center)
    main_menu_sprite = main_menu.Menu()

    gameplay_group.add(heart_sprite)
    misc_group.add(title_sprite)
    misc_group.add(main_menu_sprite)

    gameplay_group.update()
    misc_group.update()
Esempio n. 6
0
def load_in_game(screen_center: Tuple[int, int]):
    music.play_ingame_music()
    spec.load_specs()
    game_controller = controller.get_game_controller()
    game_controller.game_loaded = True

    sans_sprite = sans.Sans((screen_center[0], screen_center[1] - 100))
    border_sprite = border.Border(screen_center)
    health_bar_sprite = health_bar.Bar()
    sans_health_sprite = sans_health_bar.Bar()
    generator.generate_sprites(
        (screen_center[0] + 400, screen_center[1] + 200))

    character_group.add(sans_sprite)
    misc_group.add(border_sprite)
    gameplay_group.add(health_bar_sprite)
    gameplay_group.add(sans_health_sprite)

    gameplay_group.update()
    character_group.update()
    misc_group.update()
    game_controller.display_game()
Esempio n. 7
0
def main():
    screen, clock = init_game()
    game_controller = controller.get_game_controller()
    game_controller.display_main_menu()

    screen_center = (screen.get_width() / 2, screen.get_height() / 2)

    load_config(screen_center)
    map_event()
    load_main_menu(screen_center)
    pg.display.flip()

    while game_controller.is_game_running():
        screen.fill(BLACK)
        events = pg.event.get()

        for event in events:
            if event.type == pg.KEYDOWN:
                key_handling(event.key)
            if event.type == pg.MOUSEBUTTONUP:
                click_handling()
            if event.type == pg.QUIT:
                game_controller.quit()
            if event.type == event_store.event["IN_GAME"]["value"]:
                load_in_game(screen_center)
            if event.type == event_store.event["LOAD_BONE"]["value"]:
                if spec.specs_index != 0:
                    border_sprite = border.Border(screen_center)
                    misc_group.add(border_sprite)
                generator.generate_sprites(
                    (screen_center[0] + 400, screen_center[1] + 200))
            if event.type == event_store.event["OPTION_MENU"]["value"]:
                load_option_menu()
            if event.type == event_store.event["ALLOW_NEW_CLOUD"]["value"]:
                game_controller.allow_new_cloud()
            if event.type == event_store.event["ALLOW_NEW_ITEM"]["value"]:
                game_controller.allow_new_item()
            if event.type == event_store.event["GAME_OVER"]["value"]:
                game_controller.display_game_over()
                load_game_over(screen_center, screen)
            if event.type == event_store.event["ATTACK_SANS"]["value"]:
                game_controller.toggle_attack()
                load_attack_bar(screen_center)
                misc_group.draw(screen)
            if event.type == event_store.event["END_GAME"]["value"]:
                game_controller.display_end_game()
        if game_controller.is_at_game_over():
            misc_group.draw(screen)
            spec.reset_spec_index()
            game_controller.allow_render()
        if game_controller.is_at_main_menu(
        ) or game_controller.is_at_option_menu():
            misc_group.draw(screen)
            gameplay_group.draw(screen)
            gameplay_group.update()
            misc_group.update()
        if game_controller.game_loaded and game_controller.is_in_game():
            if game_controller.is_paused():
                pause_menu_group.draw(screen)
            else:
                misc_group.draw(screen)
                if game_controller.is_new_cloud_allowed():
                    generator.gen_cloud()
                if game_controller.is_new_item_allowed():
                    generator.gen_item()
                character_group.draw(screen)
                obstacles_group.draw(screen)
                gameplay_group.draw(screen)
                character_group.update()
                obstacles_group.update()
                gameplay_group.update()
                misc_group.update()
                check_for_collision()
                prep_for_new_render()
                if spec.specs_index == spec.get_specs_length() - 1 and len(
                        obstacles_group.sprites()) == 0:
                    spec.reset_spec_index()
                    game_controller.allow_render()
                    generator.generate_sprites(
                        (screen_center[0] + 400, screen_center[1] + 200))
        pg.display.update()
        clock.tick(120)