#imports libraries import pygame, os, sys from pygame.locals import * #variables a = 0 background = os.path.join(os.path.dirname(__file__), 'starfield1.bmp') #player ship graphic ship = os.path.join(os.path.dirname(__file__), 'pship.bmp') #enemy ship graphic eship = os.path.join(os.path.dirname(__file__), 'eship.bmp') lives = 3 printlives = 'Lives:' pygame.init() #the window window = pygame.display.set_mode ((800, 600)) pygame.display.set_caption('Galaga!') surface = pygame.display.get_surface() #creating the surface screen = pygame.image.load (background).convert() #create player ship playership = pygame.image.load (ship).convert() #create enemy ship enemyship = pygame.image.load (eship).convert() #to print "lives:" in botom left hand corner and update the number of lives the player has #NOT WORKING def lives(lives): surface.blit (printlives, (600,0)) #play position variables sposx = 374 sposy = 512 #enemy position variable eposx = 10 eposy = 55 #initializes the clock clock = pygame.time.Clock() #Draws the players ship on the surface and controls movement of the ship and fireing def pship(sposx, sposy): surface.blit (playership, (sposx, sposy)) return sposx, sposy #draws the enemy ship on the surface and controls movement def eship(eposx, eposy): surface.blit (enemyship, (eposx, eposy)) return eposx, eposy def emove(): global eposx clock.tick(40) if eposx < 800: eposx = eposx + 10 def input(events): global sposx for event in events: if event.type == QUIT: sys.exit(0) if event.type == pygame.KEYDOWN: if event.key == pygame.K_LEFT: sposx = sposx - 10 if event.key == pygame.K_RIGHT: sposx = sposx + 10 else: print event while True: surface.blit (screen, (10,0)) pship(sposx, sposy) eship(eposx, eposy) emove() input (pygame.event.get()) pygame.display.flip()