Example #1
0
    def colisao_players_bola(self):
        for bola in self.lista_bola:
            for player in self.lista_jogador:
                batida = arcade.check_for_collision_with_list(
                    bola, self.lista_jogador)
                diferenca = player.center_x - bola.center_x
                if len(batida) > 0:
                    bola.vetor_x = (math.cos(math.pi / 2 + diferenca / 256 *
                                             (math.pi)) * 10)
                    bola.vetor_y = (math.sin(math.pi / 2 + diferenca / 256 *
                                             (math.pi)) * 10)
                    som = arcade.Sound('jogo/sons/somplayer.wav')
                    som.play()
                    break

        for bola in self.lista_bola:
            for player in self.lista_jogador2:
                batida = arcade.check_for_collision_with_list(
                    bola, self.lista_jogador2)
                diferenca = player.center_x - bola.center_x
                if len(batida) > 0:
                    bola.vetor_x = (math.cos(math.pi / 2 + diferenca / 256 *
                                             (math.pi)) * 10)
                    bola.vetor_y = (math.sin(math.pi / 2 + diferenca / 256 *
                                             (math.pi)) * 10)
                    som = arcade.Sound('jogo/sons/somplayer.wav')
                    som.play()
                    break
Example #2
0
    def __init__(self, width, height, title):
        super().__init__(width, height, title)
        self.center_window()

        map = arcade.read_tmx("my-maps/platfomer-map.tmx")
        self.talaj = arcade.tilemap.process_layer(map,
                                                  "talaj",
                                                  use_spatial_hash=True)
        self.egyeb = arcade.tilemap.process_layer(map,
                                                  "egyeb",
                                                  use_spatial_hash=True)
        self.targyak = arcade.tilemap.process_layer(map,
                                                    "targyak",
                                                    use_spatial_hash=True)

        # Példányosítjuk a Player osztályt.
        self.player = Player()
        self.physics = arcade.PhysicsEnginePlatformer(self.player,
                                                      self.talaj,
                                                      gravity_constant=GRAVITY)

        self.collected = 0

        self.sound = arcade.Sound("my-sounds/coin1.wav")
        self.music = arcade.Sound("my-sounds/funkyrobot.mp3")
        self.music.play(volume=0.1)
Example #3
0
 def colisao_parede_bola(self):
     #Se a bola tentar aflingir os limites de largura da parede, ela ira para o lado oposto.
     for bola in self.lista_bola:
         if (bola.center_x + 32 > LARGURA_TELA or bola.center_x < 32
             ) and self.contador_colisao_paredes_vertical <= 0:
             bola.center_x += -bola.vetor_x
             bola.center_y += -bola.vetor_y
             bola.vetor_x = -bola.vetor_x
             som = arcade.Sound('jogo/sons/somparede.wav')
             som.play()
             self.contador_colisao_paredes_vertical = 1
     #Se a bola tentar chegar ao teto ela será mandada ao lado oposto.
         if (bola.center_y + 32 > ALTURA_TELA
             ) and self.contador_colisao_paredes_horizontal <= 0:
             bola.center_x += -bola.vetor_x
             bola.center_y += -bola.vetor_y
             bola.vetor_y = -bola.vetor_y
             som = arcade.Sound('jogo/sons/somparede.wav')
             som.play()
             self.contador_colisao_paredes_horizontal = 1
     #Se a bola sair do limite e cair da tela no canto inferior ela irá ser removida da lista de bolas e jogador perderá uma vida.
     #Em seguida ela sera posta ao jogo novamente até que a vida dos jogadores chegue a zero.
         if bola.center_y < 32:
             bola.kill()
             self.adicionar_vida(-1)
             for player in self.lista_jogador:
                 self.lista_bola.append(
                     Bola(player.center_x + player.width / 4, 96))
                 break
             break
