Horje
timer pythongame Code Example
timer pythongame
import pygame
pygame.init()
screen = pygame.display.set_mode((128, 128))
clock = pygame.time.Clock()

counter, text = 10, '10'.rjust(3)
pygame.time.set_timer(pygame.USEREVENT, 1000)
font = pygame.font.SysFont('Consolas', 30)

while True:
    for e in pygame.event.get():
        if e.type == pygame.USEREVENT: 
            counter -= 1
            text = str(counter).rjust(3) if counter > 0 else 'boom!'
        if e.type == pygame.QUIT: break
    else:
        screen.fill((255, 255, 255))
        screen.blit(font.render(text, True, (0, 0, 0)), (32, 48))
        pygame.display.flip()
        clock.tick(60)
        continue
    break




Python

Related
how to convert a dense matrix into sparse matrix in python Code Example how to convert a dense matrix into sparse matrix in python Code Example
python element wise multiplication list Code Example python element wise multiplication list Code Example
boto3 with aws profile Code Example boto3 with aws profile Code Example
python create file Code Example python create file Code Example
datetimes to day of year python Code Example datetimes to day of year python Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
7