Python pygame.K_ESCAPE Examples
The following are 30
code examples of pygame.K_ESCAPE().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
pygame
, or try the search function
.
Example #1
Source File: video_looper.py From pi_video_looper with GNU General Public License v2.0 | 10 votes |
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)
Example #2
Source File: Game3.py From Games with MIT License | 7 votes |
def ShowEndInterface(screen, width, height): screen.fill(cfg.BACKGROUNDCOLOR) font = pygame.font.Font(cfg.FONTPATH, width//15) title = font.render('恭喜! 你成功完成了拼图!', True, (233, 150, 122)) rect = title.get_rect() rect.midtop = (width/2, height/2.5) screen.blit(title, rect) pygame.display.update() 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() pygame.display.update()
Example #3
Source File: Game3.py From Games with MIT License | 7 votes |
def ShowStartInterface(screen, width, height): screen.fill(cfg.BACKGROUNDCOLOR) tfont = pygame.font.Font(cfg.FONTPATH, width//4) cfont = pygame.font.Font(cfg.FONTPATH, width//20) title = tfont.render('拼图游戏', True, cfg.RED) content1 = cfont.render('按H或M或L键开始游戏', True, cfg.BLUE) content2 = cfont.render('H为5*5模式, M为4*4模式, L为3*3模式', True, cfg.BLUE) trect = title.get_rect() trect.midtop = (width/2, height/10) crect1 = content1.get_rect() crect1.midtop = (width/2, height/2.2) crect2 = content2.get_rect() crect2.midtop = (width/2, height/1.8) screen.blit(title, trect) screen.blit(content1, crect1) screen.blit(content2, crect2) 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 == ord('l'): return 3 elif event.key == ord('m'): return 4 elif event.key == ord('h'): return 5 pygame.display.update()
Example #4
Source File: plan_game.py From You-are-Pythonista with GNU General Public License v3.0 | 7 votes |
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()
Example #5
Source File: scan_agent.py From streetlearn with Apache License 2.0 | 6 votes |
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)
Example #6
Source File: endGame.py From Games with MIT License | 6 votes |
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)
Example #7
Source File: endGame.py From AIGames with MIT License | 6 votes |
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)
Example #8
Source File: game.py From code-jam-5 with MIT License | 6 votes |
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()
Example #9
Source File: pygame_functions.py From Pygame_Functions with GNU General Public License v2.0 | 6 votes |
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()
Example #10
Source File: pygame_functions.py From Pygame_Functions with GNU General Public License v2.0 | 6 votes |
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()
Example #11
Source File: endGame.py From AIGames with MIT License | 6 votes |
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)
Example #12
Source File: main.py From python-examples with MIT License | 5 votes |
def stage1(screen): button1 = Button((5, 5), (100, 100), (0,255,0), "GO 1") button2 = Button((215, 5), (100, 100), (0,255,0), "EXIT") # - mainloop - clock = pygame.time.Clock() running = True while running: # - events - for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() exit() elif event.type == pygame.KEYDOWN: if event.key == pygame.K_ESCAPE: pygame.quit() if button1.is_clicked(event): # go to stage2 stage2(screen) if button2.is_clicked(event): # exit pygame.quit() exit() # - draws - screen.fill((255,0,0)) button1.draw(screen) button2.draw(screen) pygame.display.flip() # - FPS - clock.tick(FPS)
Example #13
Source File: app.py From BlueDot with MIT License | 5 votes |
def run(self): clock = pygame.time.Clock() running = True while running: clock.tick(50) ev = pygame.event.get() for event in ev: if event.type == pygame.MOUSEBUTTONDOWN: pos = pygame.mouse.get_pos() #has a device been clicked? for d in range(len(self.device_rects)): if self.device_rects[d].collidepoint(pos): # show the button self.draw_status_message("Connecting") button_screen = ButtonScreen(self.screen, self.font, self.bt_adapter.device, self.bt_adapter.paired_devices[d][0], self.width, self.height) button_screen.run() #redraw the screen self.draw_screen() if self.close_rect.collidepoint(pos): running = False if event.type == pygame.KEYDOWN: if event.key == pygame.K_ESCAPE: running = False if event.type == pygame.QUIT: running = False pygame.display.update()
Example #14
Source File: pygame_functions.py From Pygame_Functions with GNU General Public License v2.0 | 5 votes |
def pause(milliseconds, allowEsc=True): keys = pygame.key.get_pressed() current_time = pygame.time.get_ticks() waittime = current_time + milliseconds updateDisplay() while not (current_time > waittime or (keys[pygame.K_ESCAPE] and allowEsc)): pygame.event.clear() keys = pygame.key.get_pressed() if (keys[pygame.K_ESCAPE] and allowEsc): pygame.quit() sys.exit() current_time = pygame.time.get_ticks()
Example #15
Source File: pygame_functions.py From Pygame_Functions with GNU General Public License v2.0 | 5 votes |
def updateDisplay(): global background spriteRects = spriteGroup.draw(screen) textboxRects = textboxGroup.draw(screen) pygame.display.update() keys = pygame.key.get_pressed() if (keys[pygame.K_ESCAPE]): pygame.quit() sys.exit() spriteGroup.clear(screen, background.surface) textboxGroup.clear(screen, background.surface)
Example #16
Source File: pivaders.py From pivaders with GNU General Public License v2.0 | 5 votes |
def control(self): for event in pygame.event.get(): if event.type == pygame.QUIT: GameState.start_screen = False GameState.end_game = True if event.type == pygame.KEYDOWN \ and event.key == pygame.K_ESCAPE: if GameState.start_screen: GameState.start_screen = False GameState.end_game = True self.kill_all() else: GameState.start_screen = True self.keys = pygame.key.get_pressed() if self.keys[pygame.K_LEFT]: GameState.vector = -1 self.animate_left = True self.animate_right = False elif self.keys[pygame.K_RIGHT]: GameState.vector = 1 self.animate_right = True self.animate_left = False else: GameState.vector = 0 self.animate_right = False self.animate_left = False if self.keys[pygame.K_SPACE]: if GameState.start_screen: GameState.start_screen = False self.lives = 2 self.score = 0 self.make_player() self.make_defenses() self.alien_wave(0) else: GameState.shoot_bullet = True self.bullet_fx.play()
Example #17
Source File: booth.py From pibooth with MIT License | 5 votes |
def find_settings_event(self, events): """Return the first found event if found in the list. """ for event in events: if event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE: return event if event.type == BUTTONDOWN and event.capture and event.printer: return event return None
Example #18
Source File: mainMenu.py From universalSmashSystem with GNU General Public License v3.0 | 5 votes |
def executeMenu(self,_screen): clock = pygame.time.Clock() while self.status == 0: self.update(_screen) music = musicManager.getMusicManager() music.doMusicEvent() for event in pygame.event.get(): if event.type == KEYDOWN or event.type == pygame.JOYBUTTONDOWN: if event.type == pygame.KEYDOWN and event.key == K_ESCAPE: self.status = 1 else: menu = MainMenu(self._parent) self._parent.music.rollMusic('menu') menu.star_color = self.hsv ret_value = menu.executeMenu(_screen) pygame.mixer.music.fadeout(1000) if ret_value == -1: return -1 if event.type == QUIT: self.status = -1 sys.exit() rgb = tuple(i * 255 for i in colorsys.hsv_to_rgb(self.hsv[0],self.hsv[1],self.hsv[2])) _screen.fill(rgb) self.logo.draw(_screen, self.logo.rect.topleft, 1.0) self.start.draw(_screen, self.start.rect.topleft, 1.0) clock.tick(60) pygame.display.flip() return self.status
Example #19
Source File: mainMenu.py From universalSmashSystem with GNU General Public License v3.0 | 5 votes |
def executeMenu(self,_screen): self.clock = pygame.time.Clock() self.screen = _screen self.controls = [] for i in range(0,4): self.controls.append(settingsManager.getControls(i)) while self.status == 0: music = musicManager.getMusicManager() music.doMusicEvent() for event in pygame.event.get(): if event.type == pygame.QUIT: #Quitting the game should close it out completely self.status = -1 if event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE: #Hitting escape always counts as a back button self.status = 1 for control in self.controls: k = control.getInputs(event,False,False) if k == 'up': self.selected_option = (self.selected_option - 1) % len(self.menu_text) elif k == 'down': self.selected_option = (self.selected_option + 1) % len(self.menu_text) elif k == 'left': self.incrementOption(self.selected_option,-1) elif k == 'right': self.incrementOption(self.selected_option,1) elif k == 'confirm' or k == 'attack': self.confirmOption(self.selected_option) elif k == 'cancel' or k == 'special': self.status = 1 self.update(_screen) self.clock.tick(60) pygame.display.flip() return self.status
Example #20
Source File: qrtun_async.py From qrtun with MIT License | 5 votes |
def run(self): self.running = True while self.running: if self.read_tun() or self.display_cam: self.write_qrcode() if not self.read_cam(): running = False break self.read_qrcode() event = pygame.event.poll() if event.type == pygame.QUIT: self.running = False pygame.quit() elif event.type == pygame.KEYDOWN: if event.key == pygame.K_ESCAPE: self.running = False pygame.quit() elif event.key == pygame.K_UP: self.scale += 1 pygame.display.set_caption("qrtun - QR Code scale %d"%(self.scale)) self.write_qrcode() elif event.key == pygame.K_DOWN: self.scale -= 1 pygame.display.set_caption("qrtun - QR Code scale %d"%(self.scale)) self.write_qrcode() elif event.key == pygame.K_SPACE: self.display_cam = not self.display_cam self.write_qrcode() try: #os.unlink(self.outfile) os.unlink(self.infile) except: pass
Example #21
Source File: cli.py From stuntcat with GNU Lesser General Public License v2.1 | 5 votes |
def __pgbox(title, message): try: import pygame as pg pg.quit() #clean out anything running pg.display.init() pg.font.init() screen = pg.display.set_mode((460, 140)) pg.display.set_caption(title) font = pg.font.Font(None, 18) foreg, backg, liteg = (0, 0, 0), (180, 180, 180), (210, 210, 210) ok = font.render('Ok', 1, foreg, liteg) okbox = ok.get_rect().inflate(200, 10) okbox.centerx = screen.get_rect().centerx okbox.bottom = screen.get_rect().bottom - 10 screen.fill(backg) screen.fill(liteg, okbox) screen.blit(ok, okbox.inflate(-200, -10)) pos = [10, 10] for text in message.split('\n'): if text: msg = font.render(text, 1, foreg, backg) screen.blit(msg, pos) pos[1] += font.get_height() pg.display.flip() stopkeys = pg.K_ESCAPE, pg.K_SPACE, pg.K_RETURN, pg.K_KP_ENTER while 1: e = pg.event.wait() if e.type == pg.QUIT or \ (e.type == pg.KEYDOWN and e.key in stopkeys) or \ (e.type == pg.MOUSEBUTTONDOWN and okbox.collidepoint(e.pos)): break pg.quit() except pg.error: raise ImportError
Example #22
Source File: main.py From python-examples with MIT License | 5 votes |
def stage3(screen): button2 = Button((215, 5), (100, 100), (0,0,255), "BACK") # - mainloop - clock = pygame.time.Clock() running = True while running: # - events - for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() exit() elif event.type == pygame.KEYDOWN: if event.key == pygame.K_ESCAPE: pygame.quit() if button2.is_clicked(event): return # - draws - screen.fill((128,128,128)) button2.draw(screen) pygame.display.flip() # - FPS - clock.tick(FPS) # --- main --- # - init -
Example #23
Source File: eduactiv8.py From eduActiv8 with GNU General Public License v3.0 | 5 votes |
def main(): # create configuration object if android is not None or len(sys.argv) == 1: # Map the back button to the escape key. if android is not None: pygame.init() android.init() android.map_key(android.KEYCODE_BACK, pygame.K_ESCAPE) else: icon = pygame.image.load(os.path.join('res', 'icon', 'ico256.png')) pygame.display.set_icon(icon) configo = classes.config.Config(android) # create the language object lang = classes.lang.Language(configo, path) # create the Thread objects and start the threads speaker = classes.speaker.Speaker(lang, configo, android) #cancel out checking for updates so that the PC does not have to connect to the Internet updater = None #classes.updater.Updater(configo, android) app = GamePlay(speaker, lang, configo, updater) if android is None: speaker.start() app.run() elif len(sys.argv) == 2: if sys.argv[1] == "v" or sys.argv[1] == "version": from classes.cversion import ver print("eduactiv8-%s" % ver) else: print("Sorry arguments not recognized.")
Example #24
Source File: gui18.py From pgu with GNU Lesser General Public License v2.1 | 5 votes |
def run(this): this.app.update() pygame.display.flip() this.font = pygame.font.SysFont("", 16) this.clock = timer.Clock() #pygame.time.Clock() done = False while not done: # Process events for ev in pygame.event.get(): if (ev.type == pygame.QUIT or ev.type == pygame.KEYDOWN and ev.key == pygame.K_ESCAPE): done = True else: # Pass the event off to pgu this.app.event(ev) # Render the game rect = this.app.get_render_area() updates = [] this.disp.set_clip(rect) lst = this.render(this.disp, rect) if (lst): updates += lst this.disp.set_clip() # Cap it at 30fps this.clock.tick(30) # Give pgu a chance to update the display lst = this.app.update() if (lst): updates += lst pygame.display.update(updates) pygame.time.wait(10) ###
Example #25
Source File: util.py From SwervinMervin with GNU General Public License v2.0 | 5 votes |
def try_quit(e): if e.type == QUIT or\ (e.type == pygame.KEYDOWN and\ e.key == pygame.K_ESCAPE and\ s.FULLSCREEN): pygame.quit() sys.exit()
Example #26
Source File: FileDialog.py From PhotonFileEditor with GNU General Public License v3.0 | 5 votes |
def waitforuser(self): """ Blocks all events to Main window and wait for user to click OK. """ while self.waiting: self.redraw() pygame.display.flip() for event in pygame.event.get(): pos = pygame.mouse.get_pos() gpos=GPoint().fromTuple(pos) if event.type == pygame.MOUSEBUTTONUP: if self.dragDiff==None: for ctrl in self.controls: ctrl.handleMouseUp(pos,event.button) else: # handle window move self.dragDiff=None if event.type == pygame.MOUSEBUTTONDOWN: if gpos.inGRect(self.titlerect): self.dragDiff = gpos - self.winrect.p1 else: for ctrl in self.controls: ctrl.handleMouseDown(pos,event.button) if event.type == pygame.MOUSEMOTION: if not self.dragDiff==None: self.winrect.p1=gpos-self.dragDiff self.reposControls() else: for ctrl in self.controls: ctrl.handleMouseMove(pos) if event.type == pygame.KEYDOWN: if event.key == pygame.K_ESCAPE: print("Escape key pressed down.") self.waiting = False else: self.tbFilename.handleKeyDown(event.key, event.unicode)
Example #27
Source File: MessageDialog.py From PhotonFileEditor with GNU General Public License v3.0 | 5 votes |
def waitforuser(self): """ Blocks all events to Main window and wait for user to click OK. """ while self.waiting: self.redraw() pygame.display.flip() for event in pygame.event.get(): pos = pygame.mouse.get_pos() gpos=GPoint().fromTuple(pos) if event.type == pygame.MOUSEBUTTONUP: if self.dragDiff==None: for ctrl in self.controls: ctrl.handleMouseUp(pos,event.button) else: # handle window move self.dragDiff=None if event.type == pygame.MOUSEBUTTONDOWN: if gpos.inGRect(self.titlerect): self.dragDiff = gpos - self.winrect.p1 else: for ctrl in self.controls: ctrl.handleMouseDown(pos,event.button) if event.type == pygame.MOUSEMOTION: if not self.dragDiff==None: self.winrect.p1=gpos-self.dragDiff self.reposControls() else: for ctrl in self.controls: ctrl.handleMouseMove(pos) if event.type == pygame.KEYDOWN: if event.key == pygame.K_ESCAPE: print("Escape key pressed down.") self.waiting = False
Example #28
Source File: gui.py From ct-Raspi-Radiowecker with GNU General Public License v3.0 | 5 votes |
def process_events(self): clicked = False events = pygame.event.get() for event in events: # if the event is any type of quit request end the program if event.type == pygame.QUIT: quit() # resize the window if its requested elif event.type == pygame.VIDEORESIZE: self.window_size = event.size self.display_resize() # evaluate keypresses elif event.type == pygame.KEYDOWN: # exit on Escape if event.key == pygame.K_ESCAPE: quit() # switch to fullscreen on F11 elif event.key == pygame.K_F11: self.fullscreen = not self.fullscreen # evaluate all presses of the left mousebutton elif event.type == pygame.MOUSEBUTTONUP and event.button == 1: clicked = True self.clicktime = pygame.time.get_ticks() self.clickEvent = event click = None timediff = pygame.time.get_ticks() - self.clicktime if clicked and self.await_dblclk == False and self.click is None: self.await_dblclk = True pass elif clicked and timediff < self.dblclktime and self.await_dblclk: click = "double" self.await_dblclk = False elif timediff > self.dblclktime and self.await_dblclk: click = "single" self.await_dblclk = False if click != None: self.await_dblclk = False self.clicktime = 0 for element in self.elements: if hasattr(element, 'Callback') and element.Callback != None and element.Rect.collidepoint(self.clickEvent.pos): if click == "double" and element.DblclkCallback != None: element.DblclkCallback() else: element.Callback() # exit the programm
Example #29
Source File: main.py From pygame_tutorials with MIT License | 5 votes |
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)
Example #30
Source File: AISnake.py From AIGames with MIT License | 5 votes |
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()