Beispiel #1
0
def test_main(twm):
    if twm:
        assert True
    else:
        character_list = arcade.SpriteList()
        wall_list = arcade.SpriteList()
        moving_sprite = arcade.SpriteSolidColor(10, 10, arcade.color.RED)
        character_list.append(moving_sprite)

        wall_sprite = arcade.SpriteSolidColor(10, 10, arcade.color.BLUE)
        wall_list.append(wall_sprite)

        wall_sprite = arcade.SpriteSolidColor(10, 10, arcade.color.BLUE)
        wall_sprite.position = OUT_OF_THE_WAY
        wall_list.append(wall_sprite)

        physics_engine = arcade.PhysicsEngineSimple(moving_sprite, wall_list)
        basic_tests(moving_sprite, wall_list, physics_engine)
        simple_engine_tests(moving_sprite, wall_list, physics_engine)

        physics_engine = arcade.PhysicsEnginePlatformer(moving_sprite,
                                                        wall_list,
                                                        gravity_constant=0.0)
        basic_tests(moving_sprite, wall_list, physics_engine)
        platformer_tests(moving_sprite, wall_list, physics_engine)
Beispiel #2
0
    def setup(self):
        """ Set up the game and initialize the variables. """

        # Sprite lists
        self.player_list = arcade.SpriteList()
        self.star_sprite_list = arcade.SpriteList()
        self.enemy_sprite_list = arcade.SpriteList()
        self.bullet_sprite_list = arcade.SpriteList()

        # Set up the player
        self.player_sprite = Player()
        self.player_sprite.center_x = 50
        self.player_sprite.center_y = 50
        self.player_list.append(self.player_sprite)

        # Add stars
        for i in range(80):
            sprite = arcade.SpriteSolidColor(4, 4, arcade.color.WHITE)
            sprite.center_x = random.randrange(PLAYING_FIELD_WIDTH)
            sprite.center_y = random.randrange(PLAYING_FIELD_HEIGHT)
            self.star_sprite_list.append(sprite)

        # Add enemies
        for i in range(20):
            sprite = arcade.SpriteSolidColor(20, 20,
                                             arcade.csscolor.LIGHT_SALMON)
            sprite.center_x = random.randrange(PLAYING_FIELD_WIDTH)
            sprite.center_y = random.randrange(PLAYING_FIELD_HEIGHT)
            self.enemy_sprite_list.append(sprite)
Beispiel #3
0
    def __init__(self, width, height, title):
        super().__init__(width, height, title)

        arcade.set_background_color(arcade.color.BLACK)

        self.frame_counter = 0

        self.character_list = arcade.SpriteList()

        for i in range(7):
            my_width = SIZE
            my_height = SIZE + i * 3
            my_color = (i * 40, 0, 255)
            center_x = SPACING + (i * SPACING)
            center_y = ROW_SPACING
            self.character_sprite = arcade.SpriteSolidColor(
                my_width, my_height, my_color)
            self.character_sprite.center_x = center_x
            self.character_sprite.center_y = center_y
            self.character_list.append(self.character_sprite)

        for i in range(7):
            my_width = SIZE + i * 3
            my_height = SIZE
            my_color = (0, i * 40, 255)
            center_x = SPACING + (i * SPACING)
            center_y = ROW_SPACING * 2
            self.character_sprite = arcade.SpriteSolidColor(
                my_width, my_height, my_color)
            self.character_sprite.center_x = center_x
            self.character_sprite.center_y = center_y
            self.character_list.append(self.character_sprite)
Beispiel #4
0
def test():

    height = 2
    width = 2
    wall = arcade.SpriteSolidColor(width, height, arcade.color.RED)
    wall.position = 0, 0

    assert wall.height == height
    assert wall.width == width
    assert wall.top == height / 2
    assert wall.bottom == -height / 2
    assert wall.left == -width / 2
    assert wall.right == width / 2
    hit_box = wall.get_hit_box()
    assert hit_box[0] == (-width / 2, -height / 2)
    assert hit_box[1] == (width / 2, -height / 2)
    assert hit_box[2] == (width / 2, height / 2)
    assert hit_box[3] == (-width / 2, height / 2)

    height = 128
    width = 128
    wall = arcade.SpriteSolidColor(width, height, arcade.color.RED)
    wall.position = 0, 0

    assert wall.height == height
    assert wall.width == width
    assert wall.top == height / 2
    assert wall.bottom == -height / 2
    assert wall.left == -width / 2
    assert wall.right == width / 2
    hit_box = wall.get_hit_box()
    assert hit_box[0] == (-width / 2, -height / 2)
    assert hit_box[1] == (width / 2, -height / 2)
    assert hit_box[2] == (width / 2, height / 2)
    assert hit_box[3] == (-width / 2, height / 2)

    height = 128
    width = 128
    wall = arcade.Sprite(":resources:images/tiles/dirtCenter.png")
    wall.position = 0, 0

    assert wall.height == height
    assert wall.width == width
    assert wall.top == height / 2
    assert wall.bottom == -height / 2
    assert wall.left == -width / 2
    assert wall.right == width / 2
    hit_box = wall.get_hit_box()
    assert hit_box[0] == (-width / 2, -height / 2)
    assert hit_box[1] == (width / 2, -height / 2)
    assert hit_box[2] == (width / 2, height / 2)
    assert hit_box[3] == (-width / 2, height / 2)

    wall = arcade.Sprite(":resources:images/items/coinGold.png",
                         hit_box_algorithm="Detailed")
    wall.position = 0, 0

    hit_box = wall.get_hit_box()
    assert hit_box == [(-32, 7), (-17, 28), (7, 32), (29, 15), (32, -7),
                       (17, -28), (-8, -32), (-28, -17)]
