All pastes #346340 Raw Edit

Anonymous

public text v1 · immutable
·published 2007-02-09 09:03 UTC
rendered paste body
import pygame, os, sys
from pygame.locals import*

background = os.path.join(os.path.dirname(__file__), 'starfield1.bmp')
pvel = 1

class pship:
	def __init__(self, posx, posy):
		self.posx = posx
		self.posy = posy
	
	def draw(self):
		ship = os.path.join(os.path.dirname(__file__),'pship.bmp')
		playership = pygame.image.load (ship).convert
		surface.blit(playership, (posx, posy))
	
	
def input(events):
	global posx
	for event in events:
		if event.type == QUIT:
			sys.exit(0)
		if event.type == pygame.KEYDOWN:
			if event.key == pygame.K_LEFT:
				posx = posx - pvel
			if event.key == pygame.K_RIGHT:
				posx = posx + pvel
		else:	
			print event

while True:
	#the window 
	pygame.init()
	window = pygame.display.set_mode ((800, 600))
	pygame.display.set_caption('Galaga!')
	#the background
	surface = pygame.display.get_surface()
	screen = pygame.image.load (background).convert()
	surface.blit (screen (0,0))
	
	
	#draws pship and controls movement at x, y
	pship.draw
	
	#input and screen refresh
	input (pygame.event.get())
	pygame.display.flip()