#! /usr/bin/python

#             star.py
# This sets a simple star image bouncing around a window,
# exiting when the user closes the window

# include some core python modules that we'll need later
import sys, pygame

# initialization values
pygame.init()   # initialize PyGame
size = width, height = 320,240 # our window dimensions will be 320x240 pixels
colourBlack = 0, 0, 0 # black is represented with RGB colour values of 0,0,0

# open a display window with the dimensions set above
screen = pygame.display.set_mode(size)

# load the image of the "ball" (a star)
ballImage = pygame.image.load("../images/star.gif")

# grab a box around the ball (used for display updates and collision detection)
ballBox = ballImage.get_rect()

# have a flag to tell us to keep playing (or not)
keepPlaying = True

# repeat until player has chosen to quit
while keepPlaying:
    
    # check any keypresses, mouseclicks, etc that have taken place,
    # and see if the user has clicked on the close window box
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            keepPlaying = False

    # redraw the background and the ball when necessary
    screen.fill(colourBlack)            # clear the background by filling with black
    screen.blit(ballImage, ballBox)   # update the ball's image
    pygame.display.flip()         # redraw the display

# the loop has ended, time to exit
sys.exit()
  
