def setup(self, level):
        """ Set up the game here. Call this function to restart the game. """
        super().setup(level)
        self.player_one.state.isInPortal = False
        self.player_one.state.isWithKey = False
        self.player_one.player_sprite.center_x = 192
        self.player_one.player_sprite.center_y = 192
        self.player_one.score = 0
        self.player_one.cards = (self.controlador.get_cards())

        self.player_two.state.isInPortal = False
        self.player_two.state.isWithKey = False
        self.player_two.player_sprite.center_x = 192
        self.player_two.player_sprite.center_y = 192
        self.player_two.score = 0
        self.player_two.cards = (self.controlador.get_cards())
        # Create the 'physics engine'
        self.physics_engine_one = arcade.PhysicsEnginePlatformer(
            self.player_one.player_sprite, self.wall_list,
            self.controlador.GRAVITY)

        self.physics_engine_two = arcade.PhysicsEnginePlatformer(
            self.player_two.player_sprite, self.wall_list,
            self.controlador.GRAVITY)

        self.player_list.append(self.player_one.player_sprite)
        self.player_list.append(self.player_two.player_sprite)
    def setup(self, arcade, game, stage, p1, p2):
        """
        Initial setup to prepare the Training Screen
        """
        # Setup Stage
        game.stage = stage
        game.platforms = game.stage.platform_list

        # Setup Players
        game.player1 = p1
        game.player1.reset()
        game.player1.center_x = game.stage.p1_start_x
        game.player1.center_y = game.stage.p1_start_y
        game.player2 = p2
        game.player2.reset()
        game.player2.center_x = game.stage.p2_start_x
        game.player2.center_y = game.stage.p2_start_y

        game.playerPlatform1.append(game.player2)
        game.playerPlatform2.append(game.player1)

        # Setup Physics
        game.physics1 = arcade.PhysicsEnginePlatformer(game.player1,
                                                       game.platforms,
                                                       gravity_constant=0.5)
        game.physics2 = arcade.PhysicsEnginePlatformer(game.player2,
                                                       game.platforms,
                                                       gravity_constant=0.5)

        # Game Over Flag
        self.gameOver = False
        self.winner = ""

        # Set new view state
        game.currentView = game.twoPlayerScreen
    def setup(self, level, savex1=192, savex2=192, savey1=192, savey2=192):
        """ Set up the game here. Call this function to restart the game. """
        super().setup(level)
        self.level = level
        self.player_one.state().isInPortal = False
        self.player_one.state().isWithKey = False
        self.player_one.player_sprite.center_x = savex1
        self.player_one.player_sprite.center_y = savey1

        self.player_two.state().isInPortal = False
        self.player_two.state().isWithKey = False
        self.player_two.player_sprite.center_x = savex2
        self.player_two.player_sprite.center_y = savey2

        # Create the 'physics engine'
        self.physics_engine_one = arcade.PhysicsEnginePlatformer(
            self.player_one.player_sprite, self.wall_list,
            self.controlador.GRAVITY)

        self.physics_engine_two = arcade.PhysicsEnginePlatformer(
            self.player_two.player_sprite, self.wall_list,
            self.controlador.GRAVITY)

        self.player_list.append(self.player_one.player_sprite)
        self.player_list.append(self.player_two.player_sprite)
Esempio n. 4
0
    def update(self, delta_time):
        """ Movement and game logic """
        if self.current_state == INSTRUCTIONS_PAGE:
            self.draw_instructions_page()

        # Only move and do things if the game is running.
        if self.current_state == GAME_RUNNING:

            self.physics_engine.update()
            if self.physics_engine.can_jump():
                self.DOUBLE_JUMP_AVAILABLE = True

            # Do some logic here to figure out what room we are in, and if we need to go
            # to a different room.
            if self.player_sprite.center_x > SCREEN_WIDTH and self.current_room == 0:
                self.current_room = 1
                self.physics_engine = arcade.PhysicsEnginePlatformer(
                    self.player_sprite,
                    self.rooms[self.current_room].wall_list,
                    gravity_constant=GRAVITY)
                self.player_sprite.center_x = 0
            elif self.player_sprite.center_x < 0 and self.current_room == 1:
                self.current_room = 0
                self.physics_engine = arcade.PhysicsEnginePlatformer(
                    self.player_sprite,
                    self.rooms[self.current_room].wall_list,
                    gravity_constant=GRAVITY)
                self.player_sprite.center_x = SCREEN_WIDTH