Beispiel #5
0
    def setup(self):
        """ Set up the game and initialize the variables. """

        # Sprite lists
        self.player_list = arcade.SpriteList()
        self.coin_list = arcade.SpriteList()

        # Score
        self.score = 0

        # Set up the player
        # Character image from kenney.nl
        self.player_sprite = arcade.SpriteSolidColor(64, 64, arcade.color.RED)
        self.player_sprite.center_x = 50
        self.player_sprite.center_y = 50
        self.player_list.append(self.player_sprite)

        # Create the coins
        for i in range(COIN_COUNT):

            # Create the coin instance
            # Coin image from kenney.nl
            coin = arcade.SpriteSolidColor(32, 32, arcade.color.BLUE)

            # Position the coin
            coin.center_x = random.randrange(SCREEN_WIDTH)
            coin.center_y = random.randrange(SCREEN_HEIGHT)

            # Add the coin to the lists
            self.coin_list.append(coin)
Beispiel #6
0
    def setup(self):
        """ Set up the game here. Call this function to restart the game. """

        # List of cards we are dragging with the mouse
        self.held_cards = []

        # Original location of cards we are dragging with the mouse in case
        # they have to go back.
        self.held_cards_original_position = []

        # ---  Create the mats the cards go on.

        # Sprite list with all the mats tha cards lay on.
        self.pile_mat_list: arcade.SpriteList = arcade.SpriteList()

        # Create the mats for the bottom face down and face up piles
        pile = arcade.SpriteSolidColor(MAT_WIDTH, MAT_HEIGHT, arcade.csscolor.DARK_OLIVE_GREEN)
        pile.position = START_X, BOTTOM_Y
        self.pile_mat_list.append(pile)

        pile = arcade.SpriteSolidColor(MAT_WIDTH, MAT_HEIGHT, arcade.csscolor.DARK_OLIVE_GREEN)
        pile.position = START_X + X_SPACING, BOTTOM_Y
        self.pile_mat_list.append(pile)

        # Create the seven middle piles
        for i in range(7):
            pile = arcade.SpriteSolidColor(MAT_WIDTH, MAT_HEIGHT, arcade.csscolor.DARK_OLIVE_GREEN)
            pile.position = START_X + i * X_SPACING, MIDDLE_Y
            self.pile_mat_list.append(pile)

        # Create the top "play" piles
        for i in range(4):
            pile = arcade.SpriteSolidColor(MAT_WIDTH, MAT_HEIGHT, arcade.csscolor.DARK_OLIVE_GREEN)
            pile.position = START_X + i * X_SPACING, TOP_Y
            self.pile_mat_list.append(pile)

        # --- Create, shuffle, and deal the cards

        # Sprite list with all the cards, no matter what pile they are in.
        self.card_list = arcade.SpriteList()

        # Create every card
        for card_suit in CARD_SUITS:
            for card_value in CARD_VALUES:
                card = Card(card_suit, card_value, CARD_SCALE)
                card.position = START_X, BOTTOM_Y
                self.card_list.append(card)

        # Shuffle the cards
        for pos1 in range(len(self.card_list)):
            pos2 = random.randrange(len(self.card_list))
            self.card_list[pos1], self.card_list[pos2] = self.card_list[pos2], self.card_list[pos1]

        # Create a list of lists, each holds a pile of cards.
        self.piles = [[] for _ in range(PILE_COUNT)]

        # Put all the cards in the bottom face-down pile
        for card in self.card_list:
            self.piles[BOTTOM_FACE_DOWN_PILE].append(card)
    def load_media(self):
        ###############################################################
        # Separating the loading of images and logic for this class
        ###############################################################
        # DIALOGUE BOX SPRITE LIST
        self.dialogue_sprite_list = arcade.SpriteList()

        # Border Panel
        self.dialogue_border_background = arcade.SpriteSolidColor(
            1020, 180, arcade.color.BLACK)
        self.dialogue_sprite_list.append(self.dialogue_border_background)
        # Text Panel
        self.text_panel = arcade.SpriteSolidColor(1000, 160,
                                                  arcade.color.WHITE_SMOKE)
        self.dialogue_sprite_list.append(self.text_panel)
        # Profile Image Border
        self.profile_border_red = arcade.SpriteSolidColor(
            150, 150, arcade.color.GOLD)
        self.dialogue_sprite_list.append(self.profile_border_red)

        ##############################
        # PROFILE IMAGES FOR DIALOGUE BOX (Will be deleted on first run and replaced by current speaker)
        self.profile = arcade.SpriteSolidColor(75, 75, arcade.color.DESIRE)
        self.dialogue_sprite_list.append(self.profile)

        ###############################################################
        # PLAYER INFO BOX SPRITE LIST
        self.player_info_sprite_list = arcade.SpriteList()

        # Border Panel
        self.player_info_border_background = arcade.SpriteSolidColor(
            252, 102, arcade.color.WHITE_SMOKE)
        self.player_info_sprite_list.append(self.player_info_border_background)
        # Player Info Border
        self.player_info_player_border = arcade.SpriteSolidColor(
            250, 100, arcade.color.BLACK)
        self.player_info_sprite_list.append(self.player_info_player_border)
        # Player Image Box - NOTE: current image is too small so we put it on top of this
        self.player_info_player_image = arcade.SpriteSolidColor(
            75, 75, arcade.color.HAN_BLUE)
        self.player_info_sprite_list.append(self.player_info_player_image)

        ###################################
        # User Image for player info box (placeholder)
        self.profile_rachel = arcade.Sprite(
            "Images/UI/Profile_Rachel.png",
            scale=2)  # Need larger image for less bluriness
        self.player_info_sprite_list.append(self.profile_rachel)

        ###############################################################
        # MENU BAR SPRITE LIST
        self.menu_bar_sprite_list = arcade.SpriteList()
        # Menu Bar Background
        self.menu_bar_background = arcade.SpriteSolidColor(
            85, 27, arcade.color.BLACK)
        self.menu_bar_sprite_list.append(self.menu_bar_background)
        # Inventory
        self.menu_bar_inventory_button = arcade.SpriteSolidColor(
            82, 23, arcade.color.BEAU_BLUE)
        self.menu_bar_sprite_list.append(self.menu_bar_inventory_button)