Example #4
0
    def __init__(self):
        super().__init__()
        self.sprite = Hero(scale=2,
                           center_x=self.window.width // 2,
                           center_y=self.window.height // 2,
                           speed=5)

        self.coins_list = arcade.SpriteList()
        self.big_coins_list = arcade.SpriteList()

        self.coins = [self.coins_list, self.big_coins_list]
        self.score = 0
        self.timer = 10
        self.last_time = time.time()  # запоминаем текущее значение времени

        self.cursor = Cursor()

        self.button = Button(center_x=self.window.width // 2,
                             center_y=self.window.height // 2,
                             width=150,
                             height=30,
                             color=RED,
                             text="START",
                             text_color=BLACK)
        self.button_list = arcade.SpriteList()
        self.button_list.append(self.button)

        # подготавливаем звуки
        self.music = arcade.Sound(MUSIC)  # фоновая музыка
        self.sound_effect = arcade.Sound(SOUND)  # звук сбора монет
        self.player = None  # понадобиться для управления музыкой
Example #5
0
    def __init__(self):
        super().__init__(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE)

        self.player_list = None
        self.bullet_list = None
        self.word_list = None
        self.star_list = None
        self.spokenwords = None

        self.score = 0

        self.word_count = 0
        self.word_create_delay = 0

        self.words = [
            "what", "this", "his", "I", "or", "her", "word", "that", "the",
            "poop", "can", "at", "dog", "from", "frog", "have", "it", "is",
            "in", "for", "but", "Sonic", "Shadow", "was", "on", "we", "are",
            "be", "with", "you", "your", "and", "me", "my", "as", "he", "to",
            "of", "if"
        ]

        arcade.set_background_color(arcade.csscolor.BLACK)

        self.lasersound = arcade.Sound("assets/Bonus/sfx_laser2.ogg")
        if PLAY_MUSIC:
            self.music = arcade.Sound("assets/Bonus/solar_striker1.mp3",
                                      streaming=True)
 def add_sounds(self) -> None:
     """
     loads all sounds from disk and adds them to self.sounds for later use
     :return: none
     """
     self.sounds.append(arcade.Sound("sounds/minecraft-theme.mp3"))
     self.sounds.append(arcade.Sound("sounds/starcraft-theme.mp3"))
     self.sounds.append(arcade.Sound("sounds/player_attack.mp3"))
Example #7
0
 def __init__(self, knife_object):
     super(ThrowingKnife, self).__init__(knife_object.texture,
                                         knife_object.scale)
     self.speed = knife_object.speed
     self.range = knife_object.range * 64
     self.max_speed = knife_object.max_speed
     self.sounds = [arcade.Sound(sound) for sound in knife_object.sounds]
     self.hit_sound = arcade.Sound("resources/sounds/knife_hit_ground.wav")
     self.triangle = None
Example #8
0
    def __init__(self):
        super().__init__()

        random.seed()

        self.paddle_hit = arcade.Sound('sounds/paddle_hit.wav')
        self.score = arcade.Sound('sounds/score.wav')
        self.wall_hit = arcade.Sound('sounds/wall_hit.wav')
        arcade.play_sound(self.paddle_hit)
        # If you have sprite lists, you should create them here,
        # and set them to None
        self.gd  = None
Example #9
0
 def __init__(self, knife_object):
     super(ThrowingKnife, self).__init__(knife_object.texture,
                                         knife_object.scale)
     self.speed = knife_object.speed
     self.range = knife_object.range * 64
     self.max_speed = knife_object.max_speed
     self.sounds = [arcade.Sound(sound) for sound in knife_object.sounds]
     self.hit_sound = arcade.Sound("resources/sounds/knife_hit_ground.wav")
     self.trajectory = None
     self.path = None
     self.direction = 0
     self.ang_change = 0
     self.thrown = False