Esempio n. 5
0
    def setup(self):
        """ Set up the game here. Call this function to restart the game. """
        # Used to keep track of our scrolling
        self.view_bottom = 0
        self.view_left = 0

        #Keep track of health
        #TODO Do we want to have different health on different levels.
        #TODO switch health to be stored in character.

        # Create the Sprite lists
        self.player_list = arcade.SpriteList()
        self.wall_list = arcade.SpriteList()
        self.damage_list = arcade.SpriteList()
        self.tweet_list = arcade.SpriteList()
        self.tan_list = arcade.SpriteList()
        self.enemy_list = arcade.SpriteList()

        # Set up the player fallback image.
        image_source = ":resources:images/animated_characters/female_adventurer/femaleAdventurer_idle.png"
        self.player = TrumpCharacter.PlayerCharacter(image_source)
        self.player_list.append(self.player)

        self.score = 0
        self.player.health = 30

        # --- Load in a map from the tiled editor ---
        self.map = self.maps[self.currentLevel]["map"]
        self.background = self.maps[self.currentLevel]["background"]

        self.wall_list = self.map.wall_list
        self.damage_list = self.map.damage_list

        for thing in self.map.tweet_list:
            self.tweet_list.append(
                item.AnimatedItem("images/items/Tweet/tweet",
                                  16,
                                  thing.center_x,
                                  thing.center_y,
                                  scale=0.5))

        for thing in self.map.tan_list:
            self.tan_list.append(
                item.AnimatedItem("images/items/Tan/tan", 14, thing.center_x,
                                  thing.center_y))

        self.enemy_list = self.map.enemy_list

        self.physics_engine = arcade.PhysicsEnginePlatformer(
            self.player, self.wall_list, GRAVITY)

        for enemy in self.enemy_list:
            enemy.physics = arcade.PhysicsEnginePlatformer(
                enemy, self.wall_list, GRAVITY)

        self.base_viewport = arcade.get_viewport()

        print
Esempio n. 6
0
    def Generate_Enemie(self, numero_de_Portal, pos_x, pos_y):

        if (numero_de_Portal == 0):
            alive = False
            for enemi in self.enemy_list:
                if enemi == self.enemy1:
                    alive = True
            if not alive:
                if self.enemy1 == None:
                    # Set up the enemy1
                    self.enemy1 = Enemie_1()
                    self.enemy1.setup()

                self.dead_enemie1 = False
                self.enemy1.Load()
                # Set up the enemy1 position
                self.enemy1.center_x = pos_x
                self.enemy1.center_y = pos_y
                self.enemy1.scale = PLAYER_SCALE

                self.enemy_list.append(self.enemy1)

                self.physics_engine_enemy1 = arcade.PhysicsEnginePlatformer(self.enemy1, self.wall_list,
                                                                            gravity_constant=GRAVITY)
                arcade.play_sound(self.enemieGenerate_sound)

        elif numero_de_Portal == 1:
            alive = False
            for enemi in self.enemy_list:
                if enemi == self.enemy2:
                    alive = True
            if not alive:
                if self.enemy2 == None:
                    # Set up the enemy2
                    self.enemy2 = Enemie_2()
                    self.enemy2.setup()
                self.dead_enemie2 = False
                self.enemy2.Load()
                # Set up the enemy1 position
                self.enemy2.center_x = pos_x
                self.enemy2.center_y = pos_y
                self.enemy2.scale = PLAYER_SCALE

                self.enemy_list.append(self.enemy2)

                self.physics_engine_enemy2 = arcade.PhysicsEnginePlatformer(self.enemy2, self.wall_list,
                                                                            gravity_constant=GRAVITY)
                arcade.play_sound(self.enemieGenerate_sound)

        elif numero_de_Portal == 2:
            # Set up the enemy1 position
            self.boss1.center_x = pos_x
            self.boss1.center_y = 600
            self.boss1.scale = BOSS_SCALE
            self.dead_boss1 = False
            self.enemy_list.append(self.boss1)
