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


Python pygame.K_ESCAPE属性代码示例

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


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

示例1: _handle_keyboard_shortcuts

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import K_ESCAPE [as 别名]
def _handle_keyboard_shortcuts(self):
        while self._running:
            event = pygame.event.wait()
            if event.type == pygame.KEYDOWN:
                # If pressed key is ESC quit program
                if event.key == pygame.K_ESCAPE:
                    self._print("ESC was pressed. quitting...")
                    self.quit()
                if event.key == pygame.K_k:
                    self._print("k was pressed. skipping...")
                    self._player.stop(3)
                if event.key == pygame.K_s:
                    if self._playbackStopped:
                        self._print("s was pressed. starting...")
                        self._playbackStopped = False
                    else:
                        self._print("s was pressed. stopping...")
                        self._playbackStopped = True
                        self._player.stop(3) 
开发者ID:adafruit,项目名称:pi_video_looper,代码行数:21,代码来源:video_looper.py

示例2: loop

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import K_ESCAPE [as 别名]
def loop(env, screen, pano_ids_yaws):
  """Main loop of the scan agent."""
  for (pano_id, yaw) in pano_ids_yaws:

    # Retrieve the observation at a specified pano ID and heading.
    logging.info('Retrieving view at pano ID %s and yaw %f', pano_id, yaw)
    observation = env.goto(pano_id, yaw)

    current_yaw = observation["yaw"]
    view_image = interleave(observation["view_image"],
                            FLAGS.width, FLAGS.height)
    graph_image = interleave(observation["graph_image"],
                             FLAGS.width, FLAGS.height)
    screen_buffer = np.concatenate((view_image, graph_image), axis=1)
    pygame.surfarray.blit_array(screen, screen_buffer)
    pygame.display.update()

    for event in pygame.event.get():
      if (event.type == pygame.QUIT or
          (event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE)):
        return
    if FLAGS.save_images:
      filename = 'scan_agent_{}_{}.bmp'.format(pano_id, yaw)
      pygame.image.save(screen, filename) 
开发者ID:deepmind,项目名称:streetlearn,代码行数:26,代码来源:scan_agent.py

