예제 #1
0
    def __init__(self, width, height):
        super().__init__(width, height)
        self.hit_sound = arcade.load_sound("sounds/rockHit2.ogg")
        self.object_list = arcade.SpriteList()
        self.time = 0
        arcade.set_background_color(arcade.color.DARK_SLATE_GRAY)

        self.player = arcade.PhysicsAABB("images/character.png", [390, 400], [79 / 2, 125 / 2], [0, 0], .7, 3, 0.4)
        self.object_list.append(self.player)

        create_circles(self.object_list, 300, 300, 5, 2)

        a = arcade.PhysicsCircle("images/meteorGrey_med1.png", [400, 150], 20, [0, 0], .8, 2, 0.1)
        self.object_list.append(a)
        a = arcade.PhysicsCircle("images/meteorGrey_med2.png", [370, 120], 20, [0, 0], .8, 2, 0.1)
        self.object_list.append(a)
        a = arcade.PhysicsCircle("images/meteorGrey_med1.png", [430, 120], 20, [0, 0], .8, 2, 0.1)
        self.object_list.append(a)
        a = arcade.PhysicsCircle("images/meteorGrey_med1.png", [400, 90], 20, [0, 0], .8, 2, 0.1)
        self.object_list.append(a)

        create_boxes(self.object_list, 150, 250, 2, 20)
        create_boxes(self.object_list, 450, 250, 2, 20)
        create_boxes(self.object_list, 190, 250, 13, 2)
        create_boxes(self.object_list, 190, 450, 13, 2)
        create_boxes(self.object_list, 190, 610, 13, 2)
예제 #2
0
    def __init__(self):

        # Call the parent class and set up the window
        super().__init__(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE)

        self.left_pressed = False
        self.right_pressed = False
        self.up_pressed = False
        self.down_pressed = False
        self.jump_needs_reset = False

        # These are lists that are going to keep track of our sprites. Each sprite should go into a list
        self.coin_list = None
        self.wall_list = None
        self.background_list = None
        self.dont_touch_list = None
        self.ladder_list = None
        self.player_list = None
        self.foreground_list = None

        # Seperate variable that will hold the player sprite
        self.player_sprite = None

        # Our physics engine
        self.physics_engine = None

        # Used to keep track of our scrolling (0,0) is bottom left of our world
        self.view_bottom = 0
        self.view_left = 0

        # Where is the right end of the map?
        self.end_of_map = 0

        # Keep track of score
        self.score = 0

        # Level
        self.level = 1

        # Load Sounds
        self.collect_coin_sound = arcade.load_sound("sounds/coin3.wav")
        self.jump_sound = arcade.load_sound("sounds/jump1.wav")
        self.game_over = arcade.load_sound("sounds/gameover2.wav")

        arcade.set_background_color(arcade.csscolor.DEEP_SKY_BLUE) # Set background colour
예제 #3
0
    def __init__(self) -> None:
        super().__init__()

        # These lists will hold different sets of sprites
        self.coins = None
        self.background = None
        self.walls = None
        self.ladders = None
        self.goals = None
        self.enemies = None

        # One sprite for the player, no more is needed
        self.player = None

        # We need a physics engine as well
        self.physics_engine = None

        # Someplace to keep score
        self.score = 0

        # Which level are we on?
        self.level = 1

        # Load up our sounds here
        self.coin_sound = arcade.load_sound(
            str(ASSETS_PATH / "sounds" / "coin.wav")
        )
        self.jump_sound = arcade.load_sound(
            str(ASSETS_PATH / "sounds" / "jump.wav")
        )
        self.victory_sound = arcade.load_sound(
            str(ASSETS_PATH / "sounds" / "victory.wav")
        )

        # Check if a joystick is connected
        joysticks = arcade.get_joysticks()

        if joysticks:
            # If so, get the first one
            self.joystick = joysticks[0]
            self.joystick.open()
        else:
            # If not, flag it so we won't use it
            print("There are no Joysticks")
            self.joystick = None
예제 #4
0
 def __init__(self,x,y,dx,dy,w,c):
     super().__init__(x,y,dx,dy,w,c)
     self.x=x
     self.y=y
     self.dx=dx
     self.dy=dy
     self.w=w
     self.c=c
     self.explosion_sound = arcade.load_sound("explosion.mp3")
