import config
import pygame

from shape import *
from point import Point


class Circle(Shape):
    def __init__(self, position, radius, rotation, color):
        Shape.__init__(self, position, rotation, color)
        self.active = True
        self.radius = radius

    def paint(self, surface):
        if not self.is_active():
            return
        else:
            self.pair = self.position.pair()
            pygame.draw.circle(surface, self.color, self.pair, self.radius)

    def getPoints(self):
        points = []
        for deg in range(config.BULLET_POINT_COUNT):
            rad = math.radians(deg)
            x = math.cos(rad) * self.radius 
            y = math.sin(rad) * self.radius 
            (px, py) = self.position.pair()
            
            points.append(Point(x+px,y+py))
        return points

    def contains(self, point):
        dist_x = self.position.x - point.x
        dist_y = self.position.y - point.y
        return dist_x*dist_x + dist_y*dist_y <= self.radius*self.radius


