# Path: core/config.py
# def get_sprite(frame):
# def load_image(name):
# def load_sound(name):
# def load_text(name, lang):
# def loop_sound(sound):
# def on_off(condition):
# def percent_str(var):
# def play_music(name):
# def set_volume():
# def init_music_volume():
# def show_fps():
# def take_screenshot():
# def toggle_frame_limit():
# def toggle_fullscreen():
# def toggle_pause():
#     def __init__(self, *keys):
# APP_DATA_WIN = 'APPDATA'
# APP_DATA_LIN = 'HOME'
# BLIT_FLAGS    = HWSURFACE | HWACCEL | ASYNCBLIT | RLEACCEL
# CURSOR_BEEP   = load_sound('cursor.wav')
# CURSOR_SELECT = load_sound('select.wav')
# DATA_STORE    = join(environ[APP_DATA_WIN if 'win' in sys.platform else APP_DATA_LIN], 'Invasodado')
# DEBUG         =  __debug__ and not hasattr(sys, 'frozen') #cx_freeze adds 'frozen' to the sys module
# DEPTH         = 8
# EARTH         = load_image('earth.png')
# ENCODING      = 'utf-8'
# EVENTS_OK     = (KEYDOWN, MOUSEBUTTONDOWN, QUIT)
# FONT          = pygame.font.Font(join('gfx', 'font.ttf'), 18)
# FULL_FLAGS    = FULLSCREEN | HWSURFACE | DOUBLEBUF
# GRID_BG       = load_image('bg.png')
# ON_OFF        = {
#                  'en' : ("Off", "On"),
#                  'es' : ("No" , "Sí"),
#                 }
# PAUSE         = load_sound('pause.wav')
# SCREEN_DIMS   = tuple(pygame.display.list_modes())
# SCREEN_HEIGHT = screen.get_height()
# SCREEN_RECT   = Rect((0, 0), screen.get_size())
# SCREEN_WIDTH  = screen.get_width()
# SPRITES       = load_image('sprites.png')
# EARTH = EARTH.subsurface(Rect(0, 0, EARTH.get_width(), EARTH.get_height() / 2))
# class Enum:
# 
# Path: game/gameobject.py
# class GameObject(Sprite, object):
#     '''
#     @invariant: self.state in self.__class__.STATES
#     @
#     '''
#     actions    = None
#     collisions = None
#     group      = None
# 
#     def __init__(self):
#         Sprite.__init__(self)
#         self.acceleration = [0.0, 0.0]
#         self.next_state   = None
#         self.position     = [-300.0, -300.0]
#         self.rect         = None
#         self.state        = None
#         self.velocity     = [0.0, 0.0]
# 
#     def on_collide(self, other):
#         '''
#         Reacts based on the type of the other object.
#         
#         @param other: The object that we collided with.
#         @type other: A subclass of GameObject
#         '''
#         other_type = other.__class__
#         collisions = self.collisions
#         if isinstance(collisions, dict):
#         #If this object can interact with more than one other type...
#             if other_type in collisions and callable(collisions[other_type]):
#             #If we can interact with the other object...
#                 collisions[other_type](self, other)
# 
#     def update(self):
#         '''
#         Acts on this object's current state.
#         '''
#         assert self.state in self.__class__.actions, \
#         "A %s tried to act on an invalid state %s!" % (self, self.state)
# 
#         method_name = self.__class__.actions[self.state]
#         if method_name and callable(getattr(self, method_name)):
#         #If this key has a function for its element...
#             getattr(self, method_name)()
#             
#     def change_state(self, next_state):
#         '''
#         Queues this object for a state change in the next frame.
#         
#         @param next_state: The state to switch to, in type(self).STATES.
#         @type next_state: The values used in config.Enum to represent constants
#         '''
#         self.next_state = next_state
#         _state_changes.add(self)


from functools import partial
from itertools import filterfalse
from random    import uniform
from pygame import Rect
from core            import config
from game.gameobject import GameObject



### Constants ##################################################################
GRAVITY         = 0.5
PARTICLE_STATES = ('IDLE', 'APPEARING', 'ACTIVE', 'LEAVING')
################################################################################

### Functions ##################################################################
def _p_move(self):
    '''
    Moves this Particle a little bit this frame.
    '''
    position = self.position
    velocity = self.velocity

    velocity[1]      += self.acceleration[1]
    position[0]      += velocity[0]
    position[1]      += velocity[1]
    self.rect.topleft = (position[0] + .5, position[1] + .5)
    
def _p_appear(self):
    '''
    Initializes the location and velocity for this Particle.
    '''
    self.acceleration[1] = GRAVITY
    self.velocity        = [uniform(-5, 5), uniform(-1, -3)]
################################################################################


