Esempio n. 1
0
def read_entity_info(entity_info):
    entity_info = entity_info.split(",")
    name = entity_info[0]
    ac = int(entity_info[1])
    hp = int(entity_info[2])
    entity = create_entity(name, ac, hp)
    return entity
Esempio n. 2
0
def generate(boonG):
    """
	G{classtree}
	DESCRIPTION
	===========
		Génère un bonus à partir d'un générateur de bonus

	PARAM
	=====
	@param boonG : le générateur de bonus qui va générer
	@type boonG : dict

	@param boonG : la grille du jeu
	@type boonG : list


	RETOUR
	======
	@return : le bonus généré
	@rtype : dict
	"""
    assert type(boonG) is dict
    assert "boonGenerator" in boonG["Type"]

    x = boonG["x"]
    y = boonG["y"]
    asset = {}
    asset["boon1"] = entity.create_asset("Boon/boon1.txt")
    asset["Actual"] = asset["boon1"]
    name = "boon" + "_" + boonG["Name"] + "_" + str(boonG["GeneLastTime"][1])
    boon = entity.create_entity(name, x, y, asset, boonG["Color"])
    boon = create_boon(boon, boonG["Bonus"])

    return boon
Esempio n. 3
0
def shoot(Entity):
    """
    G{classtree}
    DESCRIPTION
    ===========
        Permet de faire tirer une entité

    PARAM
    =====

    @param Entity: l'entité qui va tirer
    @type Entity : dict


    RETOUR

    @return ca  : une Entité correspondant au projectile tiré
    @rtype ca : dict
    """
    assert type(Entity) is dict
    assert "shootingEnt" in Entity["Type"]

    bullet_name = "bullet" + "_" + Entity["Name"] + "_" + str(nb_shot(Entity))

    if "character" in Entity["Type"]:
        posture = character.get_posture(Entity)
        pos_gun = character.position_gun(posture)
        x = pos_gun[0] + Entity["x"]
        y = pos_gun[1] + Entity["y"]

    if posture[2] in [90, -90]:
        Vx = 0
        name_asset = "Gun_Vertical"

    elif posture[1] == "Right":
        Vx = 1
        if posture[2] > 0:
            name_asset = "Gun_Slash"
        elif posture[2] < 0:
            name_asset = "Gun_UnSlash"
    else:
        Vx = -1
        if posture[2] > 0:
            name_asset = "Gun_UnSlash"
        elif posture[2] < 0:
            name_asset = "Gun_Slash"

    if posture[2] > 0:
        Vy = -1
    elif posture[2] < 0:
        Vy = 1
    else:
        Vy = 0
        name_asset = "Gun_Horizontal"

    asset = {}
    asset[name_asset] = Entity["assetShot"][name_asset]
    asset["Actual"] = Entity["assetShot"][name_asset]
    bullet = entity.create_entity(bullet_name, x, y, asset,
                                  Entity["bulletColor"])
    bullet = movingent.create_moving_ent(bullet, Vx, Vy, Entity["bulletSpeed"])
    bullet = create_bullet(bullet, Entity["damage"], Entity["Name"])

    return bullet
Esempio n. 4
0
        Vy = 1
    else:
        Vy = 0
        name_asset = "Gun_Horizontal"

    asset = {}
    asset[name_asset] = Entity["assetShot"][name_asset]
    asset["Actual"] = Entity["assetShot"][name_asset]
    bullet = entity.create_entity(bullet_name, x, y, asset,
                                  Entity["bulletColor"])
    bullet = movingent.create_moving_ent(bullet, Vx, Vy, Entity["bulletSpeed"])
    bullet = create_bullet(bullet, Entity["damage"], Entity["Name"])

    return bullet


#____Jeux de Test________________________________________________________________
if (__name__ == "__main__"):
    Name = "Asheiya"
    X = 20
    Y = 37
    Asset = {}
    Asset["position"] = ["Wait", "Right", 0]
    for Asheiya_doc in [
            "Run_Right_0", "Wait_Right_0", "Run_Left_0", "Wait_Left_0",
            "Run_Right_45", "Wait_Right_45"
    ]:  # a terme on utilisera "Asheiya_asset" ou un constructeur de txt
        Asset[Asheiya_doc] = entity.create_asset(
            "Asheiya/Asset/" + Asheiya_doc + ".txt")  #chargement Asset
    player = entity.create_entity(Name, X, Y, Asset)