Esempio n. 7
0
 def add_physic(self,player,enemy,wall):
     self.physic_player = None
     self.physic_enemy = []
     player_phy = arcade.PhysicsEnginePlatformer(player,wall,gravity_constant=GRAVITY)
     self.physic_player = player_phy
     for each_enemy in enemy:
         gravity = 0.6
         if not each_enemy.want_to_jump:
             gravity = 0
         enemy_phy = arcade.PhysicsEnginePlatformer(each_enemy,wall,gravity_constant=gravity)
         self.physic_enemy.append(enemy_phy)
    def setup(self):
        #  for scrolling
        self.view_bottom = 0
        self.view_left = 0

        # Keep track of the score
        self.score = 0

        self.player_list = arcade.SpriteList()
        self.wall_list = arcade.SpriteList()
        self.coin_list = arcade.SpriteList()

        # identify player position
        self.player_sprite = arcade.Sprite('images/player_1/player_stand.png',
                                           CHARACTER_SCALING)
        self.player_sprite.center_x = 64
        self.player_sprite.center_y = 120
        # self.player_sprite.position = [64, 120]
        self.player_list.append(self.player_sprite)

        # identify grass position
        for x in range(0, 1250, 64):
            wall = arcade.Sprite('images/tiles/grassMid.png', TILE_SCALING)
            wall.center_x = x
            wall.center_y = 32
            self.wall_list.append(wall)

        coordinate_list = [[512, 96], [256, 96], [768, 96]]

        # identify boxes position
        for coordinate in coordinate_list:
            wall = arcade.Sprite('images/tiles/boxCrate_double.png',
                                 TILE_SCALING)
            wall.position = coordinate
            self.wall_list.append(wall)

        # some physics
        self.physics_engine = arcade.PhysicsEnginePlatformer(
            self.player_sprite, self.wall_list, GRAVITY)

        # addin the coins
        for x in range(128, 1250, 256):
            coin = arcade.Sprite('images/items/coinGold.png', COIN_SCALING)
            coin.center_x = x
            coin.center_y = 96
            self.coin_list.append(coin)

        # Create the 'physics engine'
        self.physics_engine = arcade.PhysicsEnginePlatformer(
            self.player_sprite, self.wall_list, GRAVITY)
Esempio n. 9
0
    def setup(self):
        my_map = arcade.read_tiled_map("maps/my-map1.tmx", 1)
        self.ground_list = arcade.generate_sprites(my_map, "ground", 1)
        self.bones_list = arcade.generate_sprites(my_map, "bones", 1)
        self.streettop_list = arcade.generate_sprites(my_map, "streettop", 1)
        self.background = arcade.load_texture("images/sky.png")
        self.player_list = arcade.SpriteList()
        self.enemy_list = arcade.SpriteList()
        self.enemy2_list = arcade.SpriteList()
        self.enemy3_list = arcade.SpriteList()
        self.enemy4_list = arcade.SpriteList()
        # Set up player
        self.player = PlayerCharacter()
        self.player.center_x = 300
        self.player.center_y = 500
        self.player.scale = 1
        self.player_list.append(self.player)
        # Set up enemy
        self.enemy = Motorcycle()
        self.enemy.center_x = 3000
        self.enemy.center_y = 260
        self.enemy.scale = .5
        self.enemy_list.append(self.enemy)
        # Set up enemy 2
        self.enemy2 = Motorcycle2()
        self.enemy2.center_x = 5500
        self.enemy2.center_y = 260
        self.enemy2.scale = .5
        self.enemy2_list.append(self.enemy2)
        # Set up enemy 3
        self.enemy3 = Motorcycle()
        self.enemy3.center_x = 7500
        self.enemy3.center_y = 260
        self.enemy3.scale = .5
        self.enemy3_list.append(self.enemy3)
        # Set up enemy 4
        self.enemy4 = Motorcycle2()
        self.enemy4.center_x = 9500
        self.enemy4.center_y = 260
        self.enemy4.scale = .5
        self.enemy4_list.append(self.enemy4)

        self.physics_engine = arcade.PhysicsEnginePlatformer(self.player, self.ground_list, gravity_constant=GRAVITY)
        self.enemy_physics_engine = arcade.PhysicsEnginePlatformer(self.enemy, self.ground_list, gravity_constant=GRAVITY)
        self.enemy2_physics_engine = arcade.PhysicsEnginePlatformer(self.enemy2, self.ground_list, gravity_constant=GRAVITY)
        self.enemy3_physics_engine = arcade.PhysicsEnginePlatformer(self.enemy3, self.ground_list, gravity_constant=GRAVITY)
        self.enemy4_physics_engine = arcade.PhysicsEnginePlatformer(self.enemy4, self.ground_list, gravity_constant=GRAVITY)
        self.player.change_x = MOVEMENT_SPEED
Esempio n. 10
0
    def setup_player(self):
        self.player = Player()
        self.player.stand_right_textures = []
        self.player.stand_left_textures = []
        self.player.walk_right_textures = []
        self.player.walk_left_textures = []
        self.player.stand_right_textures.append(
            arcade.load_texture("images/player_3/stand/0.png",
                                scale=CHARACTER_SCALING))
        self.player.stand_left_textures.append(
            arcade.load_texture("images/player_3/stand/0.png",
                                scale=CHARACTER_SCALING,
                                mirrored=True))
        for i in range(8):
            self.player.walk_right_textures.append(
                arcade.load_texture("images/player_3/walk/" + str(i) + ".png",
                                    scale=CHARACTER_SCALING))
        for i in range(8):
            self.player.walk_left_textures.append(
                arcade.load_texture("images/player_3/walk/" + str(i) + ".png",
                                    scale=CHARACTER_SCALING,
                                    mirrored=True))

        self.player.texture_change_distance = 25
        self.player.center_x = PLAYER_START_X
        self.player.center_y = PLAYER_START_Y
        self.player.scale = CHARACTER_SCALING
        self.physics_engine = arcade.PhysicsEnginePlatformer(
            self.player, self.wall_list, GRAVITY)
        self.player.physics_engine = self.physics_engine
        self.player_list.append(self.player)
