示例#1
0
def create_star(ai_settings, screen, stars, star_number, row_number):
    """Создает звезду и размещает его в ряду."""
    star = Star(ai_settings, screen)
    star_width = star.rect.width
    star.x = star_width + 4 * star_width * star_number + randint(-32, 32)
    star.rect.x = star.x
    star.rect.y = star.rect.height + 4 * star.rect.height * \
                   row_number + randint(-32,32)
    stars.add(star)
示例#2
0
def create_stars_background(ai_settings, screen, stars):
    """Create a full screen of stars"""
    star = Star(screen)

    if len(stars) < 50:
        for star_number in range(1):
            star = Star(screen)
            star.x = randint(0, ai_settings.screen_width)
            star.y = randint(0, ai_settings.screen_height)
            star.rect.x = star.x
            star.rect.y = star.y
            stars.add(star)
示例#3
0
def create_star(ai_settings, screen, stars, x_number, y_number):
    random_star = random.randint(0, 3)
    star = Star(ai_settings, screen, random_star)
    star_width = star.rect.width
    star_height = star.rect.height

    star.x = 2 * star_width * x_number + star_width * (random.randint(-8, 8) / 16 + 1)
    star.y = 2 * star_height * y_number + star_height * random.randint(0, 16) / 16

    star.rect.x = star.x
    star.rect.y = star.y
    stars.add(star)