Esempio n. 1
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. 2
0
    def setup(self):
        """ Set up the game here. Call this function to restart the game. """
        # score
        self.score = 0
        self.keys = 0

        # track scrolling
        self.view_bottom = 0
        self.view_left = 0

        self.player_list = arcade.SpriteList()
        self.wall_list = arcade.SpriteList()
        self.coin_list = arcade.SpriteList()
        self.background_list = arcade.SpriteList()
        self.key_list = arcade.SpriteList()
        self.enemies_list = arcade.SpriteList()
        self.boss_list = arcade.SpriteList()

        # setup player
        image_source = "images/timmy_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)

        # setup bertwam
        self.boss_sprite = arcade.Sprite("images/bertwam_idle.png", CHARACTER_SCALING)
        self.boss_sprite.center_x = 64
        self.boss_sprite.center_y = 128
        self.boss_list.append(self.boss_sprite)

        # load map from file
        map_name = "maps/level_1.tmx"

        # map and layers
        the_map = arcade.read_tmx(map_name)
        platform_layer = "platforms"
        coins_layer = "coins"
        keys_layer = "keys"
        enemies_layer = "enemies"
        self.wall_list = arcade.tilemap.process_layer(map_object=the_map, layer_name=platform_layer,
                                                      scaling=TILE_SCALING, use_spatial_hash=True)

        self.coin_list = arcade.tilemap.process_layer(map_object=the_map, layer_name=coins_layer,
                                                      scaling=TILE_SCALING, use_spatial_hash=True)

        self.key_list = arcade.tilemap.process_layer(map_object=the_map, layer_name=keys_layer,
                                                     scaling=TILE_SCALING, use_spatial_hash=True)

        self.enemies_list = arcade.tilemap.process_layer(map_object=the_map, layer_name=enemies_layer,
                                                         scaling=TILE_SCALING, use_spatial_hash=True)

        # -- Background objects
        self.background_list = arcade.tilemap.process_layer(the_map, "background", TILE_SCALING)

        # environmental stuffs
        if the_map.background_color:
            arcade.set_background_color(the_map.background_color)

        self.physics_engine = arcade.PhysicsEnginePlatformer(self.player_sprite, self.wall_list, GRAVITY)
Esempio n. 3
0
    def __init__(self, width, height, title):
        super().__init__(width, height, title)
        self.center_window()

        map = arcade.read_tmx("my_maps/platformer-map.tmx")
        self.talaj = arcade.tilemap.process_layer(map, "Talaj")
        self.dobozok = arcade.tilemap.process_layer(map, "dobozok")
