Esempio n. 1
0
def patch_sfx(rom, settings, log, symbols):
    # Configurable Sound Effects
    sfx_config = [
        (settings.sfx_navi_overworld, sfx.SoundHooks.NAVI_OVERWORLD),
        (settings.sfx_navi_enemy, sfx.SoundHooks.NAVI_ENEMY),
        (settings.sfx_low_hp, sfx.SoundHooks.HP_LOW),
        (settings.sfx_menu_cursor, sfx.SoundHooks.MENU_CURSOR),
        (settings.sfx_menu_select, sfx.SoundHooks.MENU_SELECT),
        (settings.sfx_nightfall, sfx.SoundHooks.NIGHTFALL),
        (settings.sfx_horse_neigh, sfx.SoundHooks.HORSE_NEIGH),
        (settings.sfx_hover_boots, sfx.SoundHooks.BOOTS_HOVER),
    ]
    sound_dict = sfx.get_patch_dict()

    for selection, hook in sfx_config:
        if selection == 'default':
            for loc in hook.value.locations:
                sound_id = int.from_bytes((rom.original[loc:loc + 2]),
                                          byteorder='big',
                                          signed=False)
                rom.write_int16(loc, sound_id)
        else:
            if selection == 'random-choice':
                selection = random.choice(
                    sfx.get_hook_pool(hook)).value.keyword
            elif selection == 'random-ear-safe':
                selection = random.choice(sfx.get_hook_pool(
                    hook, "TRUE")).value.keyword
            elif selection == 'completely-random':
                selection = random.choice(sfx.standard).value.keyword
            sound_id = sound_dict[selection]
            for loc in hook.value.locations:
                rom.write_int16(loc, sound_id)
        log.sfx[hook.value.name] = selection
Esempio n. 2
0
def update_level():
    check_events()
    check_goal()
    player.update()
    torch.update(player)
    GameStats.current_level.wall_list.draw(main_settings.screen)

    sprite_list.draw(main_settings.screen)

    if GameStats.game_level == 5:
        blind_affect.update(player)

    if GameStats.game_level in [6]:
        main_settings.screen.blit(torch.image, torch.rect)
        blind_affect.update(player, torch)
        player.pick_up_item(torch)

    #Try to blit the level's text to the screen
    try:
        main_settings.screen.blit(GameStats.current_level.lvl_text_image,
                                  GameStats.current_level.text_location)
    #Allow if there is no text
    except TypeError:
        pass

    if not sound.channel_busy(1):
        sound.play_background_sound()

    pygame.display.flip()
Esempio n. 3
0
    def spawning(self):
        if len(self.spawnlist) > 0:
            if self.spawnlist[0][0] == self.ticks:
                if self.spawnlist[0][1] == -1:
                    self.end = True
                    self.succes = True
                    return
                m = Mobs.Mob(self.spawnlist[0][1],self.spawnlist[0][2],self.spawnlist[0][3],self.spawnlist[0][4], self.spawnlist[0][5],self.spawnlist[0][6], self.spawnlist[0][7], self.spawnlist[0][8])
                Gamedata.all_sprites.add(m)
                Gamedata.mobs.add(m)
                self.spawnlist.pop(0)
                self.spawning()
        if len(self.propslist) > 0:
            if self.propslist[0][0] == self.ticks:
                prop = Backgroundprops.Backgroundprop(self.propslist[0][1],self.propslist[0][2],self.propslist[0][3],self.propslist[0][4])
                Gamedata.background.add(prop)
                self.propslist.pop(0)

        if len(self.textlist) > 0:
            if self.textlist[0][0] == self.ticks:
                text = Gametext.Text(self.textlist[0][1],self.textlist[0][2],self.textlist[0][3],self.textlist[0][4],self.textlist[0][5],self.textlist[0][6])
                Gamedata.background.add(text)
                self.textlist.pop(0)
        if len(self.musiclist) > 0:
            if self.musiclist[0][0] == self.ticks:
                Sounds.playsong(self.musiclist[0][1], self.musiclist[0][2])
                self.musiclist.pop(0)

        if random.randint(0,10) == 0:
            star = Backgroundprops.Star(False)
            Gamedata.stars.add(star)
        self.ticks += 1
        return
Esempio n. 4
0
 def endlevel(self, levelsucces):
     if not levelsucces:
         Gamedata.player.gold = self.level.startgold
         Gamedata.player.score = self.level.startscore
         Gamedata.mobs.empty()
         Gamedata.powerups.empty()
     Gamedata.background.empty()
     Gamedata.herobullets.empty()
     Gamedata.mobbullets.empty()
     Gamedata.all_sprites.empty()
     pygame.mouse.set_visible(True)
     Sounds.playsong('Hymne.mp3', True)