Esempio n. 11
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)
Esempio n. 12
0
    def setup(self):
        """ Set up the game and initialize the variables. """

        # Sprite lists
        self.player_list = arcade.SpriteList()
        self.wall_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)

        # boxes
        for x in range(173, 650, 64):
            wall = arcade.Sprite("images/boxCrate_double.png", SPRITE_SCALING)
            wall.center_x = x
            wall.center_y = 200
            self.wall_list.append(wall)

        for x in range(0, SCREEN_WIDTH, 64):
            wall = arcade.Sprite("images/boxCrate_double.png", SPRITE_SCALING)
            wall.center_x = x
            wall.center_y = 0
            self.wall_list.append(wall)

        for y in range(273, 500, 64):
            wall = arcade.Sprite("images/boxCrate_double.png", SPRITE_SCALING)
            wall.center_x = 465
            wall.center_y = y
            self.wall_list.append(wall)

        self.physics_engine = arcade.PhysicsEnginePlatformer(self.player_sprite,
                                                         self.wall_list, gravity_constant= GRAVITY)
Esempio n. 13
0
    def setup(self):
        self.background = arcade.load_texture("backgrounds/beach.png")
        self.player_list = arcade.SpriteList()
        self.wall_list = arcade.SpriteList()
        self.coin_list = arcade.SpriteList()

        self.player_sprite = arcade.Sprite("sprite/crab.png",
                                           CHARACTER_SCALING)
        self.player_sprite.center_x = 64
        self.player_sprite.center_y = 120
        self.player_list.append(self.player_sprite)

        self.score = 0
        """ Places the sand as the floor """
        for x in range(0, 1250, 64):
            wall = arcade.Sprite("sprite/sand.jpg", TILE_SCALING)
            wall.center_x = x
            wall.center_y = 32
            self.wall_list.append(wall)
        """ Using the coordinate list, places the seashells and the 
        coins above it, dependent on its location. """
        coordinate_list = [[256, 96], [430, 200], [870, 380], [650, 300]]

        for coordinate in coordinate_list:
            wall = arcade.Sprite("sprite/seashell.png", TILE_SCALING)
            wall.position = coordinate
            self.wall_list.append(wall)
            coin = arcade.Sprite("sprite/coinGold.png", COIN_SCALING)
            coin.center_x = coordinate[0]
            coin.center_y = coordinate[1] + 70
            self.coin_list.append(coin)

        self.physics_engine = arcade.PhysicsEnginePlatformer(
            self.player_sprite, self.wall_list, GRAVITY)
Esempio n. 14
0
    def setup(self):
        self.player_list = arcade.SpriteList()
        self.wall_list = arcade.SpriteList(use_spatial_hash=True)
        self.coin_list = arcade.SpriteList(use_spatial_hash=True)

        self.player_sprite = arcade.Sprite(
            ":resources:images/animated_characters/male_person/malePerson_idle.png",
            PLAYER_SCALE)
        self.player_sprite.center_x = 0
        self.player_sprite.center_y = 120
        self.player_list.append(self.player_sprite)

        for x in range(0, 1250, 64):
            wall = arcade.Sprite(":resources:/images/tiles/grassMid.png",
                                 TILE_SCALE)
            wall.center_x = x
            wall.center_y = 32
            self.wall_list.append(wall)

        coordinate_list = [[512, 96], [256, 96], [768, 96]]

        for coordinate in coordinate_list:
            crate = arcade.Sprite(
                ":resources:images/tiles/boxCrate_double.png", TILE_SCALE)
            crate.position = coordinate
            self.wall_list.append(crate)

        for x in range(128, 1250, 256):
            coin = arcade.Sprite(":resources:images/items/coinGold.png")
            coin.center_x = x
            coin.center_y = 96
            self.coin_list.append(coin)

        self.physics_engine = arcade.PhysicsEnginePlatformer(
            self.player_sprite, self.wall_list, GRAVITY)