Beispiel #8
0
    def setup(self):
        #list of cards we are dragging with the mouse
        self.held_cards = []
        #original location of cards we are dragging the mouse in case they have to go back
        self.held_cards_original_position = []

        #create the mats the cards go on
        #sprite list with all the mats that the cards lay on
        self.pile_mat_list: arcade.SpriteList = arcade.SpriteList()

        #create the mats for the bottom face down and face up piles
        pile = arcade.SpriteSolidColor(MAT_WIDTH, MAT_HEIGHT,
                                       arcade.csscolor.ALICE_BLUE)
        pile.position = START_X, BOTTOM_Y
        self.pile_mat_list.append(pile)

        pile = arcade.SpriteSolidColor(MAT_WIDTH, MAT_HEIGHT,
                                       arcade.csscolor.SIENNA)
        pile.position = START_X + X_SPACING, BOTTOM_Y
        self.pile_mat_list.append(pile)

        #Create the seven middle piles
        for i in range(0):
            pile = arcade.SpriteSolidColor(MAT_WIDTH, MAT_HEIGHT,
                                           arcade.csscolor.DARK_OLIVE_GREEN)
            pile.position = START_X + i * X_SPACING, MIDDLE_Y
            self.pile_mat_list.append(pile)

        #create the top "play" piles
        for i in range(5):
            pile = arcade.SpriteSolidColor(MAT_WIDTH, MAT_HEIGHT,
                                           arcade.csscolor.DARK_OLIVE_GREEN)
            pile.position = START_X + i * X_SPACING, TOP_Y
            self.pile_mat_list.append(pile)

        self.card_list = arcade.SpriteList()

        #create every card
        self.card_list = arcade.SpriteList()
        for card_suit in CARD_SUITS:
            for card_value in CARD_VALUES:
                card = Card(card_suit, card_value, CARD_SCALE)
                card.position = START_X, BOTTOM_Y
                self.card_list.append(card)
        for sylop in ZERO_SUIT:
            for card1 in ZERO_VALUE:
                card = Card(sylop, card1, CARD_SCALE)
                card.position = START_X, BOTTOM_Y
                self.card_list.append(card)

        for pos1 in range(len(self.card_list)):
            pos2 = random.randrange(len(self.card_list))
            self.card_list[pos1], self.card_list[pos2] = self.card_list[
                pos2], self.card_list[pos1]
