コード例 #1
0
def init():
	global screen
	options = ["Start Game", "Custom Levels", "Options", "Quit"]

	myfont = pygame.font.Font(None, 32)
	gui.clean()
	choice = dm(screen, options, WIDTH // 2, HEIGHT // 2, None, 32, 1.4, GREEN, PURPLE) + 1
	
	if choice == 1:
		game()
	
	elif choice == 3:
		pass
	
	elif choice == 4:
		pygame.quit()
		sys.exit()
	
	else:
		screen.fill(PURPLE)
		text = myfont.render("User picked "+options[choice-1], True, RED)
		textrect = text.get_rect()
		textrect = textrect.move((WIDTH-textrect.width) // 2, (HEIGHT-textrect.height) // 2)
		screen.blit(text, textrect)
		pygame.display.update(textrect)

		while True:
			for event in pygame.event.get():
				if event.type == pygame.QUIT:
					pygame.quit()
					sys.exit()
				if event.type == pygame.KEYDOWN:
					return
コード例 #2
0
ファイル: menutest.py プロジェクト: vinyldarkscratch/Fur
RED = 255, 0, 0
GREEN = 0, 255, 0
BLUE = 0, 0, 255
PURPLE = 101, 39, 170

while True:
	options = ["Start Game", "Custom Levels", "Options", "Quit"]

	size = width, height = 0, 0
	screen = pygame.display.set_mode(size, pygame.FULLSCREEN)
	size = width, height = screen.get_size()
	myfont = pygame.font.Font(None, 32)

	screen.fill(BLACK)

	choice = dm(screen, options, width // 2, height // 2, None, 32, 1.4, GREEN, PURPLE) + 1

	if choice == 4:
		pygame.quit()
		sys.exit()

	screen.fill(PURPLE)
	text = myfont.render("User picked "+options[choice], True, RED)
	textrect = text.get_rect()
	textrect = textrect.move((width-textrect.width) // 2, (height-textrect.height) // 2)
	screen.blit(text, textrect)
	pygame.display.update(textrect)

	while True:
		for event in pygame.event.get():
			if event.type == pygame.QUIT or event.type == pygame.KEYDOWN:
コード例 #3
0
ファイル: localio.py プロジェクト: vinyldarkscratch/Fur
 def choice(self, msg, choices, window=False):
     strings = [str(c) for c in choices]
     if config.ios:
         temp = strings[-1]
         if temp == m("quit") or temp == m("back") or temp == m("cancel"):
             strings.remove(temp)
         try:
             if len(strings) == 1:
                 choice = console.alert(msg, "", strings[0])
             elif len(strings) == 2:
                 choice = console.alert(msg, "", strings[0], strings[1])
             elif len(strings) == 3:
                 choice = console.alert(msg, "", strings[0], strings[1], strings[2])
             else:
                 waiting = True
                 page = 1
                 while waiting:
                     try:
                         b = 2
                         choice = console.alert(
                             msg, "", strings[0 + (page - 1) * 2], strings[1 + (page - 1) * 2], "Next Page"
                         )
                     except IndexError:
                         b = 1
                         try:
                             choice = console.alert(msg, "", strings[0 + (page - 1) * 2], output("next", r=1))
                         except IndexError:
                             page = 0
                             choice = 1 + b
                         except KeyboardInterrupt:
                             return 0
                     except KeyboardInterrupt:
                         return 0
                     if choice == 1 + b:
                         if page <= len(strings) // 2:
                             page += 1
                         else:
                             page = 1
                     else:
                         number = choice + (page - 1) * 2
                         waiting = False
             number = choice
         except KeyboardInterrupt:
             return 0
     else:
         if not window:
             choice = easygui.buttonbox(
                 msg=msg, title="PELT Engine - " + pelt.gametitle + " v" + str(pelt.version), choices=strings
             )
             i = 1
             for c in strings:
                 if choice == c:
                     number = i
                 else:
                     i += 1
         else:
             choice = dm(pelt.screen, strings, pelt.width // 2, pelt.height // 2, None, 32, 1.4, GREEN, PURPLE) + 1
     temp = str(choice)
     if temp == m("quit") or temp == m("back") or temp == m("cancel"):
         return 0
     return choices[number - 1]