Esempio n. 15
0
    def __init__(self, path, wall, ladder):
        super().__init__()

        self.textures = []
        # Load a left facing texture and a right facing texture.
        # mirrored=True will mirror the image we load.
        texture = arcade.load_texture(path)
        self.textures.append(texture)
        texture = arcade.load_texture(path, mirrored=True)
        self.textures.append(texture)

        self.scale = SPRITE_SCALING

        # By default, face right.
        self.set_texture(TEXTURE_RIGHT)

        # Set health
        self.health = 100

        # Set up cooldowns
        self.attack_cooldown = 0.0

        # physics engine
        self.physics_engine = arcade.PhysicsEnginePlatformer(self,
                                                             wall,
                                                             GRAVITY,
                                                             ladders=ladder)
Esempio n. 16
0
    def setup(self):
        """ Настроить игру и инициализировать переменные. """

        # Создать список спрайтов
        self.player_list = arcade.SpriteList()
        self.cocainum_list = arcade.SpriteList()
        self.wall_list = arcade.SpriteList()

        self._add_cocainum()
        self._draw_walls()

        # Счет
        self.score = 0

        # Задать игрока и его изображение
        self.player_sprite = arcade.Sprite("img/character.png",
                                           SPRITE_SCALING_PLAYER)
        self.player_sprite.center_x = 100  # Стартовая позиция
        self.player_sprite.center_y = 100
        self.player_sprite.height = 100
        self.player_sprite.width = 80
        self.player_list.append(self.player_sprite)

        self._draw_hallucination()

        self.physics_engine = arcade.PhysicsEnginePlatformer(
            self.player_sprite, self.wall_list, gravity_constant=GRAVITY)
Esempio n. 17
0
    def level_updater(self):
        if self.level < 13:
            # Defines the format each Tiled map file should use
            map_name = f"map_level_{self.level}.tmx"

            # Defines the layers from the Tiled file that each list will correspond to
            platforms_layer_name = 'Platforms'
            footballs_layer_name = 'Football'
            defenders_layer_name = 'Defender'

            # Sets up the name of the map file that should be set up
            my_map = arcade.tilemap.read_tmx(map_name)

            # Connects each Sprite list to the Tiled Layers
            self.wall_list = arcade.tilemap.process_layer(
                my_map, platforms_layer_name, TILE_SCALING)
            self.football_list = arcade.tilemap.process_layer(
                my_map, footballs_layer_name, FOOTBALL_SCALING)
            self.defender_list = arcade.tilemap.process_layer(
                my_map, defenders_layer_name, TILE_SCALING)
            self.physics_engine = arcade.PhysicsEnginePlatformer(
                self.player_sprite, self.wall_list, GRAVITY)

            # Changes the background based on which level the user is currently on
            if self.level % 3 == 0:
                self.flag = 0
                self.background = arcade.load_texture(
                    "images/Cowboys_Office.jpeg")
            else:
                self.background = arcade.load_texture(
                    "images/Cowboys_Stadium.jpeg")
Esempio n. 18
0
    def __init__(self):

        # Вызвать родительский класс и настроить окно
        super().__init__(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE)

        # Это «списки», которые отслеживают наши спрайты. Каждый спрайт должен быть внесен в список.
        self.coin_list = None
        self.wall_list = None
        self.player_list = None
        self.player_sprite_list = None
        self.total_time = 0.0

        # Отдельная переменная, в которой хранится спрайт игрока
        self.player_sprite = None

        # Наш физический движок
        self.physics_engine = None
        self.physics_engine = arcade.PhysicsEnginePlatformer(
            self.player_sprite, self.wall_list, GRAVITY)

        # Используется для отслеживания нашей прокрутки
        self.view_bottom = 0
        self.view_left = 0

        # Следите за счетом
        self.score = 0

        # Загрузка звуков
        self.collect_coin_sound = arcade.load_sound(
            ":resources:sounds/coin1.wav")
        self.jump_sound = arcade.load_sound(":resources:sounds/jump1.wav")

        arcade.set_background_color(arcade.csscolor.LIGHT_BLUE)