Beispiel #9
0
    def setup(self):
        """ Set up the game here. Call this function to restart the game. """

        # List of cards we are dragging with the mouse
        self.held_cards = []

        # Original location of cards we are dragging with the mouse in case
        # they have to go back.
        self.held_cards_original_position = []

        # ---  Create the mats the cards go on.

        # Sprite list with all the mats tha cards lay on.
        self.pile_mat_list: arcade.SpriteList = arcade.SpriteList()

        # Create the mats for the bottom face down and face up piles
        pile = arcade.SpriteSolidColor(MAT_WIDTH, MAT_HEIGHT,
                                       arcade.csscolor.DARK_OLIVE_GREEN)
        pile.position = START_X, BOTTOM_Y
        self.pile_mat_list.append(pile)

        pile = arcade.SpriteSolidColor(MAT_WIDTH, MAT_HEIGHT,
                                       arcade.csscolor.DARK_OLIVE_GREEN)
        pile.position = START_X + X_SPACING, BOTTOM_Y
        self.pile_mat_list.append(pile)

        # Create the seven middle piles
        for i in range(7):
            pile = arcade.SpriteSolidColor(MAT_WIDTH, MAT_HEIGHT,
                                           arcade.csscolor.DARK_OLIVE_GREEN)
            pile.position = START_X + i * X_SPACING, MIDDLE_Y
            self.pile_mat_list.append(pile)

        # Create the top "play" piles
        for i in range(4):
            pile = arcade.SpriteSolidColor(MAT_WIDTH, MAT_HEIGHT,
                                           arcade.csscolor.DARK_OLIVE_GREEN)
            pile.position = START_X + i * X_SPACING, TOP_Y
            self.pile_mat_list.append(pile)

        # Sprite list with all the cards, no matter what pile they are in.
        self.card_list = arcade.SpriteList()

        # Create every card
        for card_suit in CARD_SUITS:
            for card_value in CARD_VALUES:
                card = Card(card_suit, card_value, CARD_SCALE)
                card.position = START_X, BOTTOM_Y
                self.card_list.append(card)
Beispiel #10
0
    def redraw_tiles(self):

        self.tile_list: arcade.SpriteList = arcade.SpriteList()

        for row in range(8):
            for column in range(8):
                if (column + row) % 2 == 0:
                    tile = arcade.SpriteSolidColor(SQUARE_HEIGHT, SQUARE_WIDTH,
                                                   (85, 85, 85))
                else:
                    tile = arcade.SpriteSolidColor(SQUARE_HEIGHT, SQUARE_WIDTH,
                                                   (245, 245, 245))
                tile.position = START_X + (SQUARE_WIDTH * column), START_Y + (
                    SQUARE_HEIGHT * row)
                self.tile_list.append(tile)
Beispiel #11
0
def test_sprites_at_point():

    coin_list = arcade.SpriteList()
    sprite = arcade.SpriteSolidColor(50, 50, arcade.csscolor.RED)
    coin_list.append(sprite)

    # print()
    # print(sprite.points)
    sprite_list = arcade.get_sprites_at_point((0, 0), coin_list)
    assert len(sprite_list) == 1

    sprite.position = (130, 130)
    # print()
    # print(sprite.points)

    sprite_list = arcade.get_sprites_at_point((0, 0), coin_list)
    assert len(sprite_list) == 0

    sprite_list = arcade.get_sprites_at_point((140, 130), coin_list)
    assert len(sprite_list) == 1

    sprite.angle = 90
    # print()
    # print(sprite.points)

    sprite_list = arcade.get_sprites_at_point((0, 0), coin_list)
    assert len(sprite_list) == 0

    sprite_list = arcade.get_sprites_at_point((140, 130), coin_list)
    assert len(sprite_list) == 1
Beispiel #12
0
 def _create_sprite(center_x: int,
                    center_y: int) -> arcade.SpriteSolidColor:
     sprite_color = arcade.SpriteSolidColor(COMPONENT_SIZE, COMPONENT_SIZE,
                                            arcade.color.GREEN)
     sprite_color.center_x = center_x
     sprite_color.center_y = center_y
     return sprite_color
Beispiel #13
0
    def __init__(self, width, height, title):

        super().__init__(width, height, title)

        self.grid = [
        ]  #[[[] for row in range(ROW_COUNT)] for col in range(COLUMN_HEIGHT)]

        for row in range(ROW_COUNT):

            self.grid.append([])
            for col in range(COLUMN_COUNT):
                self.grid[row].append(0)

        arcade.set_background_color(arcade.color.BLACK)

        self.grid_sprite_list = arcade.SpriteList()

        for row in range(COLUMN_COUNT):
            for col in range(ROW_COUNT):
                x = col * (WIDTH + MARGIN) + (WIDTH / 2 + MARGIN)
                y = row * (HEIGHT + MARGIN) + (HEIGHT / 2 + MARGIN)
                sprite = arcade.SpriteSolidColor(WIDTH, HEIGHT,
                                                 arcade.color.WHITE)
                sprite.center_x = x
                sprite.center_y = y
                self.grid_sprite_list.append(sprite)
