当前位置: 首页>>代码示例>>Python>>正文


Python Scene.play_scene方法代码示例

本文整理汇总了Python中scene.Scene.play_scene方法的典型用法代码示例。如果您正苦于以下问题:Python Scene.play_scene方法的具体用法?Python Scene.play_scene怎么用?Python Scene.play_scene使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在scene.Scene的用法示例。


在下文中一共展示了Scene.play_scene方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: scene_select

# 需要导入模块: from scene import Scene [as 别名]
# 或者: from scene.Scene import play_scene [as 别名]
def scene_select(character):
	# Scene Selection Screen
	
	pygame.init()
	
	size= [constants.SCREEN_WIDTH,constants.SCREEN_HEIGHT]
	screen = pygame.display.set_mode(size)

	pygame.display.set_caption("Punks R Us")
	char_folder = "../res/Character/"+character
	sprite_list = pygame.sprite.Group()
	text_file = open(char_folder+"/scene_list.txt","r")
	lines = text_file.read().split('\n')
	text_file.close()
	i=1
	scene_num = []
	scene_list = []
	for line in lines:
		if i%2 != 0:
			scene_num.append(line)
		else:
			scene_list.append(line)
		i+=1
	
	done = False
	select_box = Thing((char_folder+"/select_line.png",0,0,113,30))
	select_box.rect.x = 100
	select_box.rect.y = 100
	sprite_list.add(select_box)
	choice = 0
	clock = pygame.time.Clock()
	count = 0
	
	
	while not done:
		for event in pygame.event.get(): # User did something
			if event.type == pygame.QUIT: # If user clicked close
				pygame.quit() # Flag that we are done so we exit this loop

			if event.type == pygame.KEYDOWN:
				if event.key == pygame.K_DOWN:
					if choice == len(scene_list)-1:
						choice = 0
						select_box.rect.y = 100
						select_box.rect.x = 100
					else:
						choice +=1
						select_box.rect.y += 40
						select_box.rect.x += 20
					count = 0
				if event.key == pygame.K_UP:
					if choice == 0:
						choice = len(scene_list)-1
						select_box.rect.y = 100 + choice*40
						select_box.rect.x = 100 + choice*20
					else:
						choice += -1
						select_box.rect.y += -40
						select_box.rect.x += -20
					count = 0
				if event.key == pygame.K_RETURN:
					scene = Scene(scene_num[choice],scene_list[choice])
					scene.play_scene()
					
		# Setup to display/"update"
		
		# Draw all yo shit
		screen.fill(constants.BLACK)
		
		sprite_list.draw(screen)
		
		# Draw all the text
		font = pygame.font.Font(constants.F4, 60)
		text = font.render('Scene Selection',True,constants.WHITE)
		screen.blit(text, [constants.SCREEN_WIDTH/2-font.size('Scene Selection')[0]/2, 15])
		font = pygame.font.Font(constants.F7, 20)
		y = 100
		x = 120
		for scene in scene_list:
			text = font.render(scene,True,constants.WHITE)
			screen.blit(text, [x, y])
			y += 40
			x += 20
		
		# ALL CODE TO DRAW SHOULD GO ABOVE THIS COMMENT

		# Limit to 60 frames per second
		clock.tick(60)

		# Go ahead and update the screen with what we've drawn.
		pygame.display.flip()
	
	
	return done
开发者ID:reakain,项目名称:Punk_Game,代码行数:96,代码来源:charselect.py


注:本文中的scene.Scene.play_scene方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。