Esempio n. 5
0
def patch_sfx(rom, settings, log, symbols):
    # Configurable Sound Effects
    sfx_config = [
        ('sfx_navi_overworld', sfx.SoundHooks.NAVI_OVERWORLD),
        ('sfx_navi_enemy', sfx.SoundHooks.NAVI_ENEMY),
        ('sfx_low_hp', sfx.SoundHooks.HP_LOW),
        ('sfx_menu_cursor', sfx.SoundHooks.MENU_CURSOR),
        ('sfx_menu_select', sfx.SoundHooks.MENU_SELECT),
        ('sfx_nightfall', sfx.SoundHooks.NIGHTFALL),
        ('sfx_horse_neigh', sfx.SoundHooks.HORSE_NEIGH),
        ('sfx_hover_boots', sfx.SoundHooks.BOOTS_HOVER),
    ]
    sound_dict = sfx.get_patch_dict()
    sounds_keyword_label = {
        sound.value.keyword: sound.value.label
        for sound in sfx.Sounds
    }
    sounds_label_keyword = {
        sound.value.label: sound.value.keyword
        for sound in sfx.Sounds
    }

    for setting, hook in sfx_config:
        selection = settings.__dict__[setting]

        # Handle Plando
        if log.src_dict.get('sfx', {}).get(hook.value.name, ''):
            selection_label = log.src_dict['sfx'][hook.value.name]
            if selection_label == 'Default':
                selection = 'default'
            elif selection_label in sounds_label_keyword:
                selection = sounds_label_keyword[selection_label]

        if selection == 'default':
            for loc in hook.value.locations:
                sound_id = rom.original.read_int16(loc)
                rom.write_int16(loc, sound_id)
        else:
            if selection == 'random-choice':
                selection = random.choice(
                    sfx.get_hook_pool(hook)).value.keyword
            elif selection == 'random-ear-safe':
                selection = random.choice(sfx.get_hook_pool(
                    hook, "TRUE")).value.keyword
            elif selection == 'completely-random':
                selection = random.choice(sfx.standard).value.keyword
            sound_id = sound_dict[selection]
            for loc in hook.value.locations:
                rom.write_int16(loc, sound_id)
        if selection == 'default':
            log.sfx[hook.value.name] = 'Default'
        else:
            log.sfx[hook.value.name] = sounds_keyword_label[selection]
Esempio n. 6
0
    def hurt(self, damage, knockback):
        if damage == 0:
            return

        if self.curr_invis_frame <= 0:
            self.health -= damage
            self.change_x += knockback
            self.curr_invis_frame = self.invis_frame
            Sounds.play(Sounds.HURT)
        if self.health <= 0:
            self.level.game_over = True
            self.level.game_over_timer = 180
Esempio n. 7
0
    def move_to(self, entity):
        import Sounds
        if self.curr_move_cd == 0:
            if not self.jumping:
                self.change_y = self.jump_height

                if self.center_x > entity.center_x:
                    self.change_x = -self.movespeed
                elif self.center_x < entity.center_x:
                    self.change_x = self.movespeed
                Sounds.play(Sounds.SLIME_JUMP)
            self.jumping = True
            self.curr_move_cd = self.move_cd
        else:
            self.curr_move_cd -= 1
Esempio n. 8
0
	def explode (self, villian):
		centerX, centerY = villian.getCenter()
		self.villianList.remove(villian)
		villian.kill()
		if (self.sound_on):
			Sounds().Explode()
		self.explosionList.append(Explosion.Explosion(self._containers, self._screen, numpy.array([centerX, centerY])))
Esempio n. 9
0
 def newBoss(self):
     if (len(self.bossList) < self.maxBosses):
         self.bossList.append(
             _Boss(self._containers, self._screen,
                   uniform(self.minBossSpeed, self.maxBossSpeed)))
     if (self.sound_on):
         Sounds().CometStart()
Esempio n. 10
0
 def explode(self, friend):
     centerX, centerY = friend.getCenter()
     self.friendList.remove(friend)
     friend.kill()
     self.explosionList.append(
         Explosion.Explosion(self._containers,
                             self._screen,
                             numpy.array([centerX, centerY]),
                             imageFile='star.png'))
     Sounds().SmallExplode()
Esempio n. 11
0
	def __init__ (self, loc, containers, screen, sound_on=True, angle=0., stress=0.):
		_v = numpy.array([sin(angle), -cos(angle)]) * bulletSpeed
		self._particles = []
		_a = numpy.zeros(2)
		if stress > 0:
			_a[1] = 1.
		else:
			if (sound_on):
				Sounds().Fire()
		Sprite.__init__(self, containers, screen, imageFile='star.png', size=(20,20), x=loc, v=_v, a=_a)