Beispiel #14
0
 def create_square_sprite(self, i, k, color):
     x = self.tile_size // 2 + self.tile_size * k
     y = self.tile_size // 2 + self.tile_size * i
     new = ar.SpriteSolidColor(self.tile_size, self.tile_size, color)
     new.center_x = x
     new.center_y = y
     return new
Beispiel #15
0
    def shield(self, x_start):
        shield_block_width = 1
        shield_block_height = 1
        shield_width_count = 1
        shield_height_count = 1

        if self.Difficulty == 1:
            shield_block_width = 5
            shield_block_height = 10
            shield_width_count = 20
            shield_height_count = 5

        elif self.Difficulty == 2:
            shield_block_width = 5
            shield_block_height = 5
            shield_width_count = 10
            shield_height_count = 2

        
        y_start = 150
        
        for x in range(x_start, x_start + shield_width_count * shield_block_width, shield_block_width):
            for y in range(y_start, y_start + shield_height_count * shield_block_height, shield_block_height):
                shield_sprite = arcade.SpriteSolidColor(shield_block_width, shield_block_height, arcade.color.GREEN)
                shield_sprite.center_x  = x
                shield_sprite.center_y = y
                self.shield_list.append(shield_sprite)
def create_grids():
    """
    Create a 2D and 1D grid of sprites. We use the 1D SpriteList for drawing,
    and the 2D list for accessing via grid. Both lists point to the same set of
    sprites.
    """
    # One dimensional list of all sprites in the two-dimensional sprite list
    grid_sprites_one_dim = arcade.SpriteList()

    # This will be a two-dimensional grid of sprites to mirror the two
    # dimensional grid of numbers. This points to the SAME sprites that are
    # in grid_sprite_list, just in a 2d manner.
    grid_sprites_two_dim = []

    # Create a list of sprites to represent each grid location
    for row in range(ROW_COUNT):
        grid_sprites_two_dim.append([])

        for column in range(COLUMN_COUNT):

            # Make the sprite as a soft circle
            sprite = arcade.SpriteSolidColor(CELL_WIDTH, CELL_HEIGHT, arcade.color.WHITE)

            # Position the sprite
            x = column * (CELL_WIDTH + CELL_MARGIN) + (CELL_WIDTH / 2 + CELL_MARGIN)
            y = row * (CELL_HEIGHT + CELL_MARGIN) + (CELL_HEIGHT / 2 + CELL_MARGIN)
            sprite.center_x = x
            sprite.center_y = y

            # Add the sprite to both lists
            grid_sprites_one_dim.append(sprite)
            grid_sprites_two_dim[row].append(sprite)

    return grid_sprites_one_dim, grid_sprites_two_dim
    def __init__(self, width, height, title):
        """
        Set up the application.
        """
        super().__init__(width, height, title)

        # Create a 2 dimensional array. A two dimensional
        # array is simply a list of lists.
        self.grid = []
        for row in range(ROW_COUNT):
            # Add an empty array that will hold each cell
            # in this row
            self.grid.append([])
            for column in range(COLUMN_COUNT):
                self.grid[row].append(0)  # Append a cell

        arcade.set_background_color(arcade.color.BLACK)

        self.grid_sprite_list = arcade.SpriteList()

        # Create a list of solid-color sprites to represent each grid location
        for row in range(ROW_COUNT):
            for column in range(COLUMN_COUNT):
                x = column * (WIDTH + MARGIN) + (WIDTH / 2 + MARGIN)
                y = row * (HEIGHT + MARGIN) + (HEIGHT / 2 + MARGIN)
                sprite = arcade.SpriteSolidColor(WIDTH, HEIGHT, arcade.color.WHITE)
                sprite.center_x = x
                sprite.center_y = y
                self.grid_sprite_list.append(sprite)
Beispiel #18
0
    def __init__(self, width, height, title):
        """
        Set up the application.
        """
        super().__init__(width, height, title)

        arcade.set_background_color(arcade.color.BLACK)

        # One dimensional list of all sprites in the two-dimensional sprite list
        self.grid_sprite_list = arcade.SpriteList()

        # This will be a two-dimensional grid of sprites to mirror the two
        # dimensional grid of numbers. This points to the SAME sprites that are
        # in grid_sprite_list, just in a 2d manner.
        self.grid_sprites = []

        # Create a list of solid-color sprites to represent each grid location
        for row in range(ROW_COUNT):
            self.grid_sprites.append([])
            for column in range(COLUMN_COUNT):
                x = column * (WIDTH + MARGIN) + (WIDTH / 2 + MARGIN)
                y = row * (HEIGHT + MARGIN) + (HEIGHT / 2 + MARGIN)
                sprite = arcade.SpriteSolidColor(WIDTH, HEIGHT, arcade.color.WHITE)
                sprite.center_x = x
                sprite.center_y = y
                self.grid_sprite_list.append(sprite)
                self.grid_sprites[row].append(sprite)
