• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

python+pygame实现代码雨(黑客帝国既视感)

python 搞代码 4年前 (2022-01-08) 34次浏览 已收录 0个评论

这篇文章主要介绍了python+pygame实现代码雨(黑客帝国既视感),文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧

本文主要介绍了python+pygame实现代码雨,分享给大家,具体如下:

 #!/usr/bin/env python # -*- coding: utf-8 -*- # @Time  : 2020/12/29 12:34 # @Author : huni # @File  : 代码雨.py # @Software: PyCharm import random import pygame PANEL_width = 1600 PANEL_highly = 1000 FONT_PX = 15 pygame.init() # 创建一个可是窗口 winSur = pygame.display.set_mode((PANEL_width, PANEL_highly)) font = pygame.font.SysFont("123.ttf", 25) bg_suface = pygame.Surface((PANEL_width, PANEL_highly), flags=pygame.SRCALPHA) pygame.Surface.convert(bg_suface) bg_suface.fill(pygame.Color(0, 0, 0, 28)) winSur.fill((0, 0, 0)) # 数字版 # texts = [font.render(str(i), True, (0, 255, 0)) for i in range(10)] #texts = [ #font.render(str(letter[i]), True, (0, 255, 0)) for i in range(26) #] # 字母版 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 = [ font.render(str(letter[i]), True, (0, 255, 0)) for i in range(26) ] texts = [font.render(str(i), True, (0, 255, 0)) for i in range(2)] # 按屏幕的宽带计算可以在画板上放几列坐标并生成一个列表 column = int(PANEL_width / FONT_PX) drops = [0 for i in range(column)] while True: # 从队列中获取事件 for event in pygame.event.get(): if event.type == pygame.QUIT: exit() elif event.type == pygame.KEYDOWN: chang = pygame.key.get_pressed() if (chang[32]): exit() # 将暂停一段给定的毫秒数 pygame.time.delay(40) # 重新编辑图像第二个参数是坐上角坐标 winSur.blit(bg_suface, (0, 0)) for i in range<span style="color:transparent">来源gaodai#ma#com搞*!代#%^码$网</span>(len(drops)): text = random.choice(texts) # 重新编辑每个坐标点的图像 winSur.blit(text, (i * FONT_PX, drops[i] * FONT_PX)) drops[i] += 1 if drops[i] * 10 > PANEL_highly or random.random() > 0.95: drops[i] = 0 pygame.display.flip() 

以上就是python+pygame实现代码雨(黑客帝国既视感)的详细内容,更多请关注gaodaima搞代码网其它相关文章!


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:python+pygame实现代码雨(黑客帝国既视感)
喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址