# Path: core/config.py
# def get_sprite(frame):
# def load_image(name):
# def load_sound(name):
# def load_text(name, lang):
# def loop_sound(sound):
# def on_off(condition):
# def percent_str(var):
# def play_music(name):
# def set_volume():
# def init_music_volume():
# def show_fps():
# def take_screenshot():
# def toggle_frame_limit():
# def toggle_fullscreen():
# def toggle_pause():
#     def __init__(self, *keys):
# APP_DATA_WIN = 'APPDATA'
# APP_DATA_LIN = 'HOME'
# BLIT_FLAGS    = HWSURFACE | HWACCEL | ASYNCBLIT | RLEACCEL
# CURSOR_BEEP   = load_sound('cursor.wav')
# CURSOR_SELECT = load_sound('select.wav')
# DATA_STORE    = join(environ[APP_DATA_WIN if 'win' in sys.platform else APP_DATA_LIN], 'Invasodado')
# DEBUG         =  __debug__ and not hasattr(sys, 'frozen') #cx_freeze adds 'frozen' to the sys module
# DEPTH         = 8
# EARTH         = load_image('earth.png')
# ENCODING      = 'utf-8'
# EVENTS_OK     = (KEYDOWN, MOUSEBUTTONDOWN, QUIT)
# FONT          = pygame.font.Font(join('gfx', 'font.ttf'), 18)
# FULL_FLAGS    = FULLSCREEN | HWSURFACE | DOUBLEBUF
# GRID_BG       = load_image('bg.png')
# ON_OFF        = {
#                  'en' : ("Off", "On"),
#                  'es' : ("No" , "Sí"),
#                 }
# PAUSE         = load_sound('pause.wav')
# SCREEN_DIMS   = tuple(pygame.display.list_modes())
# SCREEN_HEIGHT = screen.get_height()
# SCREEN_RECT   = Rect((0, 0), screen.get_size())
# SCREEN_WIDTH  = screen.get_width()
# SPRITES       = load_image('sprites.png')
# EARTH = EARTH.subsurface(Rect(0, 0, EARTH.get_width(), EARTH.get_height() / 2))
# class Enum:
# 
# Path: game/gameobject.py
# class GameObject(Sprite, object):
#     '''
#     @invariant: self.state in self.__class__.STATES
#     @
#     '''
#     actions    = None
#     collisions = None
#     group      = None
# 
#     def __init__(self):
#         Sprite.__init__(self)
#         self.acceleration = [0.0, 0.0]
#         self.next_state   = None
#         self.position     = [-300.0, -300.0]
#         self.rect         = None
#         self.state        = None
#         self.velocity     = [0.0, 0.0]
# 
#     def on_collide(self, other):
#         '''
#         Reacts based on the type of the other object.
#         
#         @param other: The object that we collided with.
#         @type other: A subclass of GameObject
#         '''
#         other_type = other.__class__
#         collisions = self.collisions
#         if isinstance(collisions, dict):
#         #If this object can interact with more than one other type...
#             if other_type in collisions and callable(collisions[other_type]):
#             #If we can interact with the other object...
#                 collisions[other_type](self, other)
# 
#     def update(self):
#         '''
#         Acts on this object's current state.
#         '''
#         assert self.state in self.__class__.actions, \
#         "A %s tried to act on an invalid state %s!" % (self, self.state)
# 
#         method_name = self.__class__.actions[self.state]
#         if method_name and callable(getattr(self, method_name)):
#         #If this key has a function for its element...
#             getattr(self, method_name)()
#             
#     def change_state(self, next_state):
#         '''
#         Queues this object for a state change in the next frame.
#         
#         @param next_state: The state to switch to, in type(self).STATES.
#         @type next_state: The values used in config.Enum to represent constants
#         '''
#         self.next_state = next_state
#         _state_changes.add(self)


# Path: core/particles.py
from functools import partial
from itertools import filterfalse
from random    import uniform
from pygame import Rect
from core            import config
from game.gameobject import GameObject




### Constants ##################################################################
GRAVITY         = 0.5
PARTICLE_STATES = ('IDLE', 'APPEARING', 'ACTIVE', 'LEAVING')
################################################################################

### Functions ##################################################################
def _p_move(self):
    '''
    Moves this Particle a little bit this frame.
    '''
    position = self.position
    velocity = self.velocity

    velocity[1]      += self.acceleration[1]
    position[0]      += velocity[0]
    position[1]      += velocity[1]
    self.rect.topleft = (position[0] + .5, position[1] + .5)
    
def _p_appear(self):
    '''
    Initializes the location and velocity for this Particle.
    '''
    self.acceleration[1] = GRAVITY
    self.velocity        = [uniform(-5, 5), uniform(-1, -3)]
################################################################################


class Particle(GameObject):