Beispiel #19
0
 def setup(self):
     self.musica = arcade.Sound("sonidos/fondo.mp3", True)
     self.musica.play(volume=0.05)
     self.sonido_personas= arcade.Sound("sonidos/oof.wav", False)
     self.perdiste= arcade.Sound("sonidos/game_over.mp3", False)
     #lista de personahes en la pantalla
     self.view_bottom =0
     self.view_left=0
     
     
     self.personajes = arcade.SpriteList()
     self.personaje = arcade.Sprite("imagenes/Green_Virus.png", SCALING)
     self.personaje.center_x= ALTO
     self.personaje.center_y= 1000
     self.personajes.append(self.personaje)
     # leer el mapa
    
     self.map = arcade.tilemap.read_tmx("Mapas/mapa_scrolling.tmx")
     #cargar los layers dentro del sprite list
     self.piso = arcade.SpriteList(use_spatial_hash = True)
     self.piso.extend(arcade.tilemap.process_layer(self.map, "piso"))
     
     borde_izquierdo = arcade.SpriteSolidColor(1 , ALTO*2, arcade.color.BLACK)
     borde_izquierdo.left = -1
     borde_izquierdo.bottom = -ALTO//2  
     self.piso.append(borde_izquierdo)
     borde_derecho = arcade.SpriteSolidColor(1 , ALTO*2, arcade.color.BLACK)
     borde_derecho.left = self.map.tile_size.width*self.map.map_size.width
     borde_derecho.bottom = -ALTO//2 
     self.piso.append(borde_derecho)
     
     self.vegetacion = arcade.SpriteList(use_spatial_hash = True)
     self.vegetacion.extend(arcade.tilemap.process_layer(self.map, "vegetacion"))
     self.edificios = arcade.SpriteList(use_spatial_hash = True)
     self.edificios.extend(arcade.tilemap.process_layer(self.map, "edificios")) 
     self.cielo = arcade.SpriteList(use_spatial_hash = True)
     self.cielo.extend(arcade.tilemap.process_layer(self.map, "cielo")) 
     self.personas = arcade.SpriteList(use_spatial_hash = True)
     self.personas.extend(arcade.tilemap.process_layer(self.map, "personas"))
     self.enemigos = arcade.tilemap.process_layer(self.map, "enemigos", scaling)
     
     for enemigo in self.enemigos:
         enemigo.change_x=2
     
     self.motor_fisica = arcade.PhysicsEnginePlatformer(self.personaje, self.piso)
Beispiel #20
0
 def block_at(x, y):
     block = arcade.SpriteSolidColor(
         settings.WALL_THICKNESS(),
         settings.WALL_THICKNESS(),
         settings.WALL_COLOR,
     )
     block.center_x = x
     block.center_y = y
     wally.append(block)
Beispiel #21
0
 def create_base(self):
     x = settings.SCREEN_WIDTH / 2
     for y in range(0, round(20 * settings.SCALE),
                    settings.WALL_THICKNESS()):
         block = arcade.SpriteSolidColor(
             settings.WALL_THICKNESS(),
             settings.WALL_THICKNESS(),
             settings.BASE_COLOR,
         )
         block.center_x = x - 8 * settings.SCALE
         block.center_y = y
         self.wall_list.append(block)
         block = arcade.SpriteSolidColor(
             settings.WALL_THICKNESS(),
             settings.WALL_THICKNESS(),
             settings.BASE_COLOR,
         )
         block.center_x = x + 8 * settings.SCALE
         block.center_y = y
         self.wall_list.append(block)
Beispiel #22
0
    def __init__(self, width, height, color, length):
        super().__init__(width, height, color)

        self.change_x = 0
        self.change_y = 0
        self.direction = Direction.NONE

        self.parts = arcade.SpriteList()

        for _ in range(length):
            self.parts.append(arcade.SpriteSolidColor(width, height, color))
Beispiel #23
0
    def create_environment(self):
        # Color the sky
        arcade.set_background_color(arcade.csscolor.CORNFLOWER_BLUE)

        # Create the ground
        self.ground = arcade.SpriteSolidColor(
            width=WindowConfig.WIDTH,
            height=WindowConfig.HEIGHT // 3,
            color=arcade.color.DARK_SPRING_GREEN)
        self.ground.center_x = WindowConfig.WIDTH / 2
        self.ground.center_y = WindowConfig.HEIGHT / 6
