예제 #1
0
	def __init__(self,
	title = TITLE, 
	x = WINDOW_X, 
	y = WINDOW_Y, 
	bgcolor = BGCOLOR, 
	colordict = COLORDICT,
	wordbank = WORD_BANK,
	scramble_speed = SCRAMBLE_SPEED,
	word_min = WORD_MIN_SIZE,
	word_max = WORD_MAX_SIZE,
	font = FONT,
	fontsize = FONT_SIZE
	):
		self.title = title
		self.x_window = x
		self.y_window = y
		self.bgcolor = bgcolor
		self.colordict = colordict
		self.wordbank = wordbank
		self.scramble_speed = scramble_speed
		self.word_min_size = word_min
		self.word_max_size = word_max
		self.fonttype = font
		self.fontsize = fontsize
		
		self.AA = 0
		self.screen = pygame.display.set_mode((self.x_window, self.y_window))
		
		self.story_iterator = worddata.storytime()
예제 #2
0
	def __init__(self,
	author = AUTHOR,
	title = TITLE, 
	x = WINDOW_X, 
	y = WINDOW_Y, 
	bgcolor = BGCOLOR, 
	colordict = COLORDICT,
	wordbank = WORD_BANK,
	scramble_speed = SCRAMBLE_SPEED,
	word_min = WORD_MIN_SIZE,
	word_max = WORD_MAX_SIZE,
	font = FONT,
	fontsize = FONT_SIZE
	):
		
		"""
	Takes on the parameters from the setup.py and places them in to the 
	ThaneBit object. 
	"""
		self.author = author
		self.title = title
		self.x_window = x
		self.y_window = y
		self.bgcolor = bgcolor
		self.colordict = colordict
		self.wordbank = wordbank
		self.scramble_speed = scramble_speed
		self.word_min_size = word_min
		self.word_max_size = word_max
		self.fonttype = font
		self.fontsize = fontsize
		
		self.AA = 0
		self.screen = pygame.display.set_mode((self.x_window, self.y_window))
		
		self.story_iterator = worddata.storytime()
예제 #3
0
def main():

	global FPSCLOCK, DISPLAYSURF, BASICFONT
	mysterious_line = worddata.storytime()
	
	###Title ###//////////FOR OPTOMIZE: Get all this into different functions, using parameters as arguments
										#Better yet, get these into self contained function calls since behavior is finite.
	pygame.init()
	screen = pygame.display.set_mode((WINDOW_X,WINDOW_Y))
	pygame.display.set_caption("Word Game")
	print screen.get_size
	
	wking_background = BGCOLOR #Set this to a variable so when it needs to
								# refresh it can keep colors consistent even
								# when we start randomly changing it.
	
	background = pygame.Surface(screen.get_size())
	backgroundspec = background.convert()
	backgroundspec = background.fill((wking_background))
	
	# font declarations
	font = pygame.font.Font("Courier_New.ttf", 100)
	subfont = pygame.font.Font(None, 25)
	
	# Text definition and positional info
	
	text = font.render("WORD GAME", 0, PINK)
	textpos = text.get_rect()
	textpos.centerx = background.get_rect().centerx
	textpos.centery = background.get_rect().centery
	
	# Sub-Text definition and positional info
	sub_txt = subfont.render("?? Copyright -- THANE LUND 1983 ??", 0, (0,250,250))
	sub_txt_pos = sub_txt.get_rect()
	sub_txt_pos.y = 500
	sub_txt_pos.x = (WINDOW_X/3)
	
	# Sets the bits in the background surface
	background.blit(text,textpos)
	background.blit(sub_txt, sub_txt_pos) 
	
	###Clear variables.... May need more of this for optomization?
	#del sub_txt_pos, sub_txt, 

	# Sets the 
	screen.blit(background, backgroundspec)
	print pygame.display.flip()
	pygame.display.flip()

	def RandomizeScreen(): ###If this was in a class we could share data without putting a func inside another 
		
		wking_background = ReturnRandomColor()
		backgroundspec = background.fill(wking_background)
		text = font.render(ReturnRandomWord(),0, ReturnRealRandomColor())
		textpos.x = random.randint(0,WINDOW_X-100)	
		textpos.y = random.randint(0,WINDOW_Y-100)
		
		background.blit(text,textpos)
		screen.blit(background, backgroundspec)
		pygame.display.flip()

	  ###########
	###MAIN LOOP###	
	  ###########
	
	while True:
		for event in pygame.event.get():
			print event
			
			if event.type == QUIT:
				return
			
			if event.type == KEYDOWN:
		
				keys = pygame.key.get_pressed()
			
				
				###RAPID COURSE
				
				
				
				if keys[K_q] and (keys[K_RCTRL] or keys[K_LCTRL]):
					terminate()
				
				elif keys[K_z] and keys[K_SPACE]:
					
					wking_background = BGCOLOR 
					
					background = pygame.Surface(screen.get_size())
					backgroundspec = background.convert()
					backgroundspec = background.fill((wking_background))
					
					font = pygame.font.Font("Courier_New.ttf", 100)
					subfont = pygame.font.Font(None, 25)
					
					text = font.render("WORD GAME", 0, PINK)
					textpos = text.get_rect()
					textpos.centerx = background.get_rect().centerx
					textpos.centery = background.get_rect().centery
					
					sub_txt = subfont.render("?? Copyright -- THANE LUND 1983 ??", 0, (0,250,250))
					sub_txt_pos = sub_txt.get_rect()
					sub_txt_pos.y = 500
					sub_txt_pos.x = (WINDOW_X/3)
					
					background.blit(text,textpos)
					background.blit(sub_txt, sub_txt_pos) 
					 
					screen.blit(background, backgroundspec)
					print pygame.display.flip()
					pygame.display.flip()

				
				elif keys[K_RETURN] and keys[K_SPACE]:   ###THIS IS A SHITTY SOLUTION: the second check sucks.  
					go = True
					while go == True:	
						RandomizeScreen()
						time.sleep(SCRAMBLE_SPEED)
						for event in pygame.event.get():
							if event.type == KEYUP:
								go = False
			
				elif keys[K_z] and keys[K_RETURN]:
					go = True
					
					font2 = pygame.font.Font(None, 30)
					
					
					text_long = font2.render(mysterious_line.next(),0,(0,0,0))
			
					textpos2 = text_long.get_rect()
					textpos2.centerx = background.get_rect().centerx
					textpos2.centery = background.get_rect().centery 
					
					
					screen.blit(background, backgroundspec)
					background.blit(text_long, textpos2)
					pygame.display.flip()
					
						
				elif keys[K_RETURN]:
					
					wking_background = ReturnRealRandomColor()
					backgroundspec = background.fill(wking_background)
					
					background.blit(text,textpos)
					screen.blit(background, (0,0))
					pygame.display.flip()
			
				####Changes Words and their color.  
				elif keys[K_z]:#
				
				
					#font = pygame.font.Font(None,ReturnRandomSize())
				
					background2 = background.fill(wking_background)
#					textpos = text.get_rect()
					text = font.render(ReturnRandomWord(), 0, ReturnRandomColor())
					background.blit(text,textpos)
					pygame.display.flip()
			
				###Changes Word Position
				elif keys[K_SPACE]:
					textpos.x = random.randint(0,WINDOW_X-100)	
					textpos.y = random.randint(0,WINDOW_Y-100)
					
					background2 = background.fill(wking_background)
					background.blit(text,textpos)
		
		
			
			screen.blit(background, (0,0))
			pygame.display.flip()