import settings
import pygame
import random
import variables


class Star(object):

    def __init__(self):
        color = ['Red', 'Orange', 'Yellow']
        self.x = random.randint(settings.SCREEN_WIDTH, settings.SCREEN_WIDTH * 2)
        self.y = random.randint(0, settings.SCREEN_HEIGHT)
        self.color = color[random.randint(0, len(color) - 1)]
        self.speed = random.uniform(0, settings.MAX_STAR_SPEED)

    def move(self):
        self.x -= self.speed

    def render(self):
        pygame.draw.circle(variables.screen, self.color, (self.x, self.y), self.speed / 2)


class Stars(object):

    def __init__(self, count):
        self.count = count
        self.stars = []

    def update(self):
        for star in self.stars:
            if star.x < -100:
                self.stars.remove(star)
                continue
            else:
                star.move()
                star.render()
        while len(self.stars) < self.count:
            self.stars.append(Star())


