30 May 2005 01:24
Re: Improved pygame inputbox
On Sunday 29 May 2005 11:10 pm, Daniel Bickett wrote: > Couldn't you improve the performance by only rendering more text if > the text has changed? From a cursory scan through the code it seems as > if you're rendering the text every loop, but couldn't you have > display_box return its surface object, to be continually blitted until > another character is entered and new text must be rendered? It already does this. Notice this is part of the "while True" loop in the ask() function: > pygame.time.wait(50) > event = pygame.event.poll() > > if event.type == QUIT: > sys.exit() > if event.type != KEYDOWN: > continue If no keep is pressed, the loop restarts. Thus, it waits for a keypress before drawing anything new. Because the input-box is blocking, there is also no need to reblit the screen. -- -- James Reeves http://www.monkeyengines.co.uk/
RSS Feed