Example #10
0
    def __init__(self, position_x: int, position_y: int):
        """
        Creates an instance of the player (wielding a shotgun by default),
        although it contains the skin of every weapon.

        :param position_x: The initial x position of the player.
        :param position_y: The initial y position of the player.
        """

        # Esta imagen es una por defecto. En realidad no importa cual sea.
        super().__init__(position_x, position_y,
                         "./resources/sprites/player/Shotgun.png", 1)

        # Used for flipping between image sequences
        self.cur_texture = 0
        self.UPDATES_PER_FRAME = 4
        self.character_face_direction = 0

        # Weapon
        self.weapon = "Akimbo"
        self.shooting = False
        Player.change_animation(self)

        # Weapons
        self.textures = []
        self.textures.append("./resources/sprites/player/shotgun.png")
        self.textures.append("./resources/sprites/player/machinegun.png")

        # Health
        self.health = 10

        # self.shooting = False

        # Sounds
        self.shotgun_sound = arcade.Sound("./resources/sounds/shotgun.wav")
        self.machinegun_sound = arcade.Sound(
            "./resources/sounds/machinegun.wav")
        self.akimbo_sound = arcade.Sound("./resources/sounds/akimbo.wav")
        self.shoot_count = 0

        # Movement
        self.speed = 500
        self.mov_ud = ""
        self.mov_lr = ""

        # Bullseye
        self.bullseye = arcade.Sprite(
            "./resources/sprites/player/bullseye.png", 0.75)
        self.mouse_position = [0, 0]
Example #11
0
    def on_update(self, delta_time: float):
        # update the player and branches
        self.entity_list.update()

        # make a list of branches that were collected
        collected_branches = arcade.check_for_collision_with_list(
            self.player, self.branch_list)

        # remove branches, add to the score, and make a sound
        for branch in collected_branches:
            branch.remove_from_sprite_lists()
            self.score += 1
            self.sound = arcade.Sound(":resources:sounds/coin5.wav")
            self.sound.play(0.5)

        # detect if the player has touched a tree or the camping equipment
        if self.player.collides_with_list(self.collision_list):
            self.player.change_x = 0
            self.player.change_y = 0

        # if a player returns to camp with at least 4 branches, they win
        if self.player.collides_with_list(self.camp_list) and self.score > 3:
            self.player.change_x = 0
            self.player.change_y = 0
            arcade.close_window()
Example #12
0
    def __init__(self):
        super().__init__()

        self.stena_list = None
        self.vxod_list = None
        self.back_list = None
        self.player = None
        self.enemy_list = None
        self.coin_list = None
        self.collision_list = None
        self.map_number = -1
        self.comback = False
        self.question = False

        self.coin_sound = ar.Sound('sound\Sound_19349.mp3')
        self.damage_sound = ar.Sound('sound\damage by kirik.m4a')
Example #13
0
    def __init__(self):
        super().__init__()
        arcade.set_background_color(arcade.csscolor.BLACK)

        # Variables that will hold sprite lists
        self.player_list = None
        self.asteroid_list = None
        self.explosions_list = None
        self.life_list = None
        self.asteroid_hit_list = None
        self.fall_life_list = None

        # Variables that are for a single sprite.
        self.life_sprite = None
        self.player_sprite = None

        self.score = 0

        self.view_bottom = 0
        self.view_left = 0

        self.background = None

        # Holds where the sounds are from, and tells the models to expect it.
        self.gun_sound = arcade.load_sound(":resources:sounds/hurt5.wav")
        self.hit_sound = arcade.load_sound(":resources:sounds/explosion2.wav")
        self.music = arcade.Sound(":resources:music/8-Bit-Surf.mp3",
                                  streaming=True)

        self.window.set_mouse_visible(
            False
        )  # Since the "curser" is the cross hairs we don't want to see the actual mouse curser.
 def switch_music(self, filename):
     volume = self.media_player.volume if self.media_player else 1
     old = self.media_player
     self.media_player = arcade.Sound(MUSIC_PREFIX.format(filename)).play(
         volume=volume, loop=True)
     if old:  # Do this afterwards to minimize a gap in sound
         old.pause()
Example #15
0
 def play_song(self):
     if not self.music:
         self.music = arcade.Sound(resource_path(random.choice(
             ['music/MenuSong.wav', 'music/S1-Beep.wav', 'music/S2-FastBeep.wav', 'music/S3-Nyoom.wav'])),
                                   streaming=True)
     self.music.play(0.1)
     sleep(0.03)