Esempio n. 19
0
    def setup(self):
        """ Set up the game and initialize the variables. """

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

        # Set up the player
        self.player_sprite = PlayerCharacter()

        # Starting position of the player
        self.player_sprite.center_x = SPAWN_X
        self.player_sprite.center_y = SPAWN_Y
        self.player_list.append(self.player_sprite)

        # Setting up score and other constants
        self.score = 0
        self.lives = 5

        # Making mouse invisible
        self.window.set_mouse_visible(False)

        # Load in Sounds
        self.coin_sound = arcade.load_sound("coin1.wav")
        self.die_sound = arcade.load_sound("error4.wav")
        self.next_level_sound = arcade.load_sound("secret2.wav")

        # --- Load in the map ---
        map_name = "Level1.tmx"

        # Different Layers
        platforms_layer = 'Platforms'
        spike_layer = 'Spikes'
        coin_layer = 'Coins'

        my_map = arcade.tilemap.read_tmx(map_name)

        # --- Layer Lists ---
        self.wall_list = arcade.tilemap.process_layer(my_map, platforms_layer,
                                                      PLATFORM_SCALING)

        self.spike_list = arcade.tilemap.process_layer(my_map, spike_layer,
                                                       PLATFORM_SCALING)

        self.coin_list = arcade.tilemap.process_layer(my_map, coin_layer,
                                                      PLATFORM_SCALING)

        # Create out platformer physics engine with gravity
        self.physics_engine = arcade.PhysicsEnginePlatformer(
            self.player_sprite, self.wall_list, gravity_constant=GRAVITY)

        if my_map.background_color:
            arcade.set_background_color(my_map.background_color)

        # Set the view port boundaries
        # These numbers set where we have 'scrolled' to.
        self.view_left = 0
        self.view_bottom = 0
Esempio n. 20
0
    def __init__(self):
        """Initalize the Gorund class
        Args:
            self (Ground): An instance of Ground
        Contributors:
            Reed Hunsaker
            Isabel Aranguren
        """
        # Name of map file to load
        self.map_name = constants.WALLS
        self.platforms_layer_name = 'Walls'
        
        # Read in the tiled map
        self.my_map = arcade.tilemap.read_tmx(self.map_name)    
        self.ground_sprite_list = arcade.tilemap.process_layer(map_object=self.my_map,
                                                      layer_name=self.platforms_layer_name,
                                                      scaling=constants.TILE_SCALING,
                                                      use_spatial_hash=True)
        # Set the background color
        if self.my_map.background_color:
            arcade.set_background_color(self.my_map.background_color)

        # Create the 'physics engine'
        self.physics_engine = arcade.PhysicsEnginePlatformer(self.ground_sprite_list,
                                                             constants.GRAVITY)
Esempio n. 21
0
    def setup(self):
        self.player_list = arcade.SpriteList()
        self.wall_list = arcade.SpriteList()
        self.coin_list = arcade.SpriteList()

        #Player
        image_source = "mario.png"
        self.player_sprite = arcade.Sprite(image_source, CHARACTER_SCALING)
        self.player_sprite.center_x = 64
        self.player_sprite.center_y = 93
        self.player_list.append(self.player_sprite)

        # Create the ground
        # This shows using a loop to place multiple sprites horizontally
        for x in range(0, 1250, 64):
            wall = arcade.Sprite("ground.png", GROUND_SCALING)
            wall.center_x = x
            wall.center_y = 32
            self.wall_list.append(wall)

            # This shows using a coordinate list to place sprites
        coordinate_list = [[512, 110], [256, 110], [768, 110]]

        for coordinate in coordinate_list:
            # Add a crate on the ground
            wall = arcade.Sprite("cylinder.png", CYLINDER_SCALING)
            wall.position = coordinate
            self.wall_list.append(wall)

        #Creathe the "physics engine"
        self.physics_engine = arcade.PhysicsEnginePlatformer(
            self.player_sprite, self.wall_list, GRAVITY)
Esempio n. 22
0
    def setup(self):
        """Create the spritelists"""
        self.player_list = arcade.SpriteList()
        self.wall_list = arcade.SpriteList(use_spatial_hash=True)
        self.coin_list = arcade.SpriteList(use_spatial_hash=True)
        """Set up the player, specifically placing it at these coordinates."""
        image_source = ":resources:images/animated_characters/female_adventurer/femaleAdventurer_idle.png"
        self.player_sprite = arcade.Sprite(image_source, CHARACTER_SCALING)
        self.player_sprite.center_x = 64
        self.player_sprite.center_y = 128
        self.player_list.append(self.player_sprite)
        """Create the ground. """
        """This shows using a loop to place multiple sprites horizontally"""
        for x in range(0, 1250, 64):
            wall = arcade.Sprite(":resources:images/tiles/grassMid.png",
                                 TILE_SCALING)
            wall.center_x = x
            wall.center_y = 32
            self.wall_list.append(wall)
        """Put some crates on the ground.  This shows using a coordinate list to place sprites"""
        coordinate_list = [[512, 96], [256, 96], [768, 96]]

        for coordinate in coordinate_list:
            """Add a crate on the ground"""
            wall = arcade.Sprite(":resources:images/tiles/boxCrate_double.png",
                                 TILE_SCALING)
            wall.position = coordinate
            self.wall_list.append(wall)
        """Create the 'physics engine"""
        self.physics_engine = arcade.PhysicsEnginePlatformer(
            self.player_sprite, self.wall_list, GRAVITY)
    def load_level(self, level):
        # Read in the tiled map
        my_map = arcade.tilemap.read_tmx(
            f":resources:tmx_maps/level_{level}.tmx")

        # --- Walls ---

        # Calculate the right edge of the my_map in pixels
        self.end_of_map = my_map.map_size.width * GRID_PIXEL_SIZE

        # Grab the layer of items we can't move through
        self.wall_list = arcade.tilemap.process_layer(my_map, 'Platforms',
                                                      TILE_SPRITE_SCALING)

        self.physics_engine = arcade.PhysicsEnginePlatformer(
            self.player_sprite, self.wall_list, gravity_constant=GRAVITY)

        # --- Other stuff
        # Set the background color
        if my_map.background_color:
            arcade.set_background_color(my_map.background_color)

        # Set the view port boundaries
        # These numbers set where we have 'scrolled' to.
        self.view_left = 0
        self.view_bottom = 0
