from__future__importdivisionfrom__future__importprint_functionimportsysimportpygameAPP_NAME=sys.argv[0]SCREEN_SIZE=(1280,720)MAX_FPS=60defmain():pygame.init()screen=pygame.display.set_mode(SCREEN_SIZE)clock=pygame.time.Clock()running=True# set up game here# main loopwhilerunning:# game logic# event loopforeventinpygame.event.get():ifevent.type==pygame.KEYDOWN:ifevent.keyin(pygame.K_ESCAPE,):# default handler just exits on Escrunning=Falseelse:# unhandled eventprint(event)elifevent.type==pygame.QUIT:running=False# finish framepygame.display.flip()frame_time=clock.tick(MAX_FPS)pygame.display.set_caption("%s - %d FPS"%(APP_NAME,int(1000/frame_time)))if__name__=="__main__":try:main()finally:pygame.quit()
Comments (0)
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.