⽤python实现⿊客帝国数字⾬效果代码实现:
import random,pygame
def shuzi():
FONT_PX =15
pygame.init()
winSur = pygame.display.set_mode((500,600))
font = pygame.font.SysFont('fangsong',20)
bg_suface = pygame.Surface((500,600), flags=pygame.SRCALPHA)
vert(bg_suface)
bg_suface.fill(pygame.Color(0,0,0,13))
winSur.fill((0,0,0))
# 数字
texts =[der(str(i),True,(0,255,0))for i in range(10)]
colums =int(500/ FONT_PX)
drops =[0for i in range(colums)]
while True:
for event in ():
pe== pygame.QUIT:
exit()
pygame.time.delay(33)
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>600or random.random()>0.95:
精通css第三版pdfdrops[i]=0
pygame.display.flip()
def zimu():
PANEL_width =400
PANEL_highly =500
FONT_PX =15
pygame.init()
# 创建⼀个窗⼝
winSur = pygame.display.set_mode((PANEL_width, PANEL_highly))python基础代码大全黑客
font = pygame.font.SysFont('f',22)
使用结构体的好处bg_suface = pygame.Surface((PANEL_width, PANEL_highly), flags=pygame.SRCALPHA)
vert(bg_suface)
bg_suface.fill(pygame.Color(0,0,0,28))
winSur.fill((0,0,0))
随机数赋值给数组
letter =['q','w','e','r','t','y','u','i','o','p','a','s','d','f','g','h','j','k','l','z','x','c',
'v','b','n','m']
texts =[
]
# 按窗⼝的宽度来计算可以在画板上放⼏列坐标并⽣成⼀个列表
column =int(PANEL_width / FONT_PX)
数据库电子书下载drops =[0for i in range(column)]
while True:
# 从队列中获取事件
for event in ():
pe== pygame.QUIT:
exit()
pe== pygame.KEYDOWN:
chang = _pressed()
if(chang[32]):
exit()
# 暂停给定的毫秒数
pygame.time.delay(30)
# 重新编辑图像
winSur.blit(bg_suface,(0,0))
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
firefox browser
if drops[i]*10> PANEL_highly or random.random()>0.95:                drops[i]=0
pygame.display.flip()
shuzi()
# zimu()
运⾏效果
数字⾬
字母⾬

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。