Py Codes
Py Codes
pygame.init()
window = pygame.display.set_mode((500, 500))
font = pygame.font.Font(None, 36)
text_surface = font.render('WORDS HERE', True, (255, 255, 255))
text_rect = text_surface.get_rect()
text_rect.center = (250, 250)
running = True
duration = 3000 # Duration in milliseconds (3 seconds)
start_time = pygame.time.get_ticks()
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
current_time = pygame.time.get_ticks()
elapsed_time = current_time - start_time
window.fill((0, 0, 0))
window.blit(text_surface, text_rect)
pygame.display.update()
# Initialize Pygame
pygame.init()
WIDTH, HEIGHT = 800, 600
FPS = 60
screen = pygame.display.set_mode((WIDTH, HEIGHT))
clock = pygame.time.Clock()
# Load image
image = pygame.image.load('image.png') # Replace 'image.png' with your image file
path
image_rect = image.get_rect()
# Game loop
running = True
while running:
clock.tick(FPS)
# Event handling
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
pygame.display.flip()