本文整理汇总了Python中pygame.QUIT属性的典型用法代码示例。如果您正苦于以下问题:Python pygame.QUIT属性的具体用法?Python pygame.QUIT怎么用?Python pygame.QUIT使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类pygame
的用法示例。
在下文中一共展示了pygame.QUIT属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: loop
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import QUIT [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)
示例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()
示例3: GameOver
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import QUIT [as 别名]
def GameOver(screen, width, height, score, highest):
screen.fill((255, 255, 255))
tfont = pygame.font.Font('./font/simkai.ttf', width//10)
cfont = pygame.font.Font('./font/simkai.ttf', width//20)
title = tfont.render('GameOver', True, (255, 0, 0))
content = cfont.render('Score: %s, Highest: %s' % (score, highest), True, (0, 0, 255))
trect = title.get_rect()
trect.midtop = (width/2, height/4)
crect = content.get_rect()
crect.midtop = (width/2, height/2)
screen.blit(title, trect)
screen.blit(content, crect)
pygame.display.update()
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit()
elif event.type == pygame.KEYDOWN:
return
示例4: __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)
示例5: 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()
示例6: 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()
示例7: 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()
示例8: 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()
示例9: 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()
示例10: 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
示例11: endGame
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import QUIT [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)
示例12: 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()
示例13: 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)
示例14: paint
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import QUIT [as 别名]
def paint(data: List[int]):
pygame.init()
screen = pygame.display.set_mode([WIDTH * SCALE, HEIGHT * SCALE])
for i in range(SCREEN_AREA_SIZE):
plot_byte(screen, data, i)
pygame.display.flip()
# Wait for quit
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
pygame.quit()
示例15: _render
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import QUIT [as 别名]
def _render(self):
self.before_render()
if not PYGAME_INSTALLED:
return
# For some reason pygame wants X and Y swapped
aray, n = self.driver.flip()
if self.screen is None:
self.screen = pygame.display.set_mode(aray[0].shape[:2][::-1])
surf = pygame.surfarray.make_surface(aray[0].swapaxes(0, 1))
rect = surf.get_rect()
self.screen.blit(surf, rect)
pygame.display.flip()
for event in pygame.event.get():
if event.type == pygame.QUIT:
self.close()