Exemplo n.º 1
0
 def reac_x(self):
     ok_food = self.stock.food < parameters.CRITICAL_FOOD
     ok_n = len(self.living_chars) > 1
     if ok_n and ok_food:
         sound.play_music("before winter")
         sounds.gong.play()
         choice = gui.get_cannibalism(self)
         if choice:
             sounds.scream.play()
             if choice == "a":
                 m = self.a
             if choice == "c":
                 m = self.c
             if choice == "h":
                 m = self.h
             m.life = -100000
             for c in self.living_chars:
                 self.stock.add_food(parameters.FOOD_CANNIBAL)
     else:
         sounds.cannot.play()
         if not ok_n:
             self.monitor.launch_fading_alert(
                 "The only survivor does not want to eat himself...")
         else:
             self.monitor.launch_fading_alert(
                 "In crew members' opinion, there is too much food left to cannibalize each other."
             )
Exemplo n.º 2
0
 def toggle_music(self):
     globals.music = not globals.music
     if globals.music:
         sound.play_music()
     else:
         sound.stop_music()
     self.update_sound_music_circles()
Exemplo n.º 3
0
def handle_inputs(player, event):
    #######################################################################################
    # Programmer Name: Alec
    # Date: 5/20/17
    # Purpose: handle inputs from the user
    # Input: player, event
    # Output: adjusted attributes for the player and sound
    #######################################################################################
    keymap = [pygame.K_UP, pygame.K_DOWN]
    sound.play_music()
    if event.type == pygame.KEYDOWN:
        if event.key == pygame.K_UP:
            player.motion = -1
        elif event.key == pygame.K_DOWN:
            player.motion = 1
        if event.key == pygame.K_LEFT:
            player.rotation = 1
        elif event.key == pygame.K_RIGHT:
            player.rotation = -1
        if event.key in keymap:
            sound.play_footsteps()
    elif event.type == pygame.KEYUP:
        if event.key == pygame.K_UP or event.key == pygame.K_DOWN:
            player.motion = 0
        if event.key == pygame.K_LEFT or event.key == pygame.K_RIGHT:
            player.rotation = 0
        if event.key in keymap:
            sound.stop_footsteps()
Exemplo n.º 4
0
 def toggle_music(self):
     globals.music = not globals.music
     if globals.music:
         sound.play_music()
     else:
         sound.stop_music()
     self.update_sound_music_circles()
Exemplo n.º 5
0
    def play(self):
        self.state = GameState.MENU
        self.background = Picture('title.png')
        sound.play_music('start')

        self.set_menu(StartMenu(self))
        # self.set_menu(LoadMenu(self))
        self.loop()
Exemplo n.º 6
0
 def enter(self):
     self.victory_image = pygame.image.load(
         resource_path("assets/victory.png"))
     self.victory_t = 0
     self.angle = 0
     self.scale = 0
     self.num_stars = self.scene.game.record_victory(self.num_steps)
     sound.play_music('victory', 0)
     self.stars = []
Exemplo n.º 7
0
 def set_next_day(self):
     self.storm_duration -= 1
     self.next_season -= 1
     if self.next_season == 5 and not self.waiting:
         next_idx = (self.season_idx + 1) % len(self.seasons)
         thorpy.launch_blocking_alert(self.seasons[next_idx].text)
         if self.seasons[next_idx].name == "Winter":
             sound.play_music("before winter")
     elif self.next_season == 0:
         self.set_next_season()
         self.next_season = parameters.SEASON_MOD_DAYS
     self.day += 1
Exemplo n.º 8
0
    def start_act(self):
        clickable.unregister_all()
        sound.play_music("Relax.mp3")
        if World.act == 1:
            self.load_option("burn_1")

        elif World.act == 2:
            self.load_option("fetch_1")

        else:
            self.load_option("final_1")

        World.act += 1
