#
###
# Application: Pycadia
# File:        sun.py
# Description: pycadia Sun class
# Copyright (c) 2002-2003   Andy Balcombe <http://www.anti-particle.com>
###
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Library General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#

#from math import sqrt, pi
import pygame
from pygame.locals import *

from game_state import Point
from actor import Actor
import gd_objects

class Sun(pygame.sprite.Sprite, Actor):
    """sun"""
    def __init__(self, consts, surf_size, lines, brightness, bright_change):
        Actor.__init__(self, consts, surf_size)
        pygame.sprite.Sprite.__init__(self, self.containers)
        self.consts = consts
        self.verts = gd_objects.sunVerts
        self.lines = lines
        self.scale = gd_objects.sunScale
        self.visible=1
        self.spin_deg = 0
        self.speed = Point((0.0,0.0))
        self.mass = 0
        self.brightness=brightness
        self.bright_change=bright_change
        self.pos = Point(consts.SUN_POSITION)
        self.rect.centerx = self.pos.x
        self.rect.centery = self.pos.y

    def update(self):
        #change brightness levels
        self.brightness = self.brightness + self.bright_change
        if self.brightness <= self.consts.MIN_BRIGHT: 
            self.brightness = self.consts.MIN_BRIGHT
            self.bright_change = -self.bright_change
        if self.brightness >= self.consts.MAX_BRIGHT: 
            self.brightness = self.consts.MAX_BRIGHT
            self.bright_change = -self.bright_change
        #redraw
        self.draw_obj()