Esempio n. 4
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")
        self.egyeb = arcade.tilemap.process_layer(map, "egyeb")
    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.player = arcade.Sprite("my-sprites/greene.png", center_x=100, center_y=300)

        self.physics = arcade.PhysicsEnginePlatformer(self.player, self.talaj, gravity_constant=GRAVITY)
    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)

        # Példányosítjuk a Player osztályt.
        self.player = Player()

        self.physics = arcade.PhysicsEnginePlatformer(self.player,
                                                      self.talaj,
                                                      gravity_constant=GRAVITY)
    def __init__(self, width, height, title, resizable=True):
        super().__init__(width, height, title, resizable=True)
        self.center_window()

        map = arcade.read_tmx("my_maps/platformer-map.tmx")
        self.talaj = arcade.tilemap.process_layer(map,
                                                  "Talaj",
                                                  use_spatial_hash=True)
        self.dobozok = arcade.tilemap.process_layer(map,
                                                    "dobozok",
                                                    use_spatial_hash=True)
        self.szalag = arcade.tilemap.process_layer(map,
                                                   "szalag",
                                                   use_spatial_hash=True)

        self.player = arcade.Sprite("my_sprites/greene.png",
                                    center_x=100,
                                    center_y=175)

        self.physics = arcade.PhysicsEnginePlatformer(self.player,
                                                      self.talaj,
                                                      gravity_constant=GRAVITY)
    def setup(self, niveau=1):
        """ Configurer le jeu ici. Appeler cette fonction pour (re)démarrer le jeu."""

        self.niveau = niveau
        # Sprite: Image animée
        # SpriteList: Groupement d'images animées
        self.personnages = arcade.SpriteList()

        # Sprite pour le personnage
        self.personnage = Personnage()
        # positionner le personnage dans la fenêtre (pixel)
        self.personnage.center_x = 64
        self.personnage.center_y = 128
        # l'ajouter à sa SpriteList
        self.personnages.append(self.personnage)

        # Utilisation d'une carte (tilemap)
        carte = arcade.read_tmx(":resources:tmx_maps/map_with_ladders.tmx")
        # extraction des calques
        # ouvrir le fichier tmx avec Tiled pour en prendre connaissance ...
        # (voir fichier joint «resources.zip»)
        self.pieces = arcade.process_layer(
            carte,
            "Coins",
            scaling=ECHELLE_TUILE,  # options
            use_spatial_hash=True
        )
        self.plateformes = arcade.process_layer(
            carte,
            "Platforms",
            scaling=ECHELLE_TUILE,  # options
            use_spatial_hash=True
        )
        self.arriere_plan = arcade.process_layer(
            carte,
            "Background",
            scaling=ECHELLE_TUILE,
            use_spatial_hash=True
        )
        self.echelles = arcade.process_layer(
            carte,
            "Ladders",
            scaling=ECHELLE_TUILE,
            use_spatial_hash=True
        )
        plateformes_mobiles = arcade.process_layer(
            carte,
            "Moving Platforms",
            scaling=ECHELLE_TUILE
        )
        # Ce sont des plateformes donc ...
        for plateforme in plateformes_mobiles:
            self.plateformes.append(plateforme)

        self.x_max_carte = carte.map_size.width * carte.tile_size.width * ECHELLE_TUILE

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

        # Configurer le «moteur physique»
        # attention: on passe de `PhysicsEngineSimple` à `PhysicsEnginePlatformer`
        self.physics_engine = arcade.PhysicsEnginePlatformer(
            self.personnage,  # personnage
            self.plateformes,  # obstacles ou sols
            gravity_constant=GRAVITE,  # force de la gravité
            ladders=self.echelles
        )

        self.xmin = 0
        self.ymin = 0
    def setup(self, nivel, puntaje, vida):

        #Listas  del juego
        self.jugador_lista = arcade.SpriteList()
        self.obstaculos_lista = arcade.SpriteList(use_spatial_hash=True)
        self.monedas_lista = arcade.SpriteList(use_spatial_hash=True)
        self.muerte_lista = arcade.SpriteList(use_spatial_hash=True)
        self.fondo_lista = arcade.SpriteList(use_spatial_hash=True)
        self.banderas_lista = arcade.SpriteList(use_spatial_hash=True)
        # Usados para el desplazamiento de la "camara"
        self.vista_abajo = 0
        self.vista_izquierda = 0
        # Puntaje del juego
        self.puntaje = puntaje
        # Vidas
        self.vidas = vida
        #Animar el presonaje
        self.jugador_sprite = PlayerCharacter()
        self.jugador_sprite.center_x = 32
        self.jugador_sprite.center_y = 200
        self.jugador_lista.append(self.jugador_sprite)
        """
        #Crear el suelo
        for x in range(0,1500,64):
            suelo=arcade.Sprite(":resources:images/tiles/stoneMid.png", escalaObstaculos)
            suelo.center_x=x
            suelo.center_y=32
            self.obstaculos_lista.append(suelo)
        

        #Crear plataformas
        for x in range(500,565,64):
            suelo=arcade.Sprite(":resources:images/tiles/stoneMid.png", escalaObstaculos)
            suelo.center_x=x
            suelo.center_y=253
            self.obstaculos_lista.append(suelo)
        """
        """
        #Crear lava
        for x in range(532,600,64):
            suelo=arcade.Sprite(":resources:images/tiles/lavaTop_high.png", escalaObstaculos)
            suelo.center_x=x
            suelo.center_y=37
            self.lava_lista.append(suelo)   

        """
        """
        #Lista con la posicion de las cajas 
        posicionCajas_lista=[[512, 96],[256, 96],[768, 96]]
        #Poner cajas en el juego
        for coordenadas in posicionCajas_lista:
            cajas=arcade.Sprite(":resources:images/tiles/boxCrate_double.png", escalaObstaculos)
            cajas.position=coordenadas
            self.obstaculos_lista.append(cajas)
        """
        """

        # Monedas en el juego
        for x in range(128, 1250, 256):
            moneda = arcade.Sprite(":resources:images/items/coinGold.png", escalaMonedas)
            moneda.center_x = x
            moneda.center_y = 96
            self.monedas_lista.append(moneda)

        """

        #Cargar plataformas del mapa tmx
        if nivel == 1:
            map_name = "mapa_1.tmx"
            arcade.set_background_color(arcade.csscolor.DARK_SLATE_GREY)
        elif nivel == 2:
            map_name = "mapa_2.tmx"
            arcade.set_background_color(arcade.csscolor.DARK_SALMON)
        elif nivel == 3:
            map_name = "mapa_3.tmx"
            arcade.set_background_color(arcade.csscolor.CORNFLOWER_BLUE)

        platforms_layer_name1 = 'plataform'
        mi_mapa = arcade.read_tmx(map_name)
        self.obstaculos_lista = arcade.tilemap.process_layer(
            map_object=mi_mapa,
            layer_name=platforms_layer_name1,
            scaling=escalaObstaculos,
            use_spatial_hash=True)

        #Cargar las monedas del mapa tmx
        monedas_layer_name = 'monedas'
        self.monedas_lista = arcade.tilemap.process_layer(
            map_object=mi_mapa,
            layer_name=monedas_layer_name,
            scaling=escalaMonedas,
            use_spatial_hash=True)

        #Cargar elemento instakill del mapa tmx
        lava_layer_name = 'kill'
        self.muerte_lista = arcade.tilemap.process_layer(
            map_object=mi_mapa,
            layer_name=lava_layer_name,
            scaling=escalaObstaculos,
            use_spatial_hash=True)

        #Cargar bandera del mapa tmx
        bandera_layer_name = 'Terminar'
        self.banderas_lista = arcade.tilemap.process_layer(
            map_object=mi_mapa,
            layer_name=bandera_layer_name,
            scaling=escalaObstaculos,
            use_spatial_hash=True)

        #Cargar elementos del fondo  del mapa tmx
        fondo_layer_name = 'fondo'
        self.fondo_lista = arcade.tilemap.process_layer(
            mi_mapa, fondo_layer_name, escalaObstaculos)

        #Iniciar las físicas del juego
        self.motor_fisica = arcade.PhysicsEnginePlatformer(
            self.jugador_sprite, self.obstaculos_lista, gravedad)