Beispiel #1
0
 def _create_steady_rain(self, row_number, drop_number):
     rain = Drop(self)
     rain_width, rain_height = rain.rect.size
     rain.x = rain_width * drop_number
     rain.rect.x = rain.x
     rain.rect.y = rain_height * row_number
     self.drops.add(rain)
def create_drop(ai_settings, screen, drops, drop_number):
    drop = Drop(ai_settings, screen)
    drop_width = drop.rect.width
    randomx = randint(-drop_width, drop_width)
    drop.x = drop_width + 2 * drop_width * drop_number + randomx
    drop.rect.top = -2 * drop.rect.height
    drop.rect.x = drop.x
    drops.add(drop)
Beispiel #3
0
def create_drop(ai_settings, screen, drops, drop_number, row_number):
    """Создание капли и размещение её в ряду"""
    drop = Drop(ai_settings, screen)
    drop_width = drop.rect.width
    drop.x = drop_width + 2 * drop_width * drop_number
    drop.rect.x = drop.x
    drop.rect.y = drop.rect.height + 2 * drop.rect.height * row_number
    drops.add(drop)
Beispiel #4
0
def create_drop(d_settings, screen, drops, drop_number, row_number):
    """Создаёт каплю и размещает её в ряду."""
    drop = Drop(d_settings, screen)
    drop_width = drop.rect.width
    drop.x = drop_width + 2 * drop_width * drop_number
    drop.rect.x = drop.x
    drop.rect.y = drop.rect.height + 2 * drop.rect.height * row_number
    drops.add(drop)
Beispiel #5
0
def create_row_drops(ai_settings, screen, drops, row_number):
    drop = Drop(ai_settings, screen)
    number_drops_x = get_number_drops(ai_settings, drop.rect.width)
    for drop_number in range(number_drops_x):
        drop = Drop(ai_settings, screen)
        drop_width = drop.rect.width
        drop.x = drop_width + 2 * drop_width * drop_number
        drop.rect.x = drop.x
        drop.rect.y = 0
        drops.add(drop)
def create_raindrops(screen, number_rows, number_drops, drops):
    """Generate all raindrops."""
    for row in range(number_rows):
        for drop_num in range(number_drops):
            # Create new instance of Drop
            drop = Drop(screen)
            drop_width = drop.rect.width
            drop.x = drop_width + (2 * drop_width * drop_num)
            drop.rect.x = drop.x
            drop.rect.y = drop.rect.height + (2 * drop.rect.height * row)
            drops.add(drop)
Beispiel #7
0
def update_edge_drops(d_settings, screen, drops, deleted_storage_drops):
    for drop in drops:
        if drop.rect.top >= 800:
            deleted_storage_drops.append(drop)
            drops.remove(drop)

            number_drops_x = get_number_drops_x(d_settings, drop.rect.width)

            if len(deleted_storage_drops) == number_drops_x:
                for drop_number in range(number_drops_x):
                    # Создание капли и размещение ёё в ряду.
                    drop = Drop(d_settings, screen)
                    drop_width = drop.rect.width
                    drop.x = drop_width + 2 * drop_width * drop_number
                    drop.rect.x = drop.x
                    drops.add(drop)
                del deleted_storage_drops[:]
    print(len(drops))