예제 #5
0
파일: Pong.py 프로젝트: LMGerard/Pong
class Pong(ac.Window):
    musics = {
        "select": ac.load_sound("assets/menu/button_select.mp3"),
        "music": ac.load_sound("assets/game/thefatrat-windfall.mp3"),
        "ping_pong": ac.load_sound("assets/game/ping_pong.mp3")
    }

    def __init__(self):
        super(Pong, self).__init__(BASE_WINDOW_WIDTH, BASE_WINDOW_HEIGHT, WINDOW_TITLE)
        self.set_fullscreen()

        self.show_menu()

    def start_game(self):
        self.show_view(Game.Game(self))

    def show_menu(self):
        self.show_view(Menu.Menu(self))
    def __init__(self, ship):
        self.ship = ship
        super().__init__()
        self.radius = SHIELD_RADIUS
        self.scale = SHIELD_SCALE
        self.shield_type = 3

        # Sounds
        self.shield_down_sound = arcade.load_sound("sfx_shieldDown.ogg")
예제 #7
0
    def __init__(self, width, height):
        """
        Initializer
        """
        super().__init__(width, height)

        # Set the working directory (where we expect to find files) to the same
        # directory this .py file is in. You can leave this out of your own
        # code, but it is needed to easily run the examples using "python -m"
        # as mentioned at the top of this program.
        file_path = os.path.dirname(os.path.abspath(__file__))
        os.chdir(file_path / Path("../../arcade/examples"))

        arcade.set_background_color(arcade.color.WHITE)
        self.laser_wav = arcade.load_sound("sounds/laser1.wav")
        self.laser_mp3 = arcade.load_sound("sounds/laser1.mp3")
        self.laser_ogg = arcade.load_sound("sounds/laser1.ogg")
        self.frame_count = 0
예제 #8
0
 def update(self):
     for coin in self.coin:
         coin.center_y -= 1
         if coin.center_y < 0:
             coin.kill()
         if self.world.player.is_hit_coin(coin):
             arcade.play_sound(arcade.load_sound("sound/coins.wav"))
             coin.kill()
             self.world.coin += randint(10, 60)
