All pastes #75431 Raw Edit

xlordt

public python v1 · immutable
#75431 ·published 2006-06-30 05:11 UTC
rendered paste body
#!/usr/bin/env pythonimport pygame, randomfrom pygame.locals import *pygame.init( )class Main( pygame.sprite.Sprite ):		def __init__ ( self ):			pygame.sprite.Sprite.__init__ ( self )						#Create the surface to be used for the ball			self.Surface = pygame.Surface( [ 10, 10 ] )			self.surfrect = self.Surface.get_rect( )						#Set the balls velocity and other options			self.v_x   = random.randint( 1, 5 )			self.v_y   = random.randint( 1, 5 )			self.radius = 5					#Lets define a few variables for later use			self.Ismoving = True			self.pixals      = 0					def DrawBall( self, color ):						self.createball = pygame.draw.circle(  self.Surface, color, ( [ 4, 6 ] ), self.radius, 0 )					def MoveBall( self, Current, Stop ):						if self.pixals < Current:								if self.Ismoving:  self.surfrect += 1				else:                   self.surfrect -= 1								if self.surfrect.bottom == Stop - 1:   self.Ismoving = False				elif self.surfrect.top == 0 + 1:         self.Ismoving = True								self.pixals = Current + 10		screen = pygame.display.set_mode( [ 150, 150 ] )_main = Main( )_main.DrawBall( [ 0, 255, 0 ] )while pygame.event.poll( ).type != pygame.KEYDOWN:				screen.fill( [ 0, 0, 0 ] )		screen.blit( _main.Surface, _main.surfrect )		                                       		pygame.display.update( )