Example #16
0
    def __init__(self, planet_name, *args, **kwargs):
        super().__init__(PLANET_SPRITES[planet_name], *args, **kwargs)
        self.name = planet_name
        self.speed_x = None
        self.speed_y = None
        self.health = 1
        self.can_push_planets = self.name == "yogh"
        self.can_blast_planets = self.name == "yogh"
        self.can_melee_planets = self.name == "ze"
        self.can_range_planets = self.name == "ezh"
        self.max_attack_distance = MAX_ATTACK_DISTANCE[self.name]
        self.base_damage = BASE_DAMAGE * PLANET_DAMAGE[self.name]
        self.color = PLANET_COLORS[self.name]
        self.attack_sound = arcade.Sound(ATTACK_SOUND[self.name])

        self.parent = None
        self.others = None
        self.damage_on_others = None

        self.attacked_last_round = []
        self.total_healing = 0

        self.last_triangulating = None

        self.proper_name = self.name[0].upper() + self.name[1:].lower()
def setup_window(graphicsWindow):
    gold_list = []
    width, height = graphicsWindow.get_size()
    for gold_count in range(6):
        gold_pot = arcade.Sprite("unnamed.png")
        xpos = random.randint(0, width)
        ypos = random.randint(0, height)
        gold_pot.set_position(xpos, ypos)
        gold_list.append(gold_pot)

    player = arcade.Sprite("galleon (1).png")
    player.set_position(200, 500)
    graphicsWindow.player = player

    graphicsWindow.gold_list = gold_list
    arcade.set_background_color(arcade.color.SEA_BLUE)
    graphicsWindow.playerDx = 0
    graphicsWindow.playerDy = 0
    graphicsWindow.up_pressed = False
    graphicsWindow.down_pressed = False
    graphicsWindow.right_pressed = False
    graphicsWindow.left_pressed = False
    graphicsWindow.score = 0
    ching_sound = arcade.Sound("Cash_register.ogg")
    graphicsWindow.ching_sound = ching_sound
Example #18
0
    def play_song(self):
        if self.music:
            self.music.stop()

        self.music = arcade.Sound(self.music_list[self.current_song_index],
                                  streaming=True)
        self.current_player = self.music.play(constants.MUSIC_VOLUME)
Example #19
0
 def __init__(self, center_x, center_y, width, height, color, text, text_color):
     super(Button, self).__init__(width, height, color)
     self.text = text
     self.text_color = text_color
     self.center_x = center_x
     self.center_y = center_y
     self.sound = arcade.Sound(SOUND)   # подготавливаем звук
Example #20
0
 def process(self, dt):
     for ent, sound in self.world.get_component(Sound):
         if self.world.has_component(ent, Timeout):
             continue
         arcade_sound = arcade.Sound(sound.file_path)
         arcade_sound.play(volume=sound.volume)
         self.world.delete_entity(ent)
Example #21
0
    def send_msg(self, target, message):
        """Send a message from the chat to a worker."""
        self.messages.append(ChatMessage(self.player_worker, target, message))
        arcade.Sound(MUSIC_PREFIX.format('sfx_send_message.ogg')).play()

        if message == self.game_view.solution:
            self.game_view.win()
Example #22
0
    def setup(self):

        self.player = Player()
        self.capitol = Capitol()
        self.coequipier = None
        self.gui = Gui(0, CONST.MAX_VOTES)
        self.supporters = []
        self.bullets = []
        self.ui_manager = UIManager()

        self.tweet = Tweet()

        self.strike_button = Strike(center_x=CONST.STRIKE_BUTTON_X,
                                    center_y=CONST.STRIKE_BUTTON_Y,
                                    normal_texture=self.button_normal,
                                    hover_texture=self.button_hovered_texture,
                                    text='')

        self.ui_manager.add_ui_element(self.strike_button)

        arcade.set_background_color(arcade.color.AMAZON)
        self.background = arcade.load_texture("tileset/background.png")

        self.music_list = ["audios/background_music.mp3"]
        self.current_song_index = 0
        self.music = arcade.Sound(self.music_list[self.current_song_index],
                                  streaming=True)
        self.play_song()