Exemplo n.º 9
0
    def tick(self):
        if self.fire_end and self.i > self.fire_end:
            # and now fire adventure mode
            import game
            import adventure

            event.fire("adventure.setup")
            adventure.active_adventure.start_act()
            game.mode = "adventure"

        if self.i > self.end:
            if not self.reached_end:
                sound.play_music("Relax.mp3")
                self.reached_end = True

            self.root.children = [
                self.title_tl_bg,
                self.title_tr_bg,
                self.title_tl,
                self.title_tr,
                self.title_bl,
                self.title_br,
                self.start_text,
                self.credits_text,
            ]
            if self.fire_end:
                self.root.children += [self.title_bl_fire, self.title_br_fire]

            if self.i % 15 == 7:
                self.start_text.fg = pytality.colors.WHITE
                self.start_text.update_data()
            elif self.i % 15 == 0:
                self.start_text.fg = pytality.colors.LIGHTGREY
                self.start_text.update_data()
                self.root.dirty = True

        self.i += 1
        while self.stages and self.i >= self.stages[0][0]:
            i, line, color = self.stages.pop(0)
            line.fg = color
            line.update_data()
Exemplo n.º 10
0
    def start(self):
        self.group = pygame.sprite.Group()
        bg = simplesprite.SimpleSprite("assets/menubg.png", (0,0))
        self.group.add(bg)

        self.selected_item_index = 0
        
        self.items = {}

        self.items['start'] = text.Text("START", "small", (20, 75))
        self.items['music'] = text.Text("MUSIC", "small", (20, 90))
        self.items['sound'] = text.Text("SOUND", "small", (20, 105))
        self.items['resolution'] = text.Text("RESOLUTION", "small", (20, 120))
        self.items['credits'] = text.Text("CREDITS", "small", (20, 135))
        self.items['exit'] = text.Text("EXIT", "small", (20, 150))
        
        self.item_names = list(self.items.keys())

        for item in self.items.values():
            self.group.add(item)
        self.update_selection()

        self.music_meter = simplesprite.SimpleSprite("assets/settingmeter.png", (80, 89))
        self.group.add(self.music_meter)
        self.sound_meter = simplesprite.SimpleSprite("assets/settingmeter.png", (80, 104))
        self.group.add(self.sound_meter)
        self.resolution_display = text.Text("1x1", "small", (100, 120))
        self.group.add(self.resolution_display)
        self.update_settings()
        sound.play_music("overworld")

        self.animated = []
        self.add_anim("assets/flag.png", 12, [0,1,2,3], (24,12))
        self.add_anim("assets/worker.png", 12, [2,3], (24,18))
        self.add_anim("assets/factory.png", 12, [0,1,2], (12,18))
        self.add_anim("assets/factory.png", 12, [0,1,2], (12,28))
        self.add_anim("assets/police.png", 12, [4,5], (168,30))
        self.add_anim("assets/police.png", 12, [2,3], (168 + 24,30 +24))
        self.add_anim("assets/soldier.png", 14, [0,1], (144, 150))
        self.add_anim("assets/soldier.png", 14, [0,1], (144, 162))
        self.timer = 0
Exemplo n.º 11
0
 def __init__(self):
     self.running = False
     game.init()
     self.screen = screen.Screen()
     game.game = self
     game.screen = self.screen
     self.clock = pygame.time.Clock()
     self.scene_num = 0
     self.scenes = []
     fx.init()
     
     self.ldraw = None
     self.activescenestack = []
     self.teen = contactnode.make_teen()
     game.teen = self.teen
     
     self.script = game.script = scriptmanager.ScriptManager("../res/script.txt", "../res/contacts.txt")
     #game.active_node = emailnode.test_email()
     #game.active_node = commentgame.CommentGame()
     #game.active_node = title.Title()
     sound.play_music()
Exemplo n.º 12
0
    def __init__(self):
        self.running = False
        game.init()
        self.screen = screen.Screen()
        game.game = self
        game.screen = self.screen
        self.clock = pygame.time.Clock()
        self.scene_num = 0
        self.scenes = []
        fx.init()

        self.ldraw = None
        self.activescenestack = []
        self.teen = contactnode.make_teen()
        game.teen = self.teen

        self.script = game.script = scriptmanager.ScriptManager(
            "../res/script.txt", "../res/contacts.txt")
        #game.active_node = emailnode.test_email()
        #game.active_node = commentgame.CommentGame()
        #game.active_node = title.Title()
        sound.play_music()