Esempio n. 12
0
    def show(self, game):
        if self.success:
            return GameSummaryScreen(self.click_count, self.size)

        board_x = (game.window.get_width() - self.scale * self.board.x) // 2
        board_y = (game.window.get_height() - self.scale * self.board.y) // 2

        for event in game.events:
            if event.type == pygame.MOUSEBUTTONUP:
                if game.left_mouse_button_clicked or game.right_mouse_button_clicked:
                    clockwise = game.left_mouse_button_clicked

                    mouse_x, mouse_y = pygame.mouse.get_pos()
                    pipe_x = (mouse_x - board_x) // self.scale
                    pipe_y = (mouse_y - board_y) // self.scale

                    if pipe_x in range(self.board.x) and pipe_y in range(
                            self.board.y):
                        self.board.table[pipe_x][pipe_y].rotate(clockwise)
                        self.success = self.board.exists_connection_between_start_and_end_pipes(
                        )
                        self.click_count += 1
                        Sounds.play_pipe_rotate()

        pygame.draw.rect(game.window, (51, 26, 0),
                         self._get_frame_rectangle(board_x, board_y))
        pygame.draw.rect(game.window, (0, 0, 0),
                         (board_x, board_y, self.board.x * self.scale,
                          self.board.y * self.scale))

        for pipe in self.pipes:
            game.window.blit(
                pipe.image,
                (board_x + self.scale * pipe.x, board_y + self.scale * pipe.y))

        self.text.set_text(
            f"{Localization.get_text('score')} {self.click_count}.")
        self.text.write(game.window, y=(board_y - self.text.size) / 2)

        if self.success:
            Sounds.play_winning()

        return super().show(game)
Esempio n. 13
0
 def explode(self, boss):
     centerX, centerY = boss.getCenter()
     self.bossList.remove(boss)
     boss.kill()
     if (self.sound_on):
         Sounds().Explode()
     self.explosionList.append(
         Explosion.Explosion(self._containers,
                             self._screen,
                             numpy.array([centerX, centerY]),
                             explosionType='boss'))
Esempio n. 14
0
    def readOptionToRecordFromFile(self):
        records=open(resource_path("records.txt"),"r",encoding="utf-8")
        Sounds.SOUND_RECORD.clear()
        line = records.readline()

        while line:
            line = line.replace('\n','')
            Sounds.SOUND_RECORD[line]=Sounds.Sound(line)
            line = records.readline()

        records.close()
Esempio n. 15
0
def update_game():

    GameStats.current_level = GameStats.levels[GameStats.game_level]
    player.level = GameStats.current_level

    main_settings.screen.fill(main_settings.bg_color)

    check_events()

    if GameStats.start_menu:
        if not sound.channel_busy(1):
            sound.play_intro()
        show_start_menu()

    elif GameStats.game_level == 0:
        sound.stop_channel(1)
        play_level_one()

    elif GameStats.game_level == 1:
        play_level_two()

    elif GameStats.game_level == 2:
        play_level_three()

    elif GameStats.game_level == 3:
        play_level_four()

    elif GameStats.game_level == 4:
        play_level_five()

    elif GameStats.game_level == 5:
        play_level_six()

    elif GameStats.game_level == 6:
        play_level_seven()

    elif GameStats.game_level == 7:
        play_level_eight()

    #Set the game to run at 60fps
    clock.tick(100)
Esempio n. 16
0
	def play_screen(self):
		Sounds.play_music(Sounds.GAME_OVER)
		quit_button = self.screen.blit(self.quit_button_image, s.QUIT_BUTTON)
		retry_button = self.screen.blit(self.retry_button_image, s.RETRY_BUTTON)
		while not self.finished:
			for event in pygame.event.get():
				if event.type == pygame.QUIT:
					pygame.quit()
					quit()
				elif event.type == pygame.MOUSEBUTTONDOWN and event.button == 1:
					if quit_button.collidepoint(pygame.mouse.get_pos()):
						pygame.quit()
						quit()
					elif retry_button.collidepoint(pygame.mouse.get_pos()):
						pygame.mouse.set_visible(False)
						Sounds.stop_music()
						self.finished = True

			self.screen.blit(self.game_over_text, s.GAME_OVER)
			pygame.display.update()
			self.clock.tick(s.FPS)
Esempio n. 17
0
    def loadAssets(self):
        """Game class method to load all assets.

        """
        #loading assets (images, sounds)
        self.imageLoader = ImageLoader(self)
        self.soundLoader = snd.Sound()
        try:
            self.imageLoader.load_assets()
            self.soundLoader.load()
        except Exception:
            traceback.print_exc()
            self.running = False
Esempio n. 18
0
def assemble_sfx_option(f, internal_name: str, sound_hook: sfx.SoundHooks,
                        display_name: str):
    options = sfx.get_setting_choices(sound_hook).keys()
    sfx_to_id = {
        sound.replace('-', '_'): index
        for index, sound in enumerate(options)
    }
    docstring = 'Choose a sound effect. "random_choice" selects a random option. "random_ear_safe" selects a random safe option. "completely_random" selects any random sound.'

    f.write(f"class {internal_name}(Choice):\n")
    f.write(f"    \"\"\"{docstring}\"\"\"\n")
    f.write(f"    display_name = \"{display_name}\"\n")
    for sound, id in sfx_to_id.items():
        f.write(f"    option_{sound} = {id}\n")
    f.write(f"\n\n\n")
