# coding: utf-8
import random
import pygame
from pygame.locals import FULLSCREEN
FONT_PX = 15
resolution = (1920, 1080)
pygame.init()
winSur = pygame.display.set_mode(resolution, FULLSCREEN)
font = pygame.font.SysFont("fangsong", 20)
bg_suface = pygame.Surface(resolution, flags=pygame.SRCALPHA)
pygame.Surface.convert(bg_suface)
bg_suface.fill(pygame.Color(0, 0, 0, 13))
winSur.fill((0, 0, 0))
# 数字
# texts = [font.render(str(i), True, (0, 255, 0)) for i in range(10)]
texts = [font.render(str(i), True, (0, 255, 0)) for i in range(10)]
colums = int(1920 / FONT_PX)
drops = [0 for i in range(colums)]
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
exit()
pygame.time.delay(10)
winSur.blit(bg_suface, (0, 0))
# 重新编辑图像
for i in range(len(drops)):
text = random.choice(texts)
# 重新编辑每个坐标点的图像
winSur.blit(text, (i * FONT_PX, drops[i] * FONT_PX))
drops[i] += 1
if drops[i] * 10 > 1080 or random.random() > 0.95:
drops[i] = 0
pygame.display.flip()
数雨
最新推荐文章于 2023-08-10 18:28:04 发布