Esempio n. 24
0
    def setup(self):
        """ Set up the game and initialize the variables. """

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

        # Set up the player
        self.player_sprite = arcade.Sprite("female_stand.png", SPRITE_SCALING)

        # Starting position of the player
        self.player_sprite.center_x = 90
        self.player_sprite.center_y = 270
        self.player_list.append(self.player_sprite)

        my_map = arcade.tilemap.read_tmx("final.tmx")
        self.wall_list = arcade.tilemap.process_layer(my_map, "Tile Layer 1",
                                                      SPRITE_SCALING)
        self.background_list = arcade.tilemap.process_layer(
            my_map, "Background", SPRITE_SCALING)

        if my_map.background_color:
            arcade.set_background_color(my_map.background_color)

        self.physics_engine = arcade.PhysicsEnginePlatformer(
            self.player_sprite, self.wall_list, GRAVITY)

        # Set the background color
        arcade.set_background_color(arcade.color.AMAZON)

        # Set the view port boundaries
        # These numbers set where we have 'scrolled' to.
        self.view_left = 0
        self.view_bottom = 0
    def setup(self):
        """ Set up the game and initialize the variables. """

        # Sprite lists
        self.all_sprites_list = arcade.SpriteList()
        self.wall_list = arcade.SpriteList()

        # Set up the player
        self.player_sprite = arcade.Sprite("images/character.png",
                                           SPRITE_SCALING)

        # Starting position of the player
        self.player_sprite.center_x = 64
        self.player_sprite.center_y = 270
        self.all_sprites_list.append(self.player_sprite)

        # Draw the walls on the bottom
        for x in range(0, SCREEN_WIDTH,
                       int(SPRITE_NATIVE_SIZE * SPRITE_SCALING)):
            wall = arcade.Sprite("images/grassMid.png", SPRITE_SCALING)

            wall.bottom = 0
            wall.left = x
            self.all_sprites_list.append(wall)
            self.wall_list.append(wall)

        self.physics_engine = arcade.PhysicsEnginePlatformer(
            self.player_sprite, self.wall_list, gravity_constant=GRAVITY)

        # Set the background color
        arcade.set_background_color(arcade.color.AMAZON)