Esempio n. 19
0
 def __init__(self, parent):
     wx.Panel.__init__(self, parent)
     
     panel = wx.Panel(self, size=(WINDOW_WIDTH, WINDOW_HEIGHT))
     nb = wx.Notebook(panel)
     
     sd = Sounds(nb)
     mu = Music(nb)
     
     nb.AddPage(sd, "Sounds")
     nb.AddPage(mu, "Music")
     
     sizer = wx.BoxSizer()
     sizer.Add(nb, 1, wx.EXPAND)
     
     self.SetSizer(sizer)
Esempio n. 20
0
 def __init__(self, screen_width, screen_height):
     pygame.init()
     # Set screen dimensions
     pygame.display.set_caption("HH GAME")
     self.screen_width = screen_width
     self.screen_height = screen_height
     self.screen = pygame.display.set_mode(
         (self.screen_width, self.screen_height))
     # Set game (number of tracks and hobos)
     self.set_game()
     self.health = 30
     # Set sounds
     self.sounds = Sounds.Sounds()
     self.crash_sound = self.sounds.crash_sound
     self.sounds.background_music()
     # Set messages that will go to the screen
     self.messages = Messages.Messages(self.screen_width,
                                       self.screen_height, self.screen,
                                       self.health)
     self.messages.set_fonts()
Esempio n. 21
0
    def __init__(self, lang):
        """ Constructor function """

        # Call the parent's constructor
        super().__init__()
        # -- Attributes
        # Speed vector of the Worm
        self.change_x = 0
        self.change_y = 0

        # Player attributes
        self.life = 100
        self.name = ''
        self.team = ''
        self.current_gun = GunMenu.BAZOOKA
        self.is_dead = False
        self.is_playing = False

        self.sound = Sounds.Sounds(lang)

        # This holds all the images for the animated walk left/right
        # of our player
        self.walking_frames_l = []
        self.walking_frames_r = []
        #jumping
        self.jumping_frames_r = []
        self.jumping_frames_l = []
        #Shooting
        self.shooting_frames_r = []
        self.shooting_frames_l = []
        #Grenade
        self.grenade_frames_r = []
        self.grenade_frames_l = []
        #HolyBomb
        self.holybomb_frames_r = []
        self.holybomb_frames_l = []
        #Baseball
        self.baseball_frames_r = []
        self.baseball_frames_l = []

        # What direction is the player facing?
        self.direction = "R"

        # Is player jumping?
        self.jumping = False

        #Are we on a block
        self.onblock = False

        # List of sprites we can bump against
        self.level = None

        #Our aim
        self.aim = None

        #current time left
        self.time = 30
        self.start_time = 0

        #our bullet
        self.bullet = None

        sprite_sheet = SpriteSheet("Pics/worms_sprites.png")
        # Load all the right facing images into a list
        image = sprite_sheet.get_image(8, 8, 22, 26)  # efst til vinstri
        self.walking_frames_l.append(image)
        image = sprite_sheet.get_image(45, 8, 22, 26)  # efst í miðju
        self.walking_frames_l.append(image)
        image = sprite_sheet.get_image(84, 7, 18, 27)  # efst til hægri
        self.walking_frames_l.append(image)

        # Load all the right facing images, then flip them
        # to face left.
        image = sprite_sheet.get_image(8, 8, 22, 26)
        image = pygame.transform.flip(image, True, False)
        self.walking_frames_r.append(image)
        image = sprite_sheet.get_image(45, 8, 22, 26)
        image = pygame.transform.flip(image, True, False)
        self.walking_frames_r.append(image)
        image = sprite_sheet.get_image(84, 7, 18, 27)
        image = pygame.transform.flip(image, True, False)
        self.walking_frames_r.append(image)

        # Load players when holding a gun left
        image = sprite_sheet.get_image(191, 49, 24, 27)
        self.shooting_frames_l.append(image)

        # Load players when holding a gun right
        image = sprite_sheet.get_image(191, 49, 24, 27)
        image = pygame.transform.flip(image, True, False)
        self.shooting_frames_r.append(image)

        # Load players when holding a grenade right
        image = sprite_sheet.get_image(705, 126, 35, 40)
        image = pygame.transform.flip(image, True, False)
        self.grenade_frames_r.append(image)

        # Load players when holding a grenade left
        image = sprite_sheet.get_image(705, 126, 35, 40)
        self.grenade_frames_l.append(image)

        # Load players when holding a holy bomb right
        image = sprite_sheet.get_image(372, 126, 35, 40)
        image = pygame.transform.flip(image, True, False)
        self.holybomb_frames_r.append(image)

        # Load players when holding a holy bomb left
        image = sprite_sheet.get_image(372, 126, 35, 40)
        self.holybomb_frames_l.append(image)

        # Load players when holding a baseball bat right
        image = sprite_sheet.get_image(489, 210, 49, 47)
        image = pygame.transform.flip(image, True, False)
        self.baseball_frames_r.append(image)

        # Load players when holding a baseball bat left
        image = sprite_sheet.get_image(489, 210, 49, 47)
        self.baseball_frames_l.append(image)

        # Load player jumping left
        image = sprite_sheet.get_image(195, 5, 18, 33)  # jumping
        self.jumping_frames_l.append(image)

        # Load player jumping right
        image = sprite_sheet.get_image(195, 5, 18, 33)  # jumping
        image = pygame.transform.flip(image, True, False)
        self.jumping_frames_r.append(image)

        # Set the image the player starts with
        self.image = self.walking_frames_r[0]
        self.mask = pygame.mask.from_surface(self.image)

        # Set a reference to the image rect.
        self.rect = self.image.get_rect()
