"""
YaSS - Yet another Space Shooter
"""

import common
import pygame
from pygame.locals import *
import sys
import FpsClock
import gfx
import events
import gameplay
import player
import resources
import levels
import sounds
import highscore

def reset_all():    
    levels.nextLevel()
    gfx.setBackground()
    common.enemies = []
    common.shots_enemy = []
    common.shots_player = []
    common.misc_goodies = []
    common.misc_harmful = []
    common.misc_neutral = []    
    common.player.rect[0] = common.resolution[0]/2-15
    common.player.rect[1] = common.resolution[1]-40
    common.player.shield  = common.player.maxshield
    common.player.alive   = common.player.maxhealth

def start():
    reset_all()
    levels.showLevel()
    common.player.hide()
    common.player.show()
    common.sound.ready()    
    while pygame.mixer.get_busy():
        pygame.event.pump()
    levels.hideLevel()
    common.sound.startbgmusic()

    # Save function references for performance
    common_clock_tick = common.clock.tick
    events_handleAll = events.handleAll
    gameplay_run = gameplay.run
    common_clock_hideFpsSurface = common.clock.hideFpsSurface
        
    while not common.game_finished:
        common_clock_hideFpsSurface()
        events_handleAll()
        gameplay_run()
        common_clock_tick()

    common.sound.stopbgmusic()