Exemplo n.º 13
0
    def start(self):
        self.scroll = (0, 0)
        self.back_group = pygame.sprite.Group()
        self.fore_group = pygame.sprite.Group()
        self.levelobjs = []
        self.map = simplesprite.SimpleSprite("assets/worldmaplayout.png",
                                             (0, 0))
        self.back_group.add(self.map)

        for i, level in enumerate(LEVELS):
            x, y = level[3][0], level[3][1]
            obj = framesprite.FrameSprite("assets/mapflag copy.png", 12)
            if self.game.save.get_level_state(i)['beaten']:
                obj.set_frame(1)
            obj.move(x - 6, y - 10)
            self.levelobjs.append((obj, level))
            self.back_group.add(obj)

        self.popup_sprites = []

        self.arrow = framesprite.FrameSprite("assets/selectarrow.png", 11)
        self.arrow.move(-11, -11)
        self.animated.append(self.arrow)
        self.fore_group.add(self.arrow)

        self.next_text = text.Text(">", "small", (0, -20))
        self.prev_text = text.Text("<", "small", (0, -20))
        self.fore_group.add(self.next_text)
        self.fore_group.add(self.prev_text)

        overlay = simplesprite.SimpleSprite("assets/mapoverlay.png", (0, 0))
        self.fore_group.add(overlay)
        self.selected_level = self.starting_level_index
        self.update_selection()
        self.flash_index = 0
        sound.play_music('overworld')
Exemplo n.º 14
0
    def reac_time_low(self):
        ##        if self.i > 150:
        ##            self.a.life = -10
        ##        if self.i > 300:
        ##            self.c.life = -10
        ##        if self.i > 1000:
        ##            self.h.life = -10
        ##        print(self.cam.chunk)
        if not pygame.mixer.music.get_busy():
            self.next_music()
        if perigeo.img_pos.distance_to(parameters.CENTER) < 50:
            if not self.does_perigeo:
                sounds.perigeo.play()
                gui.show_loading()
                scenario.launch_perigeo_text()
                self.does_perigeo = True
                self.journal.add_entry("Found Perigeo's wreckage!!!",
                                       "We can now go back to civilization.")
        if self.does_perigeo:
            if self.get_distance_from_0() < parameters.S:
                if self.score < 0:
                    self.score = self.day
                    self.journal.add_entry(
                        "End of the trip.",
                        "There are no words to describe our pride and joy.\nWe are back to our departure point."
                    )
                    gui.show_loading()
                    scenario.launch_end_text(self.score)

    ##                self.show_end()
    #checkpoints
        for c in self.controllables:
            c.refresh_last_position(self.cam)
        #temperature
        self.refresh_temperature()
        self.temp_pix = self.temp * parameters.TNORM_A + parameters.TNORM_B
        self.e_temp.set_text(str(self.temp_text) + " C ")
        #coordinates
        alt_text = int(
            (self.height - parameters.SUMMER_LEVEL) * parameters.FACTOR_ALT)
        self.alt_text = alt_text
        self.e_alt.set_text("Alt.: " + str(alt_text) + " m")
        ##        if self.a.life > 0:
        ##            x,y = self.cam.chunk
        ##        else:
        ##            x,y = "?", "?"
        if self.a.life > 0:
            self.gui_pos = (self.campos % parameters.WORLD_SIZE_PIX) / 10.
            xint = int(self.gui_pos[0])
            yint = int(self.gui_pos[1])
            x = str(xint)
            y = str(yint)
        else:
            x, y = "?", "?"
        self.e_x.set_text("X: " + x)
        self.e_y.set_text("Y: " + y)
        ##        self.pos_int += (xint,yint)
        #life and food
        if self.refresh_ship_life:
            self.e_life_ship.set_life(self.ship.life)
        #time
        newday = int(self.i * parameters.DAY_FACTOR)
        if newday > self.day:
            self.set_next_day()
            ##            self.advance_days(newday-self.day) #to be validated
            if newday in self.storms:
                if self.storm is None:
                    if parameters.BISURFACE:
                        self.cam.clouds = []
                    sound.play_music("storm", 10)
                    self.storm_duration = np.random.randint(2, 10)
                    F = 8.
                    self.storm = Wind((-F, -F), (F, F), (-1., -1.), (1., 1.),
                                      (1000, 1000))
                    self.ship.imgs = self.ship.storm_imgs
                    if self.seasons[self.season_idx].name == "Winter":
                        self.falls = self.snow
                    else:
                        self.falls = self.rain
            elif self.storm_duration <= 0:
                if self.storm is not None:
                    if parameters.BISURFACE:
                        self.cam.init_clouds()
                    sound.play_random_music()
                    self.storm = None
                    self.ship.imgs = self.ship.normal_imgs
            self.day = newday
            self.e_clock.set_text("Day " + str(newday))
        #
        if self.i > 0:
            self.stats.refresh()
        d = (self.ship.img_pos +
             Vector2(self.ship.img.get_size()) / 2).distance_to(
                 parameters.CENTER)
        self.can_board = d < parameters.BOARDING_DISTANCE
        self.can_camp = (self.collision_factor_summer
                         == 0) and (not self.aboard)