示例3: __startInterface

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import K_ESCAPE [as 别名]
def __startInterface(self):
		clock = pygame.time.Clock()
		while True:
			for event in pygame.event.get():
				if event.type == pygame.QUIT or (event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE):
					pygame.quit()
					sys.exit(-1)
				if event.type == pygame.KEYDOWN and event.key == pygame.K_RETURN:
					return
			self.screen.fill(self.cfg.AQUA)
			text1 = 'Press <Enter> to start the game'
			text2 = 'Press <Esc> to quit the game'
			text_render1 = self.font_big.render(text1, False, self.cfg.BLUE)
			text_render2 = self.font_big.render(text2, False, self.cfg.BLUE)
			self.screen.blit(text_render1, ((self.cfg.SCREENWIDTH-text_render1.get_rect().width)//2, (self.cfg.SCREENHEIGHT-text_render1.get_rect().height)//4))
			self.screen.blit(text_render2, ((self.cfg.SCREENWIDTH-text_render2.get_rect().width)//2, (self.cfg.SCREENHEIGHT-text_render2.get_rect().height)//2))
			pygame.display.flip()
			clock.tick(30) 
开发者ID:CharlesPikachu,项目名称:Games,代码行数:20,代码来源:game.py

示例4: __endInterface

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import K_ESCAPE [as 别名]
def __endInterface(self, is_win):
		if is_win:
			text1 = 'Congratulations! You win!'
		else:
			text1 = 'Game Over! You fail!'
		text2 = 'Press <R> to restart the game'
		text3 = 'Press <Esc> to quit the game.'
		clock = pygame.time.Clock()
		while True:
			for event in pygame.event.get():
				if event.type == pygame.QUIT or (event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE):
					pygame.quit()
					sys.exit(-1)
				if event.type == pygame.KEYDOWN and event.key == pygame.K_r:
					return
			self.screen.fill(self.cfg.AQUA)
			text_render1 = self.font_big.render(text1, False, self.cfg.BLUE)
			text_render2 = self.font_big.render(text2, False, self.cfg.BLUE)
			text_render3 = self.font_big.render(text3, False, self.cfg.BLUE)
			self.screen.blit(text_render1, ((self.cfg.SCREENWIDTH-text_render1.get_rect().width)//2, (self.cfg.SCREENHEIGHT-text_render1.get_rect().height)//4))
			self.screen.blit(text_render2, ((self.cfg.SCREENWIDTH-text_render2.get_rect().width)//2, (self.cfg.SCREENHEIGHT-text_render2.get_rect().height)//2))
			self.screen.blit(text_render3, ((self.cfg.SCREENWIDTH-text_render3.get_rect().width)//2, (self.cfg.SCREENHEIGHT-text_render2.get_rect().height)//1.5))
			pygame.display.flip()
			clock.tick(30) 
开发者ID:CharlesPikachu,项目名称:Games,代码行数:26,代码来源:game.py

示例5: endGame

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import K_ESCAPE [as 别名]
def endGame(screen, sounds, showScore, score, number_images, bird, pipe_sprites, backgroud_image, other_images, base_pos, cfg):
	sounds['die'].play()
	clock = pygame.time.Clock()
	while True:
		for event in pygame.event.get():
			if event.type == pygame.QUIT or (event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE):
				pygame.quit()
				sys.exit()
			elif event.type == pygame.KEYDOWN:
				if event.key == pygame.K_SPACE or event.key == pygame.K_UP:
					return
		boundary_values = [0, base_pos[-1]]
		bird.update(boundary_values, float(clock.tick(cfg.FPS))/1000.)
		screen.blit(backgroud_image, (0, 0))
		pipe_sprites.draw(screen)
		screen.blit(other_images['base'], base_pos)
		showScore(screen, score, number_images)
		bird.draw(screen)
		pygame.display.update()
		clock.tick(cfg.FPS) 
开发者ID:CharlesPikachu,项目名称:Games,代码行数:22,代码来源:endGame.py

示例6: endInterface

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import K_ESCAPE [as 别名]
def endInterface(screen, score_left, score_right):
	clock = pygame.time.Clock()
	font1 = pygame.font.Font(config.FONTPATH, 30)
	font2 = pygame.font.Font(config.FONTPATH, 20)
	msg = 'Player on left won!' if score_left > score_right else 'Player on right won!'
	texts = [font1.render(msg, True, config.WHITE),
			 font2.render('Press ESCAPE to quit.', True, config.WHITE),
			 font2.render('Press ENTER to continue or play again.', True, config.WHITE)]
	positions = [[120, 200], [155, 270], [80, 300]]
	while True:
		screen.fill((41, 36, 33))
		for event in pygame.event.get():
			if event.type == pygame.QUIT:
				pygame.quit()
				sys.exit()
			if event.type == pygame.KEYDOWN:
				if event.key == pygame.K_RETURN:
					return
				elif event.key == pygame.K_ESCAPE:
					sys.exit()
					pygame.quit()
		for text, pos in zip(texts, positions):
			screen.blit(text, pos)
		clock.tick(10)
		pygame.display.update() 
开发者ID:CharlesPikachu,项目名称:Games,代码行数:27,代码来源:Game17.py

示例7: _event_looper

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import K_ESCAPE [as 别名]
def _event_looper(self, force=False):
        has_quit = False
        if self._deactivate_display:
            return force, has_quit
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                has_quit = True
                return force, has_quit
                # pygame.quit()
                # exit()
            elif event.type == pygame.KEYDOWN:
                if event.key == pygame.K_ESCAPE:
                    has_quit = True
                    return force, has_quit
                if event.key == pygame.K_SPACE:
                    self._get_plot_pause()
                    # pause_surface = self.draw_plot_pause()
                    # self.screen.blit(pause_surface, (320 + self.left_menu_shape[0], 320))
                    return not force, has_quit
        return force, has_quit 
开发者ID:rte-france,项目名称:Grid2Op,代码行数:22,代码来源:PlotPyGame.py

示例8: _press_key_to_quit

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import K_ESCAPE [as 别名]
def _press_key_to_quit(self):
        """
        This utility function waits for the player to press a key to exit the renderer (called when the episode is done)

        Returns
        -------
        res: ``bool``, ``bool``
            ``True`` if the human player closed the window, in this case it will stop the computation: no other episode
            will be computed. ``False`` otherwise.

        """
        if self._deactivate_display:
            return
        has_quit = False
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                has_quit = True
                return True, has_quit
            elif event.type == pygame.KEYDOWN:
                if event.key == pygame.K_ESCAPE:
                    has_quit = True
                    return True, has_quit
                if event.key == pygame.K_SPACE:
                    return True, has_quit
        return False, has_quit 
开发者ID:rte-france,项目名称:Grid2Op,代码行数:27,代码来源:PlotPyGame.py

示例9: _map_keys

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import K_ESCAPE [as 别名]
def _map_keys(self):
        key_map = self.io.key_map

        key_map[imgui.KEY_TAB] = pygame.K_TAB
        key_map[imgui.KEY_LEFT_ARROW] = pygame.K_LEFT
        key_map[imgui.KEY_RIGHT_ARROW] = pygame.K_RIGHT
        key_map[imgui.KEY_UP_ARROW] = pygame.K_UP
        key_map[imgui.KEY_DOWN_ARROW] = pygame.K_DOWN
        key_map[imgui.KEY_PAGE_UP] = pygame.K_PAGEUP
        key_map[imgui.KEY_PAGE_DOWN] = pygame.K_PAGEDOWN
        key_map[imgui.KEY_HOME] = pygame.K_HOME
        key_map[imgui.KEY_END] = pygame.K_END
        key_map[imgui.KEY_DELETE] = pygame.K_DELETE
        key_map[imgui.KEY_BACKSPACE] = pygame.K_BACKSPACE
        key_map[imgui.KEY_ENTER] = pygame.K_RETURN
        key_map[imgui.KEY_ESCAPE] = pygame.K_ESCAPE
        key_map[imgui.KEY_A] = pygame.K_a
        key_map[imgui.KEY_C] = pygame.K_c
        key_map[imgui.KEY_V] = pygame.K_v
        key_map[imgui.KEY_X] = pygame.K_x
        key_map[imgui.KEY_Y] = pygame.K_y
        key_map[imgui.KEY_Z] = pygame.K_z 
开发者ID:swistakm,项目名称:pyimgui,代码行数:24,代码来源:pygame.py

示例10: events

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import K_ESCAPE [as 别名]
def events(self):
        # catch all events here
        for event in pg.event.get():
            if event.type == pg.QUIT:
                self.quit()
            if event.type == pg.KEYDOWN:
                if event.key == pg.K_ESCAPE:
                    self.quit()
                if event.key == pg.K_LEFT:
                    self.player.move(dx=-1)
                if event.key == pg.K_RIGHT:
                    self.player.move(dx=1)
                if event.key == pg.K_UP:
                    self.player.move(dy=-1)
                if event.key == pg.K_DOWN:
                    self.player.move(dy=1) 
开发者ID:kidscancode,项目名称:pygame_tutorials,代码行数:18,代码来源:main.py

示例11: game_over

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import K_ESCAPE [as 别名]
def game_over(self):
        '''
        游戏结束
        '''
        while True:
            # 绘制背景图
            self.set_time_passed()
            self.draw_background()
            text = self.font.render(f'游戏结束,得分 : {self.score} ', True, (0, 0, 0), (255, 255, 255))
            text_position_x = (self.size[0] - text.get_size()[0]) / 2
            text_position_y = (self.size[1] - text.get_size()[1]) / 2
            self.screen.blit(text, (text_position_x, text_position_y))

            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    pygame.quit()
                    sys.exit()
                elif event.type == pygame.KEYDOWN:
                    if event.key == pygame.K_ESCAPE:
                        pygame.quit()
                        sys.exit()

            pygame.display.update() 
开发者ID:MiracleYoung,项目名称:You-are-Pythonista,代码行数:25,代码来源:plan_game.py

示例12: ShowEndInterface

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import K_ESCAPE [as 别名]
def ShowEndInterface():
	title_font = pygame.font.Font('simkai.ttf', 100)
	title_game = title_font.render('Game', True, (233, 150, 122))
	title_over = title_font.render('Over', True, (233, 150, 122))
	game_rect = title_game.get_rect()
	over_rect = title_over.get_rect()
	game_rect.midtop = (SCREENWIDTH/2, 70)
	over_rect.midtop = (SCREENWIDTH/2, game_rect.height+70+25)
	screen.blit(title_game, game_rect)
	screen.blit(title_over, over_rect)
	pygame.display.update()
	pygame.time.wait(500)
	while True:
		for event in pygame.event.get():
			if event.type == pygame.QUIT or (event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE):
				CloseGame() 
开发者ID:CharlesPikachu,项目名称:AIGames,代码行数:18,代码来源:AISnake.py

示例13: endGame

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import K_ESCAPE [as 别名]
def endGame(screen, sounds, showScore, score, number_images, bird, pipe_sprites, backgroud_image, other_images, base_pos, cfg, mode):
	if mode == 'train':
		return
	sounds['die'].play()
	clock = pygame.time.Clock()
	while True:
		for event in pygame.event.get():
			if event.type == pygame.QUIT or (event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE):
				pygame.quit()
				sys.exit()
			elif event.type == pygame.KEYDOWN:
				if event.key == pygame.K_SPACE or event.key == pygame.K_UP:
					return
		boundary_values = [0, base_pos[-1]]
		bird.update(boundary_values)
		screen.blit(backgroud_image, (0, 0))
		pipe_sprites.draw(screen)
		screen.blit(other_images['base'], base_pos)
		showScore(screen, score, number_images)
		bird.draw(screen)
		pygame.display.update()
		clock.tick(cfg.FPS) 
开发者ID:CharlesPikachu,项目名称:AIGames,代码行数:24,代码来源:endGame.py

示例14: textBoxInput

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import K_ESCAPE [as 别名]
def textBoxInput(textbox, functionToCall=None, args=[]):
    # starts grabbing key inputs, putting into textbox until enter pressed
    global keydict
    textbox.text = ""
    returnVal = None
    while True:
        updateDisplay()
        if functionToCall:
            returnVal = functionToCall(*args)
        for event in pygame.event.get():
            if event.type == pygame.KEYDOWN:
                if event.key == pygame.K_RETURN:
                    textbox.clear()
                    if returnVal:
                        return textbox.text, returnVal
                    else:
                        return textbox.text
                elif event.key == pygame.K_ESCAPE:
                    pygame.quit()
                    sys.exit()
                else:
                    textbox.update(event)
            elif event.type == pygame.QUIT:
                pygame.quit()
                sys.exit() 
开发者ID:StevePaget,项目名称:Pygame_Functions,代码行数:27,代码来源:pygame_functions.py

示例15: run

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import K_ESCAPE [as 别名]
def run(self):
        # Game Loop
        while True:
            self.clock.tick(60)  # Set to 60 fps

            if self.current_scene == 'Map':
                self.map_scene()
            elif self.current_scene == 'Main':
                self.main_scene()

            events = pygame.event.get()
            for event in events:
                if event.type == pygame.QUIT:
                    pygame.quit()
                    quit()
                elif event.type == pygame.KEYDOWN:
                    if event.key == pygame.K_ESCAPE:
                        # If ESC is pressed during the zoom state the world map is opened
                        self.country = None
                        self.current_scene = 'Map'
                        self.run()
            pygame.display.update() 
开发者ID:python-discord,项目名称:code-jam-5,代码行数:24,代码来源:game.py


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