Ich habe dreimal die gleiche Schleife, diese muss aber, je nach Vorgabe, unter bestimmten Bedingungen ablaufen:
Code: Alles auswählen
            if typ3 == 1:                                                        #Spiegelachse ist Winkelhalbierende
                x0 = 0
                y0 = 0
                #hier kommt das Dreieck:
                while x1 + breite > h_breite/20 -3 or y1 + hoehe > h_hoehe/20 -6 :
                    x1 = random.randint(4,12)
                    y1 = random.randint(1,12) 
                    breite = random.randint(2,6)
                    hoehe = random.randint(2,6)
            elif typ3 == 2:                                                        #Spiegelachse parallel zur y-Achse
                x0 = random.randint(4,7)
                y0 = 0
                #hier kommt das Dreieck:
                while x1 + breite > h_breite/20 -3 or y1 + hoehe > h_hoehe/20 -6 or x1 - x0 > x0 + x_null/20:
                    x1 = random.randint(4,12)
                    y1 = random.randint(1,12) 
                    breite = random.randint(2,6)
                    hoehe = random.randint(2,6)
            elif typ3 == 3:                                                        #Spiegelachse parallel zur x-Achse
                x0 = 0
                y0 = random.randint(4,7)
                #hier kommt das Dreieck:
                while x1 + breite > h_breite/20 -3 or y1 + hoehe > h_hoehe/20 -6 or y1 - y0 > y0 + y_null/20:
                    x1 = random.randint(4,12)
                    y1 = random.randint(1,12) 
                    breite = random.randint(2,6)
                    hoehe = random.randint(2,6)