Es raro porque a mi si me funciona con clock.tick(<frame_segundo>) como puedes ver en mi código:
https://github.com/mdtrooper/pyretro 2017-02-07 4:44 GMT+01:00 miquel parera <computer.music.n...@gmail.com>: > Hola > > Disculpad mi pregunta de novato, pero hay algo en el manejo del tiempo que > no acabo de entender. Quiero que, al clickar un cuadradro, se torne blanco > y, al segundo, vuelva a ser negro. > Pero ni pygame.time.delay(1000) funcionan ni time.sleep(1) funcionan. > > Alguna idea? gracias! > > import pygame > > # Pygame screen > # Cuadrados > # Añadir tiempo al click > > # colores > > BLACK = ( 0, 0, 0) > WHITE = ( 255, 255, 255) > GREEN = ( 0, 255, 0) > RED = ( 255, 0, 0) > > # iniciar pygame > > pygame.init() > > # caracteristicas de la ventana > > size = (260,260) > screen = pygame.display.set_mode(size) > > pygame.display.set_caption("Pantalla") > > # definir array de cuadro (10x10) > > width = 20 > height = 20 > margin = 5 > > grid = [[0 for x in range(10)] for y in range(10)] > > > # control de procesos > > done = False > > clock = pygame.time.Clock() > > # loop principal > > while not done: > > for event in pygame.event.get(): > if event.type == pygame.QUIT: > done = True > > # evento de click > > elif event.type == pygame.MOUSEBUTTONDOWN: > column = pos[0] // (width + margin) > row = pos[1] // (height + margin) > # print > print("Click ", pos, "Coordenadas: ", row, column) > grid[row][column] = 1 > pygame.time.delay(1000) > grid[row][column] = 0 > > # lógica de click > pos = pygame.mouse.get_pos() > x = pos[0] > y = pos[1] > > #color de fondo > > screen.fill(WHITE) > > # dibujar cuadro > > for row in range(10): > for column in range(10): > if grid[row][column] == 1: > color = WHITE > else: > color = BLACK > pygame.draw.rect(screen, color, [margin + (margin + width) * > column, margin + (margin + height) * row, width, height]) > > > > # escribir todo > > pygame.display.flip() > > clock.tick(60) > > # finalizar > > pygame.quit() > > > > > -- > > > Musicnumbers Netlabel (for almost silence): http://musicnumbers.es/ > > _______________________________________________ > Python-es mailing list > Python-es@python.org > https://mail.python.org/mailman/listinfo/python-es > _______________________________________________ Python-es mailing list Python-es@python.org https://mail.python.org/mailman/listinfo/python-es