Esempio n. 22
0
def play_slide():
    if not sound.channel_busy(5):
        sound.play_slide()
Esempio n. 23
0
 def sounds(self):
     Sounds.run_program(self.app_log)
Esempio n. 24
0
    def hurt(self, damage, knockback):
        import Sounds
        if self.curr_invis_frame <= 0:
            Sounds.play(Sounds.SKELETON_HIT)

        super().hurt(damage, knockback)
Esempio n. 25
0
from Ball import *
from const import *
import pygame, sys
import colors
from Team import *
from Text import *
from Sounds import *

MARGIN_RIGHT = BACKGROUND_WIDTH - GAP_SIZE_WIDTH - 10
MARGIN_TOP = int(TABLE_SCORE_HEIGHT + BACKGROUND_HEIGHT / 2 - GOAL_WIDTH / 2)
DEFENDER_X = GAP_SIZE_WIDTH + 5 / 27 * GAME_WIDTH
MIDFIELDER_X = GAP_SIZE_WIDTH + 8 / 27 * GAME_WIDTH
STRIKER_X = GAP_SIZE_WIDTH + 11 / 27 * GAME_WIDTH
MIDDLE_Y = TABLE_SCORE_HEIGHT + GAP_SIZE_HEIGHT + GAME_HEIGHT / 2

sound = Sounds()


class GameInfo():
    def __init__(self):
        self.redTeamScore = 0
        self.blueTeamScore = 0
        self.blueGoal = pygame.Rect(0, MARGIN_TOP, GAP_SIZE_WIDTH + 10,
                                    GOAL_WIDTH)
        self.redGoal = pygame.Rect(MARGIN_RIGHT, MARGIN_TOP,
                                   GAP_SIZE_WIDTH + 10, GOAL_WIDTH)

    def isGoal(self):
        if self.blueGoal.colliderect(BALL.rect):
            self.redTeamScore += 1
            sound.isRedGoal()