Esempio n. 26
0
    def setup(self):
        """ Set up the game and initialize the variables. """

        # Sprite lists
        self.all_sprites_list = arcade.SpriteList()
        self.wall_list = arcade.SpriteList()

        # Set up the player
        self.score = 0
        self.player_sprite = arcade.Sprite("character.png", SPRITE_SCALING)

        # Starting position of the player
        self.player_sprite.center_x = 64
        self.player_sprite.center_y = 270
        self.all_sprites_list.append(self.player_sprite)

        # Get a 2D array made of numbers based on the map
        map_array = get_map("map.csv")

        # Now that we've got the map, loop through and create the sprites
        for row_index, row in enumerate(map_array):
            for column_index, item in enumerate(row):

                # For this map, the numbers represent:
                # -1 = empty
                # 0  = box
                # 1  = grass left edge
                # 2  = grass middle
                # 3  = grass right edge
                if item == -1:
                    continue
                elif item == 0:
                    wall = arcade.Sprite("boxCrate_double.png", SPRITE_SCALING)
                elif item == 1:
                    wall = arcade.Sprite("grassLeft.png", SPRITE_SCALING)
                elif item == 2:
                    wall = arcade.Sprite("grassMid.png", SPRITE_SCALING)
                elif item == 3:
                    wall = arcade.Sprite("grassRight.png", SPRITE_SCALING)

                # Calculate where the sprite goes
                wall.left = column_index * SCALED_TILE_SIZE
                wall.top = (MAP_HEIGHT - row_index) * SCALED_TILE_SIZE

                # Add the sprite
                self.all_sprites_list.append(wall)
                self.wall_list.append(wall)

        self.physics_engine = arcade.PhysicsEnginePlatformer(
            self.player_sprite, self.wall_list, gravity_constant=GRAVITY)

        # Set the background color
        arcade.set_background_color(arcade.color.AMAZON)

        # Set the view port boundaries
        # These numbers set where we have 'scrolled' to.
        self.view_left = 0
        self.view_bottom = 0

        self.game_over = False
    def setup(self):
        """ Set up the game here. Call this function to restart the game. """
        # Create the Sprite lists
        self.player_list = arcade.SpriteList()
        self.wall_list = arcade.SpriteList()
        self.coin_list = arcade.SpriteList()

        # Set up the player, specifically placing it at these coordinates.
        self.player_sprite = arcade.Sprite("images/ada.png", CHARACTER_SCALING)
        self.player_sprite.center_x = 64
        self.player_sprite.center_y = 96
        self.player_list.append(self.player_sprite)

        # Create the ground
        # This shows using a loop to place multiple sprites horizontally
        for x in range(0, 1250, 64):
            wall = arcade.Sprite("images/potato.png", TILE_SCALING)
            wall.center_x = x
            wall.center_y = 32
            self.wall_list.append(wall)

        # Put some crates on the ground
        # This shows using a coordinate list to place sprites
        coordinate_list = [[512, 96], [256, 96], [768, 96]]

        for coordinate in coordinate_list:
            # Add a crate on the ground
            wall = arcade.Sprite("images/cisc108_banner.png", TILE_SCALING)
            wall.position = coordinate
            self.wall_list.append(wall)

        # Create the 'physics engine'
        self.physics_engine = arcade.PhysicsEnginePlatformer(
            self.player_sprite, self.wall_list, GRAVITY)
    def setup(self):
        #  for scrolling
        self.view_bottom = 0
        self.view_left = 0

        # Keep track of the score
        self.score = 0

        self.player_list = arcade.SpriteList()
        self.wall_list = arcade.SpriteList()
        self.coin_list = arcade.SpriteList()

        self.player_sprite = arcade.Sprite('images/player_1/player_stand.png',
                                           CHARACTER_SCALING)
        self.player_sprite.center_x = 64
        self.player_sprite.center_y = 120
        # self.player_sprite.position = [64, 120]
        self.player_list.append(self.player_sprite)

        for x in range(0, 1250, 64):
            wall = arcade.Sprite('images/tiles/grassMid.png', TILE_SCALING)
            wall.center_x = x
            wall.center_y = 32
            self.wall_list.append(wall)

        coordinate_list = [[512, 96], [256, 96], [768, 96]]

        for coordinate in coordinate_list:
            wall = arcade.Sprite('images/tiles/boxCrate_double.png',
                                 TILE_SCALING)
            wall.position = coordinate
            self.wall_list.append(wall)

        self.physics_engine = arcade.PhysicsEnginePlatformer(
            self.player_sprite, self.wall_list, GRAVITY)
Esempio n. 29
0
    def setup(self):

        # Make Sphere affected by gravity
        print('Sphere Setup - floors list: ' + str(POCGame().floors_list))
        self.sphere_sprite.physics_engine = arcade.PhysicsEnginePlatformer(self.sphere_sprite, 
                                                                            platforms =  POCGame.floors_list,
                                                                            gravity_constant=GRAVITY)
Esempio n. 30
0
    def __init__(self, width, height, title):
        super().__init__(width, height, title)

        file_path = os.path.dirname(os.path.abspath(__file__))
        os.chdir(file_path)

        arcade.set_background_color(arcade.color.AMAZON)

        self.character_list = arcade.SpriteList()
        self.character_sprite = arcade.Sprite(
            ":resources:images/animated_characters/female_person/femalePerson_idle.png",
            CHARACTER_SCALING)
        self.character_sprite.center_x = 150
        self.character_sprite.center_y = 110
        self.character_list.append(self.character_sprite)

        self.wall_list = arcade.SpriteList()
        for x in range(0, 1200, 64):
            sprite = arcade.Sprite(
                ":resources:images/tiles/boxCrate_double.png",
                CHARACTER_SCALING)
            sprite.center_x = x
            sprite.center_y = 32
            self.wall_list.append(sprite)

        self.physics_engine = arcade.PhysicsEnginePlatformer(
            self.character_sprite, self.wall_list, gravity_constant=GRAVITY)