python - Making text appear one character at a time [PyGame] -
i trying make dialog appear 1 character @ time (like in pokemon games , other similar).
i have searched on internet have not managed find helpful.
i aware of question asked this, didn't solve trying do. know can done because have seen games made python has been done.
import pygame, sys pygame.locals import * window_width = 500 window_height = 500 pygame.init() displaysurf = pygame.display.set_mode((window_width, window_height)) black = ( 0, 0, 0) white = (255, 255, 255) def display_text_animation(string): text = '' in range(len(string)): displaysurf.fill(white) text += string[i] text_surface = font.render(text, true, black) text_rect = text_surface.get_rect() text_rect.center = (window_width/2, window_height/2) displaysurf.blit(text_surface, text_rect) pygame.display.update() pygame.time.wait(100) def main(): while true: event in pygame.event.get(): if event.type == quit: pygame.quit() sys.exit() display_text_animation('hello world!') main()
note: haven't used pygame before may not work.
Comments
Post a Comment