def patch_cosmetics(settings, rom):
    log = CosmeticsLog(settings)

    # re-seed for aesthetic effects. They shouldn't be affected by the generation seed
    random.seed()

    # Set default targeting option to Hold
    if settings.default_targeting == 'hold':
        rom.write_byte(0xB71E6D, 0x01)
    else:
        rom.write_byte(0xB71E6D, 0x00)

    # patch music
    if settings.background_music == 'random':
        restore_music(rom)
        log.bgm = randomize_music(rom)
    elif settings.background_music == 'off':
        disable_music(rom)
    else:
        restore_music(rom)

    # patch tunic colors
    tunics = [
        ('Kokiri Tunic', settings.kokiri_color, 0x00B6DA38),
        ('Goron Tunic', settings.goron_color, 0x00B6DA3B),
        ('Zora Tunic', settings.zora_color, 0x00B6DA3E),
    ]
    tunic_color_list = get_tunic_colors()

    for tunic, tunic_option, address in tunics:
        # handle random
        if tunic_option == 'Random Choice':
            tunic_option = random.choice(tunic_color_list)
        # handle completely random
        if tunic_option == 'Completely Random':
            color = [
                random.getrandbits(8),
                random.getrandbits(8),
                random.getrandbits(8)
            ]
        # grab the color from the list
        elif tunic_option in tunic_colors:
            color = tunic_colors[tunic_option]
        # build color from hex code
        else:
            color = list(int(tunic_option[i:i + 2], 16) for i in (0, 2, 4))
            tunic_option = 'Custom'
        rom.write_bytes(address, color)
        log.tunic_colors[tunic] = dict(
            option=tunic_option,
            color=''.join(['{:02X}'.format(c) for c in color]))

    # patch navi colors
    navi = [
        ('Navi Idle', settings.navi_color_default, [0x00B5E184]),  # Default
        ('Navi Targeting Enemy', settings.navi_color_enemy,
         [0x00B5E19C, 0x00B5E1BC]),  # Enemy, Boss
        ('Navi Targeting NPC', settings.navi_color_npc, [0x00B5E194]),  # NPC
        ('Navi Targeting Prop', settings.navi_color_prop, [
            0x00B5E174, 0x00B5E17C, 0x00B5E18C, 0x00B5E1A4, 0x00B5E1AC,
            0x00B5E1B4, 0x00B5E1C4, 0x00B5E1CC, 0x00B5E1D4
        ]),  # Everything else
    ]
    navi_color_list = get_navi_colors()

    for navi_action, navi_option, navi_addresses in navi:
        # choose a random choice for the whole group
        if navi_option == 'Random Choice':
            navi_option = random.choice(navi_color_list)
        custom_color = False
        for address in navi_addresses:
            # completely random is random for every subgroup
            if navi_option == 'Completely Random':
                color = [
                    random.getrandbits(8),
                    random.getrandbits(8),
                    random.getrandbits(8), 0xFF,
                    random.getrandbits(8),
                    random.getrandbits(8),
                    random.getrandbits(8), 0x00
                ]
                if navi_action not in log.navi_colors:
                    log.navi_colors[navi_action] = list()
                log.navi_colors[navi_action].append(
                    dict(option=navi_option,
                         color1=''.join(
                             ['{:02X}'.format(c) for c in color[0:3]]),
                         color2=''.join(
                             ['{:02X}'.format(c) for c in color[4:7]])))
            # grab the color from the list
            elif navi_option in NaviColors:
                color = NaviColors[navi_option]
            # build color from hex code
            else:
                color = list(int(navi_option[i:i + 2], 16) for i in (0, 2, 4))
                color = color + [0xFF] + color + [0x00]
                custom_color = True
            rom.write_bytes(address, color)
        if custom_color:
            navi_option = 'Custom'
        if navi_action not in log.navi_colors:
            log.navi_colors[navi_action] = [
                dict(option=navi_option,
                     color1=''.join(['{:02X}'.format(c) for c in color[0:3]]),
                     color2=''.join(['{:02X}'.format(c) for c in color[4:7]]))
            ]

    # Configurable Sound Effects
    sfx_config = [
        (settings.sfx_hover_boots, sfx.SoundHooks.BOOTS_HOVER),
        (settings.sfx_menu_select, sfx.SoundHooks.MENU_SELECT),
        (settings.sfx_menu_cursor, sfx.SoundHooks.MENU_CURSOR),
        (settings.sfx_horse_neigh, sfx.SoundHooks.HORSE_NEIGH),
        (settings.sfx_navi, sfx.SoundHooks.NAVI),
        (settings.sfx_low_hp, sfx.SoundHooks.HP_LOW),
        (settings.sfx_nightfall, sfx.SoundHooks.NIGHTFALL),
    ]
    sound_dict = sfx.get_patch_dict()

    for selection, hook in sfx_config:
        if selection == 'default':
            for loc in hook.value.locations:
                sound_id = int.from_bytes((rom.original[loc:loc + 2]),
                                          byteorder='big',
                                          signed=False)
                rom.write_int16(loc, sound_id)
        else:
            if selection == 'random-choice':
                selection = random.choice(
                    sfx.get_hook_pool(hook)).value.keyword
            elif selection == 'random-ear-safe':
                selection = random.choice(sfx.no_painful).value.keyword
            elif selection == 'completely-random':
                selection = random.choice(sfx.standard).value.keyword
            sound_id = sound_dict[selection]
            for loc in hook.value.locations:
                rom.write_int16(loc, sound_id)
        log.sfx[hook.value.name] = selection

    # Player Instrument
    instruments = {
        #'none':            0x00,
        'ocarina': 0x01,
        'malon': 0x02,
        'whistle': 0x03,
        'harp': 0x04,
        'grind_organ': 0x05,
        'flute': 0x06,
        #'another_ocarina': 0x07,
    }
    if settings.sfx_ocarina != 'random':
        choice = settings.sfx_ocarina
    else:
        choice = random.choice(list(instruments.keys()))
    rom.write_byte(0x00B53C7B, instruments[choice])
    log.sfx['Ocarina'] = choice

    return log
