All pastes #366503 Raw Edit

Anonymous

public text v1 · immutable
#366503 ·published 2007-02-21 18:39 UTC
rendered paste body
#Galaga Version .02
#2007-02-20 Derek Mcdonald
#################################################################################################################

#import pygame os and sys libraries
import pygame, os, sys
from pygame.locals import*
#################################################################################################################

#define global variables
x = 400
y = 50
ex = 400
ey = 550

#initialize pygame
pygame.init()

#create window and set up background image
window = pygame.display.set_mode ((800, 600))
pygame.display.set_caption('Galaga!')
surface = pygame.display.get_surface()
background = os.path.join(os.path.dirname(__file__), 'starfield1.bmp')
screen = pygame.image.load (background).convert()
surface.blit (screen, (10,0))


#define function to draw and move the player ship on X, Y plane
def pship(x,y):
	ship = os.path.join(os.path.dirname(__file__), 'pship.bmp')
	playership = pygame.image.load (ship).convert()
	surface.blit (playership, (x, y))
	return x, y
	
#Define function to draw and move the enemy ship on X, Y plane
def eship(ex,ey):
	eship = os.path.join(os.path.dirname(__file__), 'eship.bmp')
	enemyship = pygame.image.load (eship).convert()
	surface.blit (enemyship, (ex, ey))

#Define function to control fire the player weapon when fire command is issued

#Define function to get input and controll exit commands fire command and movement of playership
def input(events):
	for event in events:
		if event.type == QUIT:
			sys.exit(0)
		if event.type == pygame.KEYDOWN:
			if event.key == pygame.K_LEFT:
				x = x - 10
			if event.key == pygame.K_RIGHT:
				x = x + 10
		else:
			print event

##################################################################################################################

#start loop
while True:



	#initiate player ship function
	pship(x,y)

	#initiate enemy ship function
	eship(ex,ey)

	#initiate input function
	input (pygame.event.get())

	#iterate loop
	pygame.display.flip()