#! /usr/bin/env python
#
"""
msg test
"""
#imports
import pygame
from pygame.locals import *

from constants import VektoroidsConstants
from game_state import GameState, Point, DummyJoy
from sound import PycadiaSound
from vector_text import Char, Message
from actor import Actor
from player import Player, Flame
from explosion import Debris, Explode
from shot import Shot
from asteroid import Asteroid
import gd_objects
from pyg_keys import GameKeys
import hiscores

if not pygame.image.get_extended():
    raise SystemExit, "Requires the extended image loading from SDL_image"
if not pygame.font: print 'Warning, fonts disabled'
if not pygame.mixer: print 'Warning, sound disabled'

_version = '0.4.0'

#
def main():
    """main vektoroids code"""
    #spacewarpy constants class
    consts = VektoroidsConstants()
    #initialize everything
    gs = GameState(consts)
    pygame.init()
    #setup display
    pygame.display.set_caption('Message Tester %s' % (_version))
    pygame.mouse.set_visible(0)
    pygame.key.set_repeat(30,30)
    clock = pygame.time.Clock()
    #get player keys
    pkeys = GameKeys()

    #create the backgound
    gs.background = pygame.Surface(gs.screen.get_size())
    gs.background = gs.background.convert()
    gs.background.fill((0, 0, 0))

    #display the background
    gs.screen.blit(gs.background, (0,0))
    pygame.display.flip()
    
    all = pygame.sprite.RenderUpdates()
    
    #
    Actor.gs = gs

    #init vector text class
    messages = pygame.sprite.Group()
    Char.containers = messages, all

    #msg 1
    Message(consts, 'Vektoroids', 3, 0, 200, 1)
    
    #msg 2
    Message(consts, 'SpaceWarpy', 3, 0, 300, 1)

    #main loop
    while 1:
        gs.dT = clock.tick(consts.FRAMES_PER_SEC)
        
        # clear/erase the last drawn sprites
        all.clear(gs.screen, gs.background)
        
        #update all the sprites
        all.update()

        #handle keys
        pygame.event.pump()
        keys=pygame.key.get_pressed()
        if keys[K_ESCAPE] or pygame.event.peek(QUIT):
            break

        #redraw the whole scene
        dirty = all.draw(gs.screen)
        pygame.display.update(dirty)


#start the ball rolling...
if __name__ == '__main__':
    main()
    
