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


Python pygame.quit方法代码示例

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


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

示例1: startInterface

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import quit [as 别名]
def startInterface(screen):
	screen.fill(Config.get('bg_color'))
	clock = pygame.time.Clock()
	while True:
		button_1 = BUTTON(screen, (95, 150), '开始游戏')
		button_2 = BUTTON(screen, (95, 305), '退出游戏')
		for event in pygame.event.get():
			if event.type == pygame.QUIT:
				pygame.quit()
				sys.exit()
			if event.type == pygame.MOUSEBUTTONDOWN:
				if button_1.collidepoint(pygame.mouse.get_pos()):
					return
				elif button_2.collidepoint(pygame.mouse.get_pos()):
					quitGame()
		clock.tick(60)
		pygame.display.update() 
开发者ID:CharlesPikachu,项目名称:Games,代码行数:19,代码来源:Game12.py

示例2: ShowStartInterface

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import quit [as 别名]
def ShowStartInterface(screen, screensize):
	screen.fill((255, 255, 255))
	tfont = pygame.font.Font(cfg.FONTPATH, screensize[0]//5)
	cfont = pygame.font.Font(cfg.FONTPATH, screensize[0]//20)
	title = tfont.render(u'滑雪游戏', True, (255, 0, 0))
	content = cfont.render(u'按任意键开始游戏', True, (0, 0, 255))
	trect = title.get_rect()
	trect.midtop = (screensize[0]/2, screensize[1]/5)
	crect = content.get_rect()
	crect.midtop = (screensize[0]/2, screensize[1]/2)
	screen.blit(title, trect)
	screen.blit(content, crect)
	while True:
		for event in pygame.event.get():
			if event.type == pygame.QUIT:
				pygame.quit()
				sys.exit()
			elif event.type == pygame.KEYDOWN:
				return
		pygame.display.update() 
开发者ID:CharlesPikachu,项目名称:Games,代码行数:22,代码来源:Game4.py

示例3: _idle_message

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import quit [as 别名]
def _idle_message(self):
        """Print idle message from file reader."""
        # Print message to console.
        message = self._reader.idle_message()
        self._print(message)
        # Do nothing else if the OSD is turned off.
        if not self._osd:
            return
        # Display idle message in center of screen.
        label = self._render_text(message)
        lw, lh = label.get_size()
        sw, sh = self._screen.get_size()
        self._screen.fill(self._bgcolor)
        self._screen.blit(label, (sw/2-lw/2, sh/2-lh/2))
        # If keyboard control is enabled, display message about it
        if self._keyboard_control:
            label2 = self._render_text('press ESC to quit')
            l2w, l2h = label2.get_size()
            self._screen.blit(label2, (sw/2-l2w/2, sh/2-l2h/2+lh))
        pygame.display.update() 
开发者ID:adafruit,项目名称:pi_video_looper,代码行数:22,代码来源:video_looper.py

示例4: _handle_keyboard_shortcuts

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import quit [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

示例5: __startInterface

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import quit [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

示例6: startInterface

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import quit [as 别名]
def startInterface(screen, begin_image_paths):
    begin_images = [pygame.image.load(begin_image_paths[0]), pygame.image.load(begin_image_paths[1])]
    begin_image = begin_images[0]
    while True:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                pygame.quit()
                sys.exit()
            elif event.type == pygame.MOUSEMOTION:
                mouse_pos = pygame.mouse.get_pos()
                if mouse_pos[0] in list(range(419, 574)) and mouse_pos[1] in list(range(374, 416)):
                    begin_image = begin_images[1]
                else:
                    begin_image = begin_images[0]
            elif event.type == pygame.MOUSEBUTTONDOWN:
                mouse_pos = pygame.mouse.get_pos()
                if event.button == 1 and mouse_pos[0] in list(range(419, 574)) and mouse_pos[1] in list(range(374, 416)):
                    return True
        screen.blit(begin_image, (0, 0))
        pygame.display.update() 
开发者ID:CharlesPikachu,项目名称:Games,代码行数:22,代码来源:startinterface.py

示例7: start_interface

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import quit [as 别名]
def start_interface(screen):
	clock = pygame.time.Clock()
	while True:
		button_1 = BUTTON(screen, (330, 190), '单人模式')
		button_2 = BUTTON(screen, (330, 305), '双人模式')
		for event in pygame.event.get():
			if event.type == pygame.QUIT:
				pygame.quit()
				sys.exit()
			if event.type == pygame.MOUSEBUTTONDOWN:
				if button_1.collidepoint(pygame.mouse.get_pos()):
					return 1
				elif button_2.collidepoint(pygame.mouse.get_pos()):
					return 2
		clock.tick(60)
		pygame.display.update() 
开发者ID:CharlesPikachu,项目名称:Games,代码行数:18,代码来源:Game10.py

示例8: end_interface

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import quit [as 别名]
def end_interface(screen):
	clock = pygame.time.Clock()
	while True:
		button_1 = BUTTON(screen, (330, 190), '重新开始')
		button_2 = BUTTON(screen, (330, 305), '退出游戏')
		for event in pygame.event.get():
			if event.type == pygame.QUIT:
				pygame.quit()
				sys.exit()
			if event.type == pygame.MOUSEBUTTONDOWN:
				if button_1.collidepoint(pygame.mouse.get_pos()):
					return
				elif button_2.collidepoint(pygame.mouse.get_pos()):
					pygame.quit()
					sys.exit()
		clock.tick(60)
		pygame.display.update() 
开发者ID:CharlesPikachu,项目名称:Games,代码行数:19,代码来源:Game10.py

示例9: switchInterface

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import quit [as 别名]
def switchInterface(screen):
	screen.fill(Config.get('bg_color'))
	clock = pygame.time.Clock()
	while True:
		button_1 = BUTTON(screen, (95, 150), '进入下关')
		button_2 = BUTTON(screen, (95, 305), '退出游戏')
		for event in pygame.event.get():
			if event.type == pygame.QUIT:
				pygame.quit()
				sys.exit()
			if event.type == pygame.MOUSEBUTTONDOWN:
				if button_1.collidepoint(pygame.mouse.get_pos()):
					return
				elif button_2.collidepoint(pygame.mouse.get_pos()):
					quitGame()
		clock.tick(60)
		pygame.display.update() 
开发者ID:CharlesPikachu,项目名称:Games,代码行数:19,代码来源:Game12.py

示例10: endInterface

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import quit [as 别名]
def endInterface(screen, color, is_win):
	screen.fill(color)
	clock = pygame.time.Clock()
	if is_win:
		text = 'VICTORY'
	else:
		text = 'FAILURE'
	font = pygame.font.SysFont('arial', 30)
	text_render = font.render(text, 1, (255, 255, 255))
	while True:
		for event in pygame.event.get():
			if event.type == pygame.QUIT:
				pygame.quit()
				sys.exit()
			if (event.type == pygame.KEYDOWN) or (event.type == pygame.MOUSEBUTTONDOWN):
				return
		screen.blit(text_render, (350, 300))
		clock.tick(60)
		pygame.display.update() 
开发者ID:CharlesPikachu,项目名称:Games,代码行数:21,代码来源:utils.py

示例11: showEndGameInterface

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import quit [as 别名]
def showEndGameInterface(screen, exitcode, accuracy, game_images):
    font = pygame.font.Font(None, 24)
    text = font.render(f"Accuracy: {accuracy}%", True, (255, 0, 0))
    text_rect = text.get_rect()
    text_rect.centerx = screen.get_rect().centerx
    text_rect.centery = screen.get_rect().centery + 24
    while True:
        screen.fill(0)
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                pygame.quit()
                sys.exit()
        if exitcode:
            screen.blit(game_images['youwin'], (0, 0))
        else:
            screen.blit(game_images['gameover'], (0, 0))
        screen.blit(text, text_rect)
        pygame.display.flip() 
开发者ID:CharlesPikachu,项目名称:Games,代码行数:20,代码来源:interfaces.py

示例12: GameStartInterface

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import quit [as 别名]
def GameStartInterface(screen, sounds, cfg):
	dino = Dinosaur(cfg.IMAGE_PATHS['dino'])
	ground = pygame.image.load(cfg.IMAGE_PATHS['ground']).subsurface((0, 0), (83, 19))
	rect = ground.get_rect()
	rect.left, rect.bottom = cfg.SCREENSIZE[0]/20, cfg.SCREENSIZE[1]
	clock = pygame.time.Clock()
	press_flag = False
	while True:
		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_SPACE or event.key == pygame.K_UP:
					press_flag = True
					dino.jump(sounds)
		dino.update()
		screen.fill(cfg.BACKGROUND_COLOR)
		screen.blit(ground, rect)
		dino.draw(screen)
		pygame.display.update()
		clock.tick(cfg.FPS)
		if (not dino.is_jumping) and press_flag:
			return True 
开发者ID:CharlesPikachu,项目名称:Games,代码行数:26,代码来源:gamestart.py

示例13: startInterface

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import quit [as 别名]
def startInterface(screen):
	clock = pygame.time.Clock()
	while True:
		screen.fill((41, 36, 33))
		button_1 = Button(screen, (150, 175), '1 Player')
		button_2 = Button(screen, (150, 275), '2 Player')
		for event in pygame.event.get():
			if event.type == pygame.QUIT:
				pygame.quit()
				sys.exit()
			if event.type == pygame.MOUSEBUTTONDOWN:
				if button_1.collidepoint(pygame.mouse.get_pos()):
					return 1
				elif button_2.collidepoint(pygame.mouse.get_pos()):
					return 2
		clock.tick(10)
		pygame.display.update() 
开发者ID:CharlesPikachu,项目名称:Games,代码行数:19,代码来源:Game17.py

示例14: endInterface

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import quit [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

示例15: main

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import quit [as 别名]
def main():
    pygame.init()
    display = (800,600)
    pygame.display.set_mode(display, DOUBLEBUF|OPENGL)

    gluPerspective(45, (display[0]/display[1]), 0.1, 50.0)

    glTranslatef(0.0,0.0, -5)

    while True:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                pygame.quit()
                quit()

        glRotatef(1, 3, 1, 1)
        glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT)
        Cube()
        pygame.display.flip()
        pygame.time.wait(10) 
开发者ID:geohot,项目名称:twitchslam,代码行数:22,代码来源:test_pyopengl.py


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