Esempio n. 5
0
def Init_manche():
    """
	G{classtree}
	DESCRIPTION
	===========
		Initialise chaque manche : placement du joueur, environnement, bonus, ennemies.

	PARAM
	=====
		Sans parametre

	RETOUR
	======
		Sans retour
	"""
    #-afaire

    global manche, menu, player, allAssetGameZone, acutalAssetGameZone, Story, Shadow_background, color

    asheiyaAsset = [
        "Run_Right_0",
        "Run_Right_45",
        "Run_Right_90",
        "Run_Right_-45",
        "Run_Right_-90",
        "Run_Left_0",
        "Run_Left_45",
        "Run_Left_90",
        "Run_Left_-45",
        "Run_Left_-90",
        "Wait_Right_0",
        "Wait_Right_45",
        "Wait_Right_90",
        "Wait_Right_-45",
        "Wait_Right_-90",
        "Wait_Left_0",
        "Wait_Left_45",
        "Wait_Left_90",
        "Wait_Left_-45",
        "Wait_Left_-90",
    ]
    projectileAsset = [
        "Gun_Horizontal", "Gun_Slach", "Gun_UnSlash", "Gun_Vertical"
    ]

    if manche == 10:
        Shadow_background = hitbox.Create_ShadowBackgrond(1)
        acutalAssetGameZone = allAssetGameZone[
            "Zone_" + str(allAssetGameZone["NumZone"])]
        #on concoit le joueur___________________________________________________________________________________________________________________________

        assetPlayer = {}
        assetPlayer["position"] = [
            "Wait", "Right", 0
        ]  #correspond a sa representation : course/attente, orientation, position du bras
        for Asheiya_doc in asheiyaAsset:
            assetPlayer[Asheiya_doc] = entity.create_asset("Asheiya/Asset/" +
                                                           Asheiya_doc +
                                                           ".txt")
        assetPlayer["Actual"] = assetPlayer[assetPlayer["position"][0] + "_" +
                                            assetPlayer["position"][1] + "_" +
                                            str(assetPlayer["position"][2])]

        xPlayer = 0
        yPlayer = 0
        vxPlayer = 0
        vyPlayer = 0

        player = entity.create_entity("Asheiya Briceval", xPlayer, yPlayer,
                                      assetPlayer, color["txt"]["Yellow"])

        speedPlayer = 0.1  #deplaxcement pas seconde
        player = movingent.create_moving_ent(player, vxPlayer, vyPlayer,
                                             speedPlayer)

        lifePlayer = 18
        armorPlayer = 25
        player = livingent.create_living_ent(player, lifePlayer, armorPlayer)

        assetShot = {}
        for Shot_doc in [
                "Gun_Horizontal", "Gun_Slash", "Gun_UnSlash", "Gun_Vertical"
        ]:
            assetShot[Shot_doc] = entity.create_asset("Asheiya/Projectile/" +
                                                      Shot_doc + ".txt")

        damage = 5
        shotDelay = 3
        bulletSpeed = 0.04
        colorBullet = color["txt"]["Red"]
        player = shootingent.create_shooting_ent(player, damage, bulletSpeed,
                                                 assetShot, shotDelay,
                                                 colorBullet)

        spowerSpeed = 1  #toutes les secondes on augmente de 1 la charge du super
        spowerMax = 100  #au bout de 100 charges on peut utiliser l'ultime
        player = character.create_character(player, spowerSpeed, spowerMax)

        allEntity.append(player)

        player = movingent.tp_entity(player, 20, 37)

        #placement des bonus :  #-afair quand on les placera tous, automatiser le tout
        listeBonus = {"speedUp": 0.02, "fireRateUp": 1, "lifeUp": 5}
        xbonus = 9
        ybonus = 33
        assetBonus = {}
        assetBonus["boon1"] = entity.create_asset(
            "Boon/boon1.txt")  #-afair en sorte que les accès soient automatisé
        assetBonus["Actual"] = assetBonus["boon1"]
        boon1 = entity.create_entity(
            "boon1", xbonus, ybonus, assetBonus, color["txt"]
            ["Green"])  #-afair en sorte que leurs noms s'incrémente tout seul
        boon1 = boon.create_boon(boon1, listeBonus)

        allEntity.append(boon1)

        listeBonus = {"lifeUp": 5, "armorMaxUp": 2}
        xbonus = 9
        ybonus = 27
        assetBonus = {}
        assetBonus["boonGenerator"] = entity.create_asset(
            "Boon/boonGenerator.txt")
        assetBonus["Actual"] = assetBonus["boonGenerator"]
        geneSpeed = 2
        boong = entity.create_entity("boong1", xbonus, ybonus, assetBonus,
                                     color["txt"]["Cyan"])
        boong = boon.create_boon_generator(boong, listeBonus, geneSpeed)

        allEntity.append(boong)

        assetCristal = {}
        assetCristal["Cristal"] = entity.create_asset("Mobs/Cristal.txt")
        assetCristal["Actual"] = assetCristal["Cristal"]

        Cristal_1 = {}
        Cristal_1 = entity.create_entity(
            "Cristal_1", 42, 24, assetCristal,
            color["txt"]["Pink"])  #position x=42,y=24

        Cristal_1 = livingent.create_living_ent(
            Cristal_1, 9, 0)  #9 point de vie, 0 point d'armure
        allEntity.append(Cristal_1)

        Cristal_2 = {}
        Cristal_2 = entity.create_entity(
            "Cristal_1", 73, 36, assetCristal,
            color["txt"]["Red"])  #position x=73,y=37
        Cristal_1 = livingent.create_living_ent(
            Cristal_2, 12, 0)  #12 point de vie, 0 point d'armure
        allEntity.append(Cristal_2)

        #Story
        storyFile = "Story/Zone_1.txt"
        maxLigne = 35
        LastTime = time.time()
        Story = windows.create_story(storyFile, maxLigne, LastTime)
        # manche initialisé
        manche = 11

    if manche == 20:
        #initialiser la deuxieme manche
        manche = 21
    return