예제 #9
0
    def setup(self, level_number: int):
        self.current_level = level_number

        # Used to keep track of our scrolling
        self.view_bottom = 0
        self.view_left = 0

        self.level_speed = level_data_handler.get_level_speed(
            str(level_number))

        yield "Loading map"
        my_map = arcade.tilemap.read_tmx(
            f"assets/maps/level_{level_number}.tmx")
        self.obstacle_list = arcade.tilemap.process_layer(my_map, "obstacles")
        for obstacle in self.obstacle_list:
            obstacle.change_x = self.level_speed

        self.trap_list = arcade.tilemap.process_layer(my_map, "traps")
        for trap in self.trap_list:
            trap.change_x = self.level_speed

        self.jump_pad_list = arcade.tilemap.process_layer(my_map, "jump_pads")
        for jump_pad in self.jump_pad_list:
            jump_pad.change_x = self.level_speed

        floor = arcade.Sprite("assets/images/floor.png", 2)
        floor.position = (SCREEN_WIDTH // 2, 0)

        # Move the loaded map sprites x to the right so they "come" to us.
        # Move the loaded map sprites y up so they start at floor height.
        floor_y_offset = floor.center_y + floor.height // 2
        self.obstacle_list.move(SCREEN_WIDTH, floor_y_offset)
        self.trap_list.move(SCREEN_WIDTH, floor_y_offset)
        self.jump_pad_list.move(SCREEN_WIDTH, floor_y_offset)

        # After we're done with loading map add the floor (only after since we change the loaded sprite positions)
        self.obstacle_list.append(floor)

        yield "Loading backgrounds.."
        background_parallax_list = level_data_handler.get_background_parallax_list(
            level_number)
        self.background_list = ParallaxBackground(background_parallax_list)

        yield "Loading music"
        self.music = arcade.load_sound("assets/sounds/Guitar-Mayhem-5.mp3")
        arcade.play_sound(self.music)

        yield "Finishing up"
        self.player = Player()
        self.player.center_x = PLAYER_START_X
        self.player.center_y = PLAYER_START_Y

        self.player_dash_trail = PlayerDashTrail(
            self.get_player_dash_trail_position())

        self.physics_engine = arcade.PhysicsEnginePlatformer(
            self.player, self.obstacle_list, GRAVITY)
def on_key_press(key, modifiers):
    """"computes if a key is pressed and if it is, the action assigned to the key is executed

    Arguments:
        key {str} -- the key on a computer keyboard that is pressed 
        modifiers {str} -- a key that changes execution if pressed in combination with other keys

    Returns:
        the action that is assigned to the key is executed 
    """
    global left_pressed_human, left_pressed_alien, right_pressed_human, right_pressed_alien, fire_laser_human 
    global fire_laser_alien, spaceship_human_x, spaceship_human_y, spaceship_alien_x, spaceship_alien_y 
    global run_game, time, delta_time, start_game, run_game, end_game

    laser_sound = arcade.load_sound("laser.wav")

    # when LEFT/RIGHT is pressed for the right side player, and A/D for the left side player, the spaceship moves left and right
    if key == arcade.key.LEFT:
        left_pressed_human = True

    if key == arcade.key.A:
        left_pressed_alien = True

    if key == arcade.key.RIGHT:
        right_pressed_human = True

    if key == arcade.key.D:
        right_pressed_alien = True

    # when UP is pressed for the right side player, and W for the left side player, a laser is shot with a sound
    if key == arcade.key.W:
        fire_laser_alien = True
        alien_x_positions_laser.append(spaceship_alien_x)
        alien_y_positions_laser.append(spaceship_alien_y)
        arcade.sound.play_sound(laser_sound)

    if key == arcade.key.UP:
        fire_laser_human = True
        human_x_positions_laser.append(spaceship_human_x)
        human_y_positions_laser.append(spaceship_human_y)
        arcade.sound.play_sound(laser_sound)

    # the space bar starts the game after the main screen
    if key == arcade.key.SPACE:
        run_game = True

    # the escape key stops the execution of all other game stages, pausing the game
    if key == arcade.key.ESCAPE:
        run_game = False
        start_game = False
        final_stage_game = False
        end_game = False

    # the enter key restarts the game
    if key == arcade.key.ENTER:
        end_game = False
        run_game = True
예제 #11
0
def main():
    arcade.open_window(600, 600, "A  N E W  H O P E")
    arcade.set_background_color(arcade.color.LIGHT_PINK)

    arcade.schedule(on_draw, 1 / 60)
    sound = arcade.load_sound(
        'Star Wars IV A new hope - Binary Sunset (Force Theme).mp3')
    arcade.play_sound(sound)
    arcade.run()
예제 #12
0
    def __init__(self, cast):
        """
        Class constructor.
        Calls the constructor of the parent class.

        Args:
            self (Melee): an instance of Melee
            cast (dict): dictionary that holds all the actors

        """
        super().__init__(constants.CROSS_HAIR, 0.25)
        self.offset = 0
        self.cast = cast
        self.timer = time.time()

        self.slash_sound = arcade.load_sound(constants.HERO_SLASH_SOUND)
        self.hit_resource_sound = arcade.load_sound(
            constants.HERO_RESOURCE_SOUND)
예제 #13
0
파일: level.py 프로젝트: kfields/badwing
    def __init__(self, name):
        super().__init__(name)
        badwing.app.scene = self
        self.physics_engine = None
        self.pc_stack = []
        self.tilewidth = 0
        self.tileheight = 0

        self.song = arcade.load_sound(asset('music/funkyrobot.ogg'))
예제 #14
0
    def __init__(self, views):
        """ This is run once when we switch to this view """
        super().__init__()
        self.texture = arcade.load_texture(
            "cse210-FinalProject/bedhead/assets/images/game_over.png")
        self.views = views

        # sound
        self.end_sound = arcade.load_sound(":resources:sounds/gameover2.wav")
예제 #15
0
 def __init__(self, host, port, name, curWin):
     self.Connect((host, port))
     #add stuff here
     arcade.View.__init__(self)
     arcade.set_background_color(arcade.csscolor.INDIGO)
     # Lists are used for movemetn and collisions
     self.current_player = multiplayerServer.Player(str(name))
     self.playerList = arcade.SpriteList()
     self.playerList.append(self.current_player)
     self.laserList = None
     self.asteroidList = None
     self.phyEngine = None
     self.fireSound = arcade.load_sound(":resources:sounds/hurt5.wav")
     self.hitSound = arcade.load_sound(":resources:sounds/hit3.wav")
     self.gameOver = False
     self.asteroidCount = 6
     self.threshold = 3
     self.window = curWin
예제 #16
0
파일: sticker.py 프로젝트: kfields/badwing
    def __init__(self, name):
        super().__init__(name)

        # Our physics engine
        self.physics_engine = physics_engine = KinematicPhysicsEngine()
        #self.physics_engine = physics_engine = DynamicPhysicsEngine()
        self.space = physics_engine.space

        # Used to keep track of our scrolling
        self.view_bottom = 0
        self.view_left = 0

        # Load sounds
        self.collect_butterfly_sound = arcade.load_sound(":resources:sounds/coin1.wav")
        self.collect_flag_sound = arcade.load_sound(":resources:sounds/upgrade5.wav")
        self.jump_sound = arcade.load_sound(":resources:sounds/jump1.wav")
        # Soundtrack
        self.song = arcade.load_sound(asset('music/funkyrobot.ogg'))
예제 #17
0
    def __init__(self, image: Star):
        """ Initializer """

        # Call the parent class initializer
        super().__init__(SCREEN_WIDTH, SCREEN_HEIGHT, "Lab 7 - User Control")
        self.background_color
        self.image = image

        self.click_sound = arcade.load_sound("click.mp3")
예제 #18
0
def setup_window(graphicsWindow):
    enemy_list = []
    landmine_list = []
    width, height = graphicsWindow.get_size()
    for enemy_count in range(10):
        enemies = arcade.Sprite("Enemy2.png")
        xPos = random.randint(0, width)
        if xPos < 100:
            xPos = 500
        elif xPos > 900:
            xPos = 500
        yPos = random.randint(0, height)
        if yPos < 500:
            yPos = 800
        elif yPos > 900:
            yPos = 500
        enemies.set_position(xPos, yPos)
        enemy_list.append(enemies)

    for landmine_count in range(10):
        landmines = arcade.Sprite("LandMine2.png")
        landmine_list.append(landmines)
        graphicsWindow.landmine_list = []

    player = arcade.Sprite("Hero2.png")
    player.set_position(200, 400)
    graphicsWindow.player = player
    graphicsWindow.playerDx = 0
    graphicsWindow.playerDy = 0
    graphicsWindow.enemyList = enemy_list
    graphicsWindow.up_pressed = False
    graphicsWindow.down_pressed = False
    graphicsWindow.left_pressed = False
    graphicsWindow.right_pressed = False
    graphicsWindow.score = 0

    graphicsWindow.Hero_Gun_sound = arcade.sound.load_sound("HeroGunshot.mp3")
    graphicsWindow.Enemy_Gun_sound = arcade.sound.load_sound(
        "EnemyGunshot.mp3")
    graphicsWindow.Hitmarker = arcade.sound.load_sound("Hitmarker.mp3")
    graphicsWindow.background_music = arcade.load_sound("Background Music.mp3")
    graphicsWindow.DeathSound = arcade.load_sound("DeathNoise.mp3")
    graphicsWindow.Explosion = arcade.load_sound("Explosion.mp3")
    arcade.play_sound(graphicsWindow.background_music)
예제 #19
0
    def __init__(self,
                 base_sprite: str,
                 sprite_scale: float,
                 parent: Entity,
                 relative_x: Union[float, int] = 0.0,
                 relative_y: Union[float, int] = 0.0,
                 angle: float = 0.0,
                 speed: Union[float, int] = 1,
                 bullet_type: Type[Bullet] = None,
                 firing_mode: ShotType = ShotType.SINGLE,
                 firing_rate: Union[float, int] = 0.25) -> None:
        """

        Parameters
        ----------
        base_sprite     :   str
            The path to the file containing the sprite for this entity.
        sprite_scale    :   float
            The scale to draw the sprite for this entity
        parent          :   Entity
            The entity that created/fired this bullet.
        relative_x      :   Union[float, int]
            The x position, relative to the parent to spawn the bullet at.
        relative_y      :   Union[float, int]
            The y position, relative to the parent to spawn the bullet at.
        angle           :   float
            The starting angle that the bullet should be facing when shot.
        speed           :   Union[float, int]
            The speed that the bullet will travel at.
        bullet_type     :   Type[Bullet]
            The bullet that this turret shoots.
        firing_mode     :   ShotType
            The type of shot to fire the bullet in. Defaults to ShotType.SINGLE. ShotType.BUCKSHOT is another option.
        firing_rate     :   Union[float, int]
            The firing rate of the turret in seconds.

        """

        super().__init__(base_sprite,
                         sprite_scale,
                         parent=parent,
                         relative_x=relative_x,
                         relative_y=relative_y,
                         maintain_relative_position=True,
                         speed=speed,
                         angle=angle,
                         maintain_parent_angle=False)
        ShootingMixin.__init__(self)

        self.bullet_type = bullet_type
        self.inventory = self.parent.inventory if hasattr(
            self.parent, 'inventory') else None
        self.firing_mode = firing_mode
        self.firing_rate = firing_rate

        self._attack_sound = arcade.load_sound("resources/sound/cannon.ogg")
예제 #20
0
    def __init__(self):
        super().__init__()
        self.background = None
        self.music = arcade.load_sound(f"{DATA_PATH}/music.wav")
        self.music.play(volume=0.2)

        self.half_width = SCREEN_WIDTH / 2
        self.half_height = SCREEN_HEIGHT / 2

        self.theme = None
예제 #21
0
    def __init__(self):
        # Call the parent class initializer
        super().__init__(SCREEN_WIDTH, SCREEN_HEIGHT)

        self.player_list = None
        self.pie_list = None
        self.bat_list = None

        # Loads sounds for pie and bat collisions
        # Both sounds found at kenney.nl
        self.good_sound = arcade.load_sound("confirmation_004.ogg")
        self.bad_sound = arcade.load_sound("error_004.ogg")

        self.player_sprite = None
        self.score = 0

        self.set_mouse_visible(False)

        arcade.set_background_color(arcade.color.GRANNY_SMITH_APPLE)
예제 #22
0
    def setup(self):
        self.backdrop = arcade.SpriteList()
        self.toasty = arcade.SpriteList()
        self.aliens = arcade.SpriteList()
        self.projectiles = arcade.SpriteList()
        self.powerups = arcade.SpriteList()
        self.coffee = arcade.SpriteList()
        self.storyslate = arcade.SpriteList()
        self.credits = arcade.SpriteList()
        self.spinningAlien = arcade.SpriteList()

        self.backdrop.append(Backdrop(WIDTH, HEIGHT))
        self.toasty.append(Toasty(WIDTH / 2, 70))
        self.storyslate.append(StorySlate(WIDTH, HEIGHT))
        self.storyslate.append(SpinningPug(WIDTH, HEIGHT - 50))
        self.credits.append(Credits(WIDTH, HEIGHT))
        self.spinningAlien.append(SpinningAlien(WIDTH, HEIGHT - 100))
        self.music = arcade.load_sound(MUSIC)
        self.mainmenumusic = arcade.load_sound(MAIN)
예제 #23
0
    def __init__(self):

        # Call the parent class and set up the window
        super().__init__()

        # These are 'lists' that keep track of our sprites. Each sprite should
        # go into a list.
        self.gold_coin_list = None
        self.bronze_coin_list = None
        self.wall_list = None
        self.player_list = None
        self.enemy_list = None
        self.level_jewel_list = None
        self.background_list = None
        self.ladders_list = None
        self.do_not_touch_list = None
        self.exit_sign_list = None
        self.enemy_list = None

        # Separate variable that holds the player sprite
        self.player = None

        # Our physics engine
        self.physics_engine = None

        # Used to keep track of our scrolling
        self.view_bottom = 0
        self.view_left = 0

        # Keep track of the score
        self.score = 0
        self.lives = 3

        # Load sounds
        self.collect_coin_sound = arcade.load_sound("sounds/coin1.wav")
        self.jump_sound = arcade.load_sound("sounds/jump1.wav")
        self.game_over = arcade.load_sound("sounds/gameover1.wav")

        # Level
        self.level = 1

        self.setup(self.level)
        arcade.set_background_color(arcade.csscolor.CORNFLOWER_BLUE)
예제 #24
0
    def on_key_press(self, key, modifiers):
        """Called whenever a key is pressed. """

        if key == arcade.key.ENTER or key == arcade.key.SPACE:
            self.entersound = arcade.load_sound("sounds/confirmMenu.ogg")
            arcade.play_sound(self.entersound)
            time.sleep(3)
            window = MyGame()
            window.setup(1)
            arcade.run()
예제 #25
0
    def __init__(self):
        """ Initializer """
        super().__init__(SCREEN_WIDTH, SCREEN_HEIGHT, "Sprite Example")

        self.player_list = None
        self.snowball_list = None
        self.fire_list = None  #NEW

        self.player_sprite = None
        self.score = 0

        #Good sound form OpenGameArt
        self.good_sound = arcade.load_sound("good_sound.wav")
        #Bad sound from OpenGameArt
        self.bad_sound = arcade.load_sound("bad_sound.mp3")

        self.set_mouse_visible(False)

        arcade.set_background_color(arcade.color.AERO_BLUE)
예제 #26
0
    def __init__(self):
        """ Initializer """

        # Call the parent class initializer
        super().__init__(SCREEN_WIDTH, SCREEN_HEIGHT, "Lab 7 - User Control")
        self.set_mouse_visible(False)
        arcade.set_background_color(arcade.color.BLACK)
        self.ball = Ball(50, 50, 0, 0, radius=10)
        self.ball2 = Ball2(50, 50, 15, 0)
        self.click_sound = arcade.load_sound("cardFan1.wav")
예제 #27
0
파일: main.py 프로젝트: anetryg/arcade_game
    def __init__(self):
        super().__init__()
        self.player = None
        self.player_list = None
        self.physics_engine = None
        self.ground_list = None
        self.count_score = 0
        self.time = TIMER
        self.view_bottom = 0
        self.view_left = 0
        self.level = 1
        self.theme = None

        #zvuky
        self.coin_sound = arcade.load_sound("sounds\\coin_sound.wav")
        self.win_sound = arcade.load_sound("sounds\\win_sound.wav")
        self.lose_sound = arcade.load_sound("sounds\\lose_sound.wav")

        self.start_game()
예제 #28
0
    def __init__(self):
        """ Initializer """
        super().__init__(SCREEN_WIDTH, SCREEN_HEIGHT, "Bunny Game")

        # Load sound effects
        self.carrot_sound = arcade.load_sound("coin3.wav")
        self.enemy1_sound = arcade.load_sound("hurt4.wav")
        self.enemy2_sound = arcade.load_sound("laser1.wav")

        # Variables that will hold sprite lists
        self.player_list = None
        self.carrot_list = None
        self.enemy_list = None

        # Set up the player info
        self.player_sprite = None
        self.score = 0

        arcade.set_background_color(arcade.color.GRAY_ASPARAGUS)
예제 #29
0
    def __init__(self):
        """ Declares variables for the GameView class
        Args:
            self (Gameview): an instance of Gameview
        Contributors:
            Reed Hunsaker
            Adrianna Lund
            Isabel Aranguren
            Jordan McIntyre
            Juliano Nascimiento
        """
        super().__init__()

        self._score = Score()
        self.texture = arcade.load_texture(constants.BACKGROUND)
        self.game_ending = False
        self.name = ""

        # physics engines
        self.physics_engine = None
        self.physics_engine2 = None
        self.physics_engine3 = None
        self.physics_engine4 = None

        # sprite lists
        self.bullet_list = None
        self.explosions_list = None
        self.explosion_texture_list = []

        # sounds
        self.powerup_sound = arcade.load_sound(constants.POWERUPS_SOUND)
        self.powerdown_sound = arcade.load_sound(constants.POWERDOWN_SOUND)
        self.tank_explode = arcade.load_sound(constants.EXPLOSION_SOUND)

        # explosion details
        self.columns = 16
        self.count = 8
        self.sprite_width = 256
        self.sprite_height = 256
        self.file_name = ":resources:images/spritesheets/explosion.png"
        self.explosion_texture_list = arcade.load_spritesheet(
            self.file_name, self.sprite_width, self.sprite_height,
            self.columns, self.count)
    def __init__(self):
        # Creates the window frame and sets the backgroudn color
        # Can change this to show a backround image instead
        super().__init__()
        arcade.set_background_color(arcade.csscolor.INDIGO)

        # Lists are used for movemetn and collisions
        self.shipList = None
        self.shipSprite = None
        self.laserList = None
        self.astroidList = None
        self.phyEngine = None
        self.fireSound = arcade.load_sound(":resources:sounds/hurt5.wav")
        self.hitSound = arcade.load_sound(":resources:sounds/hit3.wav")
        self.lives = 3
        self.score = 0
        self.gameOver = False
        self.asteroidCount = 6
        self.threshold = 3
예제 #31
0
    def setup(self):
        super().setup()

        self._song = arcade.load_sound(songspath / "ch" / "run_around_the_character_code" / "song.mp3")
        self.song = HeroSong.parse(songspath / "ch" / "run_around_the_character_code")
        self.chart = self.song.get_chart("Expert", "Single")
        self.highway = HeroHighway(self.chart, (0, 0), show_flags=True)

        # Generate "gum wrapper" background
        self.logo_width, self.small_logos_forward, self.small_logos_backward = generate_gum_wrapper(self.size)
예제 #32
0
    def setup(self):
        """ Set up the game and initialize the variables. """

        self.frame_count = 0
        self.game_over = False

        # Sprite lists
        self.all_sprites_list = arcade.SpriteList()
        self.asteroid_list = arcade.SpriteList()
        self.bullet_list = arcade.SpriteList()
        self.ship_life_list = arcade.SpriteList()

        # Set up the player
        self.score = 0
        self.player_sprite = ShipSprite("images/playerShip1_orange.png", SCALE)
        self.all_sprites_list.append(self.player_sprite)
        self.lives = 3

        # Set up the little icons that represent the player lives.
        cur_pos = 10
        for i in range(self.lives):
            life = arcade.Sprite("images/playerLife1_orange.png", SCALE)
            life.center_x = cur_pos + life.width
            life.center_y = life.height
            cur_pos += life.width
            self.all_sprites_list.append(life)
            self.ship_life_list.append(life)

        # Make the asteroids
        image_list = ("images/meteorGrey_big1.png",
                      "images/meteorGrey_big2.png",
                      "images/meteorGrey_big3.png",
                      "images/meteorGrey_big4.png")
        for i in range(3):
            image_no = random.randrange(4)
            enemy_sprite = AsteroidSprite(image_list[image_no], SCALE)

            enemy_sprite.center_y = random.randrange(window.width)
            enemy_sprite.center_x = random.randrange(window.height)

            enemy_sprite.change_x = random.random() * 2 - 1
            enemy_sprite.change_y = random.random() * 2 - 1

            enemy_sprite.change_angle = (random.random() - 0.5) * 2
            enemy_sprite.size = 4
            self.all_sprites_list.append(enemy_sprite)
            self.asteroid_list.append(enemy_sprite)

        # Sounds
        self.laser_sound = arcade.load_sound("sounds/laser1.ogg")
예제 #33
0
    def __init__(self):
        super().__init__(SCREEN_WIDTH, SCREEN_HEIGHT)

        self.frame_count = 0

        self.game_over = False

        # Sprite lists
        self.all_sprites_list = None
        self.asteroid_list = None
        self.bullet_list = None
        self.ship_life_list = None

        # Set up the player
        self.score = 0
        self.player_sprite = None
        self.lives = 3

        # Sounds
        self.laser_sound = arcade.load_sound("sounds/laser1.ogg")
예제 #34
0
 def setup(self):
     self.hit_sound = arcade.load_sound("sounds/rockHit2.ogg")
     self.object_list = []
     setup_b(self.object_list)