Exemplo n.º 15
0
    def __init__(self, dungeon, final_boss):
        sidebar_width = 26
        bottom_height = 17

        self.message_log = dungeon.message_log
        self.stat_display = dungeon.stat_display
        self.stat_display.set_mode("battle")
        clickable.unregister_all()


        self.battle_window = pytality.buffer.Buffer(
            x=sidebar_width,
            y=0,
            height=main.screen_height - bottom_height,
            width=main.screen_width - (sidebar_width * 2)

        )
        self.action_window = ActionWindow(
            width=main.screen_width - sidebar_width * 2,
            height=bottom_height,
            x=sidebar_width,
            y=main.screen_height - bottom_height,
            border_fg=pytality.colors.LIGHTGREY,
            battle=self,
        )
        self.action_overlay = overlay.Overlay(
            width=self.action_window.width,
            height=self.action_window.height - 1,
            x=0, y=0
        )

        self.real_boss = final_boss
        if self.real_boss:
            self.boss_sprite = BattleSprite(file_names=["finalboss.ans"], width=61, height=48, x=self.battle_window.width - 61, y=0, crop=True)
            self.boss_portrait = data.load_buffer("finalbossport.ans", width=16, crop=True)
            sound.play_music("The_Final_Threat.mp3")
        else:
            self.boss_sprite = BattleSprite(file_names=["you2.ans", "you2alt.ans"], width=34, height=31, x=self.battle_window.width - 40, y=14, crop=True)
            self.boss_portrait = data.load_buffer("youport.ans", width=16, crop=True)
            sound.play_music("OHC_Changeling_Rumble.mp3")

        act = (adventure.World.act - 1)
        self.boss_attack = 6 + (7 * act)
        self.boss_defense = 4 + (7 * act)
        self.boss_hp = self.boss_max_hp = 50 + (20 * act)

        self.hero_sprite = BattleSprite(file_names=[hero.active_hero.get_boss_file()], width=18, height=15, x=10, y=30)
        self.hero_portrait = data.load_buffer("heroportrait.ans", width=16, crop=True)

        self.battle_window.children = [self.boss_sprite, self.hero_sprite]

        self.fullscreen_flash = pytality.buffer.Buffer(
            x=sidebar_width,
            height=main.screen_height,
            width=main.screen_width - (sidebar_width * 2)
        )

        self.root = pytality.buffer.Buffer(height=0, width=0, children=[
            self.message_log,
            self.stat_display,
            self.battle_window,
            self.action_window
        ])
        self.i = 0
        self.flashed = False
        self.message_log.add("\n     <LIGHTRED>BOSS BATTLE!")

        self.next_state = "hero_talk"
        self.after_animation_state = None
        self.state_delay = 5

        self.pending_attack_type = None
        self.pending_attack_powerful = False
Exemplo n.º 16
0
 def start_up(self):
     sound.play_music('sounds/score.mp3')
Exemplo n.º 17
0
 def start(self):
     self.load()
     self.initialize_state()
     sound.play_music('game')
Exemplo n.º 18
0
    def keepMusicRunning(self, event):
        import sound

        sound.play_music()
Exemplo n.º 19
0
def dungeon_setup(monster_type=None):
    global active_dungeon
    active_dungeon = Dungeon(monster_type=monster_type)
    sound.play_music("Curse_of_The_Patashu.mp3")