Example #23
0
    def on_mouse_press(self, x: float, y: float, button: int, modifiers: int):
        if self.state == 0:
            for button in self.button_list_0:
                assert (isinstance(button, arcade.gui.TextButton))
                button.check_mouse_press(x, y)

        elif self.state == 1:
            left, right, bottom, top = arcade.get_viewport()

            if button == arcade.MOUSE_BUTTON_LEFT:
                self.player.shooting = True

            for button2 in self.pause_list:
                if isinstance(button2, Button):
                    button2.check_mouse_press(x + left, y + bottom)

            # Easter egg
            if self.pause:
                if (self.player.check_mouse_press(x + left, y + bottom)):
                    self.contador += 1
                    if self.contador == 15:
                        self.song.stop()
                        self.song = arcade.Sound("./resources/music/song2.wav")
                        self.volume = 0.01
                        arcade.Sound.play(self.song, self.volume)

        elif self.state == 2:
            for button in self.button_list_1:
                assert (isinstance(button, arcade.gui.TextButton))
                button.check_mouse_press(x, y)
        elif self.state == 3:
            pass
Example #24
0
    def setup(self):
        self.set_update_rate(1 / 8)  # fps

        self.game_started = False
        self.game_over = False
        self.score = 0

        self.snake = Snake(
            (self.width, self.height),
            self.tile_size
        )
        self.apple = Apple(
            (self.width, self.height),
            self.tile_size,
            self.snake.placement
        )

        # goes clockwise (top, right, bottom, left)
        self.borders = (
            int(self.height - self.tile_size / 2),
            int(self.width - self.tile_size / 2),
            int(0 + self.tile_size / 2),
            int(0 + self.tile_size / 2),
        )

        self.death_sound = arcade.Sound('assets/audio/death.mp3')

        return self
Example #25
0
    def setup(self, start_x, start_y, end_x, end_y):
        ""
        bullet = arcade.Sprite("assets/images/laserBlue01.png", constants.BULLET_SCALING)
        bullet.sound = arcade.Sound("assets/sounds/laser2.wav")
        bullet.sound.play(volume= .04)

        bullet.center_x = start_x
        bullet.center_y = start_y
        
        dest_y = end_y
        dest_x = end_x

        x_diff = dest_x - start_x
        y_diff = dest_y - start_y
        angle = math.atan2(y_diff, x_diff) # retruns the arc tangent of a number (x) between -pi/2 and pi/2 (think back to pre-calculus)

        # Angle the bullet/laser
        bullet.angle = math.degrees(angle)

        bullet.change_x = math.cos(angle) * constants.BULLET_SPEED 
        bullet.change_y = math.sin(angle) * constants.BULLET_SPEED 
        self.bullet_list.append(bullet)

        
            
            
        
        
Example #26
0
 def music_play(self):
     if self.scene in self.music_load:
         if self.music is not None:
             self.music.stop()
         self.music = arcade.Sound(self.music_load[self.scene],
                                   streaming=True)
         self.music.play(0.01)
Example #27
0
def _init_sounds() -> Dict[str, arcade.Sound]:
    sounds = {}
    path = container.path / "sounds"
    for sound_path in path.iterdir():
        key = sound_path.name
        sound = arcade.Sound(sound_path)
        sounds[key] = sound
    return sounds
Example #28
0
def main():
    s_title = "Peace"
    arcade.Window.music = arcade.Sound("feather.mp3", streaming=True)
    arcade.open_window(s_width, s_height, s_title)
    fps = 22  # can change fps by manipulating the value of the variable fps
    arcade.schedule(draw_bg, 1 / fps)
    #arcade.Window.music.play(0.3)
    arcade.run()
Example #29
0
def main():
    """ Main method """

    window = arcade.Window(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE)
    arcade.Window.music = arcade.Sound("backgroundmusic.mp3", streaming=True)
    start_view = InstructionView()
    window.show_view(start_view)
    arcade.run()
Example #30
0
 def __init__(self,width,height):
     super().__init__(width,height)
     # Importing of sounds:
     self.flap = arcade.Sound('sfx_wing.wav')
     self.die = arcade.Sound('sfx_die.wav')
     self.point = arcade.Sound('sfx_point.wav')
     self.die = arcade.Sound('sfx_hit.wav')
     self.background = None
     # Setting up the arcade and all variables associated with it
     self.player_list = None
     self.sprite_list = None
     self.score = None
     self.MOVEMENT_SPEED_X = 0
     self.MOVEMENT_SPEED_Y = 0
     self.apple = None
     self.counter = 0
     self.score = 0