Ejemplo n.º 1
0
def gestionCollisionBonusBarres():
    global gestionCollisonBonusBarre

    for i in range(barres.nbBarre()):
        k = 0
        for j in range(bonus.nbBonus()):
            enleverBonus = gestionCollisonBonusBarre(k, i)
            if not enleverBonus:
                k += 1

    k = 0
    for i in range(bonus.nbBonus()):
        if bonus.y[k] > config.HEIGHT:
            bonus.enleverBonus(k)
        else:
            k += 1
Ejemplo n.º 2
0
def gestionCollisonBonusBarre(i, j):
    """Si il y a collision, on active le bonus"""
    global collision

    retour = False

    bonusx1 = bonus.x[i] + bonus.dx[i]
    bonusx2 = bonusx1 + bonus.w[i]
    bonusy1 = bonus.y[i] + bonus.dy[i]
    bonusy2 = bonusy1 + bonus.h[i]

    barrex1 = barres.x[j] + barres.dx[j]
    barrex2 = barrex1 + barres.w[j]
    barrey1 = barres.y[j]
    barrey2 = barrey1 + barres.h[j]

    if collision(bonusx1, bonusx2, bonusy1, bonusy2, barrex1, barrex2, barrey1, barrey2):

        retour = True

        # l'effet obtenu depend du bonus
        if bonus.bonus_contenu[i] in ["barre_agrandie", "barre_retrecie"]:
            barres.applyBonus(j, bonus.bonus_contenu[i])
            bonus.enleverBonus(i)
        elif bonus.bonus_contenu[i] == "balle_feu":
            for k in range(balles.nbBalle()):
                balles.applyBonus(k, "balle_feu")
            bonus.enleverBonus(i)
        elif bonus.bonus_contenu[i] == "ajout_balle":
            xBalle = barres.x[j] + barres.w[j] // 2 - balles.RAYON_BALLE
            yBalle = barres.y[j] + -balles.RAYON_BALLE
            dxBalle = 0
            dyBalle = -config.SPEED
            balles.ajouterBalle(xBalle, yBalle, dxBalle, dyBalle)
            bonus.enleverBonus(i)
        elif bonus.bonus_contenu[i] == "":
            bonus.enleverBonus(i)
        else:
            raise ValueError("Erreur : bonus contenant un type d bonus inconnu : " + bonus.bonus_contenu[i])

    return retour