Esempio n. 27
0
	def play_screen(self):

		Sounds.play_music(Sounds.INTRO)
		self.screen.blit(self.surfaces['background'], (0, 0))
		play_button = self.screen.blit(self.surfaces['play_button'], s.PLAY_BUTTON)
		quit_button = self.screen.blit(self.surfaces['quit_button'], s.QUIT_BUTTON_TITLE)

		while not self.finished:
			for event in pygame.event.get():
				if event.type == pygame.QUIT:
					pygame.quit()
					quit()
				elif event.type == pygame.MOUSEBUTTONDOWN and event.button == 1:
					if quit_button.collidepoint(pygame.mouse.get_pos()):
						pygame.quit()
						quit()
					elif play_button.collidepoint(pygame.mouse.get_pos()):
						pygame.mouse.set_visible(False)
						Sounds.stop_music()
						self.finished = True
				# Keyboard events:
				elif event.type is pygame.KEYDOWN:
					if event.key == pygame.K_ESCAPE:
						pygame.quit()
						quit()
					# Toggle full screen with 'f' key:
					elif event.key == pygame.K_f:
						self._toggle_full_screen()
					# Toggle sound effects:
					elif event.key == pygame.K_n:
						if Sounds.get_se_volume() == 0:
							Sounds.set_se_volume(self.volume)
						else:
							Sounds.set_se_volume(0)
					# Toggle music:
					elif event.key == pygame.K_m:
						if Sounds.get_music_volume() == 0:
							Sounds.set_music_volume(self.volume)
						else:
							Sounds.set_music_volume(0)

			# blit background
			self.screen.blit(self.surfaces['title'], s.TITLE_POS)
			self.screen.blit(self.surfaces['tower'], s.TOWER_POS)
			self.screen.blit(self.surfaces['instructions'], s.INSTRUCTIONS_POS)
			pygame.display.update()
			self.clock.tick(s.FPS)
Esempio n. 28
0
import pygame
import headpiece
import levelManeger
import Backgrounds
import Enemys
import GameObject
import Sounds

running = True
screen = pygame.display.set_mode((1000, 1000))

head = headpiece.headpiece(screen)
level = levelManeger.levelManeger(screen)
drawer0 = Backgrounds.BackgroundsDrawer(screen)
drawer1 = Enemys.EnemyDrawer(screen)
sound = Sounds.SoundPlay(screen)
modules = {
    'levelManeger': level,
    'headpiece': head,
    'BackgroundsDrawer': drawer0,
    'EnemyDrawer': drawer1,
    'Sounds': sound
}
FPS = 120
clock = pygame.time.Clock()
pasuse = False

GameObject.openLvl = int(open('data.save', 'r').read())

for i in modules.keys():
    modules[i].init(modules)
Esempio n. 29
0
def play_head_hit():
    sound.play_head_hit()
Esempio n. 30
0
def play_jump():
    sound.play_jump()
Esempio n. 31
0
    def __init__(self, db):
        super(QtWidgets.QMainWindow, self).__init__()
        self.setupUi(self)
        self._setupLog()
        self.currentStatus = None
        self.optionsMenu.triggered.connect(self._optionsMenuSelected)
        self.exitMenu.triggered.connect(self._exitMenuSelected)
        self.searchMenuItem.triggered.connect(self._addSearchTabSelected)
        self.statusMenuItem.triggered.connect(self._addStatusTabSelected)
        self.commodityMenuItem.triggered.connect(self._addCommodityTabSelected)
        self.guideMenuItem.triggered.connect(self._addGuideTabSelected)
        self.edceFinished.connect(self.onEdceUpdated)
        self.db = db
        self.analyzer = EliteLogAnalyzer.EliteLogAnalyzer()
        self.analyzer.setPath(Options.get("Elite-path", ""))
        self._updateEdceInstance()
        self.edceLastUpdated = int(
            datetime.datetime.now().timestamp()) - self._edceUpdateTimeout + 15
        self.edceLastUpdateInfo = None
        self.verificationCode = None
        self.startVerification = False
        self.sounds = Sounds.Sounds()

        self.timer = QtCore.QTimer(self)
        self.timer.timeout.connect(self.onTimerEvent)
        self.timer.start(1000)
        self.tabItems = []

        self.mainTab.setTabsClosable(True)
        self.mainTab.tabCloseRequested.connect(self._onTabClosing)

        #self.mainTab.currentChanged.connect(self._onTabChanged)

        newbutton = QtWidgets.QPushButton("New Search", self.mainTab)
        newbutton.clicked.connect(self._addSearchTabSelected)
        buttonlayout = QtWidgets.QStackedLayout()
        buttonlayout.addWidget(newbutton)
        buttonwidget = QtWidgets.QWidget()
        buttonwidget.setLayout(buttonlayout)

        self.mainTab.setCornerWidget(buttonwidget, 0)

        self.edceState = "notStation"

        if self.db.dbEmpty:
            print("db load failed or doesn't exist - downloading...")
            self.dbupdated.connect(self.loadSettingsAndUI)

            # display 'db downloading' tab
            self.mainTab.clear()
            widget = ui.DBloadingTab.DBloadingTab(self.db, self.analyzer, "",
                                                  self)
            widget.setTabName(str(1))
            #item = (widget.getTabName(), widget)
            self.mainTab.addTab(widget, QtGui.QIcon(), 'DB loading...')

            self.mainTab.setEnabled(False)
            ThreadWorker.ThreadWorker(
                lambda: EDDB.update(self.db, force=True),
                lambda result: self.dbupdated.emit()).start()
        else:
            self.loadSettingsAndUI()
            self._checkUpdate()
