# 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: core/color.py
# RED    = Color('#FF3333')
# GREEN  = Color('#4FFF55')
# BLUE   = Color('#585EFF')
# YELLOW = Color('#EBFF55')
# PURPLE = Color('#FF55D5')
# WHITE  = Color('#FFFFFF')
# BLACK  = Color('#000000')
# COLOR_BLIND_FRAMES  = tuple(Rect(32 * i, 32, 32, 32) for i in range(4, 10))
# COLOR_BLIND_SYMBOLS = {
#                         id(RED)    : config.get_sprite(COLOR_BLIND_FRAMES[0]),
#                         id(BLUE)   : config.get_sprite(COLOR_BLIND_FRAMES[1]),
#                         id(GREEN)  : config.get_sprite(COLOR_BLIND_FRAMES[2]),
#                         id(YELLOW) : config.get_sprite(COLOR_BLIND_FRAMES[3]),
#                         id(PURPLE) : config.get_sprite(COLOR_BLIND_FRAMES[4]),
#                         id(WHITE)  : None                                    ,
#                        }
# COLOR_KEY           = config.SPRITES.get_at((0, config.SPRITES.get_height() - 1))
# LIST                = (RED, BLUE, GREEN, YELLOW, PURPLE)
# def blend_color(surface, color):
# def get_colored_objects(frames, has_alpha=True, color_blind=False, pause_frame=True):
# def _rand_color_appear(self):
# 
# Path: game/gamedata.py
# DEFAULT_LIVES = 3
# MAX_COMBO_TIME = 60  #In frames
# def clean_up():


from pygame.display import get_surface
from pygame         import Rect
from pygame         import Surface
from pygame.sprite  import GroupSingle, Sprite
from core import config
from core import color
from game import gamedata
        for j in (1, 2):
            if b.gridcell[1] + j < SIZE[1]:
            #If we're not out of bounds...
                next_blocks[0].append(blocks[b.gridcell[0]][b.gridcell[1] + j])
                #add the block below
            if b.gridcell[0] + j < SIZE[0] and b.gridcell[1] + j < SIZE[1]:
            #If we're not out of bounds...
                next_blocks[1].append(blocks[b.gridcell[0] + j][b.gridcell[1] + j])
                #add the block down and to the right
            if b.gridcell[0] + j < SIZE[0]:
            #If we're not out of bounds...
                next_blocks[2].append(blocks[b.gridcell[0] + j][b.gridcell[1]])
                #add the block to the right
            if b.gridcell[1] - j >= 0 and b.gridcell[0] + j < SIZE[0]:
            #If we're not out of bounds...
                next_blocks[3].append(blocks[b.gridcell[0]+j][b.gridcell[1]-j])
                #add the block up and to the right
        #TODO: Optimize this so the above mess is done in one loop, if possible

        for i in next_blocks:
        #For all the lists of blocks above...
            if len([1 for j in i if j and i is not j and b.color is j.color]) >= 2:
            #If there are 2+ blocks that are the same color as the first...
                match_set.update(i) #Mark these blocks as matching

        if len(match_set) >= 3:
        #If at least 3 blocks are aligned...
            _blocks_to_clear.update(match_set) #Mark these blocks for removal
            


# 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: core/color.py
# RED    = Color('#FF3333')
# GREEN  = Color('#4FFF55')
# BLUE   = Color('#585EFF')
# YELLOW = Color('#EBFF55')
# PURPLE = Color('#FF55D5')
# WHITE  = Color('#FFFFFF')
# BLACK  = Color('#000000')
# COLOR_BLIND_FRAMES  = tuple(Rect(32 * i, 32, 32, 32) for i in range(4, 10))
# COLOR_BLIND_SYMBOLS = {
#                         id(RED)    : config.get_sprite(COLOR_BLIND_FRAMES[0]),
#                         id(BLUE)   : config.get_sprite(COLOR_BLIND_FRAMES[1]),
#                         id(GREEN)  : config.get_sprite(COLOR_BLIND_FRAMES[2]),
#                         id(YELLOW) : config.get_sprite(COLOR_BLIND_FRAMES[3]),
#                         id(PURPLE) : config.get_sprite(COLOR_BLIND_FRAMES[4]),
#                         id(WHITE)  : None                                    ,
#                        }
# COLOR_KEY           = config.SPRITES.get_at((0, config.SPRITES.get_height() - 1))
# LIST                = (RED, BLUE, GREEN, YELLOW, PURPLE)
# def blend_color(surface, color):
# def get_colored_objects(frames, has_alpha=True, color_blind=False, pause_frame=True):
# def _rand_color_appear(self):
# 
# Path: game/gamedata.py
# DEFAULT_LIVES = 3
# MAX_COMBO_TIME = 60  #In frames
# def clean_up():


# Path: game/blockgrid.py
from pygame.display import get_surface
from pygame         import Rect
from pygame         import Surface
from pygame.sprite  import GroupSingle, Sprite
from core import config
from core import color
from game import gamedata

        for j in (1, 2):
            if b.gridcell[1] + j < SIZE[1]:
            #If we're not out of bounds...
                next_blocks[0].append(blocks[b.gridcell[0]][b.gridcell[1] + j])
                #add the block below
            if b.gridcell[0] + j < SIZE[0] and b.gridcell[1] + j < SIZE[1]:
            #If we're not out of bounds...
                next_blocks[1].append(blocks[b.gridcell[0] + j][b.gridcell[1] + j])
                #add the block down and to the right
            if b.gridcell[0] + j < SIZE[0]:
            #If we're not out of bounds...
                next_blocks[2].append(blocks[b.gridcell[0] + j][b.gridcell[1]])
                #add the block to the right
            if b.gridcell[1] - j >= 0 and b.gridcell[0] + j < SIZE[0]:
            #If we're not out of bounds...
                next_blocks[3].append(blocks[b.gridcell[0]+j][b.gridcell[1]-j])
                #add the block up and to the right
        #TODO: Optimize this so the above mess is done in one loop, if possible

        for i in next_blocks:
        #For all the lists of blocks above...
            if len([1 for j in i if j and i is not j and b.color is j.color]) >= 2:
            #If there are 2+ blocks that are the same color as the first...
                match_set.update(i) #Mark these blocks as matching

        if len(match_set) >= 3:
        #If at least 3 blocks are aligned...
            _blocks_to_clear.update(match_set) #Mark these blocks for removal
            


    if gamedata.combo_time: