Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(2)  |  Call(2)  |  Derive(0)  |  Import(0)

        def Make_Quake_SF_Points(off):
    # Quake fault lines must stay well away from the centre:
    # that's enforced here.
    crosses_centre = True
    (x,y) = GRID_CENTRE
    d = 7
    check = [ (x - d, y - d), (x + d, y + d),
            (x - d, y + d), (x + d, y - d) ]
    (w,h) = GRID_SIZE

    while ( crosses_centre ):
        if ( random.randint(0,1) == 0 ):
            start = (random.randint(0,w - 1), -off)
            finish = (random.randint(0,w - 1), h + off)
        else:
            start = (-off, random.randint(0,h - 1))
            finish = (h + off, random.randint(0,h - 1))

        crosses_centre = ( 
                intersect.Intersect((start, finish),
                    (check[ 0 ], check[ 1 ]))
                or intersect.Intersect((start, finish),
                    (check[ 2 ], check[ 3 ])) )
    return [start, finish]
        


src/2/0/20kly-HEAD/code/quakes.py   20kly(Download)
    def __Generate_Quake(self):
        # Make start/finish points first.
        line = extra.Make_Quake_SF_Points(2)
 
        # Split line, repeatedly, at random locations.

src/2/0/20kly-HEAD/code/storms.py   20kly(Download)
        self.storm_frame = 0
 
        [a, b] = extra.Make_Quake_SF_Points(5)
        if ( self.net.random(2) == 0 ):
            (a, b) = (b, a) # flip - ensures start point is not always on top or left