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)
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)