Beispiel #24
0
    def setup(self):
        # Create your sprites and sprite lists here
        self.root = map_generator.Room(map_generator.ROOM_W, 
                                map_generator.ROOM_H, 
                                (random.randrange(0,255), 
                                random.randrange(0,255), 
                                random.randrange(0,255)), 
                                [None]*map_generator.MAX_ROOM_NEIGH, 
                                (0,0),
                                None)
                    
        map_generator.generate([self.root], 0, 0)

        self.current_camera_pos = (0,0)
        self.camera_target = (0,0)
        self.player = arcade.SpriteSolidColor(PLAYER_SIZE, PLAYER_SIZE, arcade.csscolor.BLACK)
        self.player.center_x = SCREEN_WIDTH // 2
        self.player.center_y = SCREEN_HEIGHT // 2
        self.player_list = arcade.SpriteList()
        self.player_list.append(self.player)
        self.wall_list = arcade.SpriteList()
        self.current_room = self.root

        for y in (0, SCREEN_HEIGHT):
        # Loop for each box going across
            for x in range(0, SCREEN_WIDTH):
                self.wall = arcade.SpriteSolidColor(1,0,arcade.csscolor.WHITE)
                self.wall.left = x
                self.wall.bottom = y
                self.wall_list.append(self.wall)

    # Create left and right column of boxes
        for x in (0, SCREEN_WIDTH):
        # Loop for each box going across
            for y in range(0, SCREEN_WIDTH):
                self.wall = arcade.SpriteSolidColor(1,0,arcade.csscolor.WHITE)
                self.wall.left = x
                self.wall.bottom = y
                self.wall_list.append(self.wall)

        self.physics_engine = arcade.PhysicsEngineSimple(self.player, self.wall_list)    
Beispiel #25
0
    def on_mouse_press(self, x, y, button, modifiers):
        """ Called whenever the mouse button is clicked. """

        bullet = arcade.SpriteSolidColor(20, 5, arcade.color.DARK_YELLOW)
        self.bullet_list.append(bullet)

        # Position the bullet at the player's current location
        start_x = self.player_sprite.center_x
        start_y = self.player_sprite.center_y
        bullet.position = self.player_sprite.position

        # Get from the mouse the destination location for the bullet
        # IMPORTANT! If you have a scrolling screen, you will also need
        # to add in self.view_bottom and self.view_left.
        dest_x = x
        dest_y = y

        # Do math to calculate how to get the bullet to the destination.
        # Calculation the angle in radians between the start points
        # and end points. This is the angle the bullet will travel.
        x_diff = dest_x - start_x
        y_diff = dest_y - start_y
        angle = math.atan2(y_diff, x_diff)

        # What is the 1/2 size of this sprite, so we can figure out how far
        # away to spawn the bullet
        size = max(self.player_sprite.width, self.player_sprite.height) / 2

        # Use angle to to spawn bullet away from player in proper direction
        bullet.center_x += size * math.cos(angle)
        bullet.center_y += size * math.sin(angle)

        # Set angle of bullet
        bullet.angle = math.degrees(angle)

        # Gravity to use for the bullet
        # If we don't use custom gravity, bullet drops too fast, or we have
        # to make it go too fast.
        # Force is in relation to bullet's angle.
        bullet_gravity = (0, -BULLET_GRAVITY)

        # Add the sprite. This needs to be done AFTER setting the fields above.
        self.physics_engine.add_sprite(bullet,
                                       mass=0.1,
                                       damping=1.0,
                                       friction=0.6,
                                       collision_type="bullet",
                                       gravity=bullet_gravity,
                                       elasticity=0.9)

        # Add force to bullet
        force = (BULLET_MOVE_FORCE, 0)
        self.physics_engine.apply_force(bullet, force)
Beispiel #26
0
    def takeCards(self,isEnemy,myCard):

        count = 0
        for pile_no in range(len(self.pile_mat_list)):
            pile = self.pile_mat_list[pile_no]
            if pile.game:
                count += len(self.piles[pile_no])

        if count>0:
            numberOfCardsOnHand = 0
            numberOfMatsOnHand = 0
            for pile_no in range(len(self.pile_mat_list)):
                pile=self.pile_mat_list[pile_no]
                if (isEnemy and pile.enemy) or (myCard and pile.myCard):
                    numberOfMatsOnHand += 1
                    numberOfCardsOnHand += len(self.piles[pile_no])

            numberOfMatsToAdd = numberOfCardsOnHand + count - numberOfMatsOnHand

            for i in range(numberOfMatsToAdd):
                pile = arcade.SpriteSolidColor(MAT_WIDTH, MAT_HEIGHT, arcade.csscolor.DARK_OLIVE_GREEN)
                pile.position = numberOfMatsOnHand * X_SPACING + START_X + i * X_SPACING, TOP_Y if isEnemy else BOTTOM_Y
                pile.enemy=isEnemy
                pile.myCard=myCard
                pile.game=False
                self.pile_mat_list.append(pile)
                cards=[]
                self.piles.append(cards)


            #move cards
            for pile_no in range(len(self.pile_mat_list)):
                pile=self.pile_mat_list[pile_no]
                if pile.game:
                    cards=self.piles[pile_no]
                    for card_index_ in range(len(cards)):
                        card_index=len(cards)-card_index_-1
                        
                        pile_no_to = self.findEmptyPile(isEnemy, myCard)
                        if pile_no_to != -1:
                            cards[card_index].position = self.pile_mat_list[pile_no_to].position

                            if isEnemy:
                                cards[card_index].face_down()
                            else:
                                cards[card_index].face_up()

                            self.move_card_to_new_pile(cards[card_index], pile_no_to)

            self.centerPlayerCards(isEnemy,myCard)

            self.newTurn(False)
