#! /usr/bin/python

print "Game console initialized"

import pygame
pygame.init()

screenSize = width,height = 240,180
display = pygame.display.set_mode(screenSize)

starImage = pygame.image.load("star.gif")
starBox = starImage.get_rect()

starImage2 = pygame.image.load("star.gif")
starBox2 = starImage2.get_rect()

keepPlaying = True
speed = [10,5]
speed2 = [5,10]
while keepPlaying:

	# see if it's time to end the game
	for event in pygame.event.get():
		# did someone click the X to close the window?
		if event.type == pygame.QUIT:
			keepPlaying = False

	# redraw the background
	black = 0,0,0
	display.fill(black)

	# draw the stars on the screen
	starBox = starBox.move(speed)
	starBox2 = starBox2.move(speed2)

	# update their speed, changing direction if needed
	if starBox.left < 0 or starBox.right > width:
		speed[0] = - speed[0]
	if starBox.top < 0 or starBox.bottom > height:
		speed[1] = - speed[1]
	if starBox2.left < 0 or starBox2.right > width:
		speed2[0] = - speed2[0]
	if starBox2.top < 0 or starBox2.bottom > height:
		speed2[1] = - speed2[1]

	# see if they collide, print BOOM on the console if they do
	collide = True
	if starBox.left > starBox2.right:
		collide = False
	elif starBox.right < starBox2.left:
		collide = False
	elif starBox.top > starBox2.bottom:
		collide = False
	elif starBox.bottom < starBox2.top:
		collide = False
	else:
		print "Boom!"

	# update the display
	display.blit(starImage, starBox)
	display.blit(starImage2, starBox2)
	pygame.display.flip()
	pygame.time.delay(100)

