"""
     Copyright (C) 2002-2003 Stas Z. <stas@linux.isbeter.nl>

 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, 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 General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program; see the file COPYING.  If not, write to
 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.

 Childsplay - A suite of educational games for young children.

  This is beta software, please send bugs and/or comments to
  childsplay@users.sourceforge.net"""


import pygame,os,sys
pygame.init()
scr = pygame.display.set_mode((800,600))

from threading import Thread
from utils import trace_error,load_image,load_music
from CPConstants import DATADIR

def splash():
    """Display a splash screen at startup.
      This runs in a seperate thread at the timeout"""
    
    T = 4000
    try:
        snd = load_music(os.path.join(DATADIR,'cows.ogg'))
        snd.play(-1)
    except pygame.error,info:
        print >> sys.stderr,info
    try:
        cow = load_image(os.path.join(DATADIR,'cowsplash.png'))
        load = load_image(os.path.join(DATADIR,'cowsplash-load.png'))
        pygame.display.update((scr.blit(cow,(300,100)),scr.blit(load,(40,20))))
    except pygame.error:
        trace_error()
        T = 1
    # Keep it alive
    pygame.time.wait(T)
    try:
        snd.stop()
    except:
        pass
 
thread = Thread(target=splash)
thread.start()

pygame.time.wait(1)