Beispiel #27
0
    def setupPiles(self):

        # List of cards we are dragging with the mouse
        self.held_cards = []

        # Original location of cards we are dragging with the mouse in case
        # they have to go back.
        self.held_cards_original_position = []

        # Sprite list with all the mats tha cards lay on.
        self.pile_mat_list: arcade.SpriteList = arcade.SpriteList()
        self.piles = []

        # Create the mats for the trump card
        pile = arcade.SpriteSolidColor(MAT_WIDTH, MAT_HEIGHT, arcade.csscolor.DARK_OLIVE_GREEN)
        pile.position = START_X + X_SPACING, MIDDLE_Y #This is the face up deck pile (Trump)
        pile.enemy=False
        pile.myCard=False
        pile.game=False
        self.pile_mat_list.append(pile)
        self.piles.append([])

        # Create the mats for the bottom face down and face up piles
        pile = arcade.SpriteSolidColor(MAT_WIDTH, MAT_HEIGHT, arcade.csscolor.DARK_OLIVE_GREEN)
        pile.position = START_X, MIDDLE_Y #This is the face back deck pile (Bank)
        pile.enemy=False
        pile.myCard=False
        pile.game=False
        self.pile_mat_list.append(pile)
        self.piles.append([])

        # Create the mats for the done piles
        pile = arcade.SpriteSolidColor(MAT_WIDTH, MAT_HEIGHT, arcade.csscolor.DARK_OLIVE_GREEN)
        pile.position = END_X - MAT_WIDTH, MIDDLE_Y #This is the face back deck pile (Bank)
        pile.enemy=False
        pile.myCard=False
        pile.game=False
        self.pile_mat_list.append(pile)
        self.piles.append([])
Beispiel #28
0
 def init_grid_sprite_list(self):
     self.grid_sprite_list = arcade.SpriteList()
     for row in range(self.row_count):
         for col in range(self.col_count):
             x = col * (self.cell_width + self.margin) + (
                 self.cell_width / 2 + self.margin)
             y = row * (self.cell_height + self.margin) + (
                 self.cell_height / 2 + self.margin)
             sprite = arcade.SpriteSolidColor(self.cell_width,
                                              self.cell_height,
                                              arcade.color.WHITE)
             sprite.center_x = x
             sprite.center_y = y
             self.grid_sprite_list.append(sprite)
Beispiel #29
0
    def setup(self):
        self.map = GameMap(COLUMN_COUNT, ROW_COUNT)
        self.map.make_map(level=1)

        for row in range(COLUMN_COUNT):
            for column in range(ROW_COUNT):
                x = column * WIDTH + (WIDTH / 2)
                y = row * HEIGHT + (HEIGHT / 2)

                sprite = None

                if self.map.tiles[row][column] == 0:
                    sprite = arcade.SpriteSolidColor(WIDTH, HEIGHT,
                                                     arcade.color.WHITE)
                elif self.map.tiles[row][column] == 1:
                    sprite = arcade.SpriteSolidColor(WIDTH, HEIGHT,
                                                     arcade.color.BLACK)
                elif self.map.tiles[row][column] == 22:
                    sprite = self.player

                sprite.center_x = x
                sprite.center_y = y
                self.grid_sprites.append(sprite)
Beispiel #30
0
 def generate_level(self, start, lastLevel, iters):
     start_y = lastLevel
     last_level_x = start
     for i in range(0, iters):
         x = random.randint(2, 6) * 64  # Calculate length of platform
         y = start_y + random.randint(-1, 1)
         platform = arcade.SpriteSolidColor(x, 64, arcade.color.SKY_BLUE)
         platform.left = start
         platform.bottom = 194 + y * 64
         start += x
         last_level_y = y
         last_level_x += x
         self.platform_list.append(platform)
     return (last_level_x, last_level_y)