Esempio n. 32
0
    def update(self):

        speed_mult = 1
        if self.keyboard.is_pressed("sprint"):
            speed_mult = 2

        if self.keyboard.is_pressed("dash"):
            if not self.dashing:
                self.change_y += 2
            self.dashing = True

        if self.keyboard.is_pressed("l"):
            pass
            # self.level.reset = True

        if self.keyboard.is_pressed("down"):
            self.change_y -= 0.1
            self.crawling = True
            speed_mult *= 0.5
        else:
            self.crawling = False

        if self.keyboard.is_pressed("attack"):
            if self.curr_attack_speed == 0:

                extra_y_dir = 0
                if self.keyboard.is_pressed("up"):
                    extra_y_dir = 4
                elif self.keyboard.is_pressed("down"):
                    extra_y_dir = -4

                attack_x = (self.change_x) * 4
                attack_y = (self.change_y + extra_y_dir) * 3
                attack_angle = int(
                    math.atan2(attack_y, attack_x) / math.pi * 180)

                card = Projectile(
                    Textures.SPRITESHEET[3 + int((attack_angle % 360) / 45) +
                                         16], self.center_x, self.center_y,
                    attack_x, attack_y)
                self.level.add_entity_to_list(card, self.level.entities)
                self.curr_attack_speed = self.max_attack_speed
                Sounds.play(Sounds.SHOOT)

        if self.curr_attack_speed > 0:
            self.curr_attack_speed -= 1

        if self.keyboard.is_pressed("jump"):
            if self.level.physics_engine.can_jump(1):
                # if self.level.engine.can_jump(self, 1):
                if not self.jumping:
                    Sounds.play(Sounds.JUMP)
                self.level.physics_engine.jump(self.jump_height)
                self.jumping = True
            # elif self.level.engine.can_jump(self, -1):
            elif self.level.physics_engine.can_jump(-1):
                self.jumping = False
                self.curr_jump_height = 0

            if self.curr_jump_height > self.max_jump_height:
                self.jumping = False
                self.curr_jump_height = 0

        elif self.curr_jump_height >= self.min_jump_height:
            self.jumping = False
            self.curr_jump_height = 0

        if self.jumping:
            self.change_y = self.jump_height
            self.curr_jump_height += self.jump_height

        if self.keyboard.is_pressed("left"):
            self.change_x = -self.movespeed * speed_mult
        elif self.keyboard.is_pressed("right"):
            self.change_x = self.movespeed * speed_mult
        else:
            if self.change_x > 1:
                self.change_x -= 1
                self.not_mirrored = True
            elif self.change_x < -1:
                self.change_x += 1
                self.not_mirrored = False
            else:
                self.change_x = 0

        if self.dashing:
            if self.change_x > 0:
                self.change_x = self.movespeed * speed_mult * 1.5
            elif self.change_x < 0:
                self.change_x = -self.movespeed * speed_mult * 1.5

            self.curr_dash_frame += 1
            if self.curr_dash_frame >= self.dash_frame_speed * len(
                    self.dash_textures):
                self.curr_dash_frame = 0
                self.dashing = False

        elif self.crawling:
            self.curr_crawl_frame += 1
            if self.curr_crawl_frame >= self.crawl_frame_speed * len(
                    self.crawl_textures):
                self.curr_crawl_frame = 0
        else:
            self.walk_count += 1
            if self.walk_count >= len(
                    self.walking_textures) * self.walk_frame_speed:
                self.walk_count = 0

        if self.curr_invis_frame > 0 and self.curr_invis_frame % 12 < 6:
            self.texture = Textures.get_texture(15, 15)
        elif self.change_x > 0:
            if self.dashing:
                self.texture = self.dash_textures[self.curr_dash_frame //
                                                  self.dash_frame_speed]
            elif self.crawling:
                self.texture = self.crawl_textures[self.curr_crawl_frame //
                                                   self.crawl_frame_speed]
            else:
                self.texture = self.walking_textures[self.walk_count //
                                                     self.walk_frame_speed]
            # self.player_dir = True

        elif self.change_x < 0:
            if self.dashing:
                self.texture = self.dash_textures_mirrored[
                    self.curr_dash_frame // self.dash_frame_speed]
            elif self.crawling:
                self.texture = self.crawl_textures_mirrored[
                    self.curr_crawl_frame // self.crawl_frame_speed]
            else:
                self.texture = self.walking_textures_mirrored[
                    self.walk_count // self.walk_frame_speed]
            # self.player_dir = False
        else:
            if self.not_mirrored:
                if self.crawling:
                    self.texture = self.crawl_textures[0]
                else:
                    self.texture = self.idle_texture
            else:
                if self.crawling:
                    self.texture = self.crawl_textures_mirrored[0]
                else:
                    self.texture = self.idle_texture_mirrored

        super().update()