亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

python+pygame實(shí)現(xiàn)代碼雨(黑客帝國(guó)既視感)

 更新時(shí)間:2021年03月18日 09:52:35   作者:乎你  
這篇文章主要介紹了python+pygame實(shí)現(xiàn)代碼雨(黑客帝國(guó)既視感),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧

本文主要介紹了python+pygame實(shí)現(xiàn)代碼雨,分享給大家,具體如下:

效果:

#!/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()
# 創(chuàng)建一個(gè)可是窗口
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))
# 數(shù)字版
# 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)]
# 按屏幕的寬帶計(jì)算可以在畫(huà)板上放幾列坐標(biāo)并生成一個(gè)列表
column = int(PANEL_width / FONT_PX)
drops = [0 for i in range(column)]
while True:
  # 從隊(duì)列中獲取事件
  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()
  # 將暫停一段給定的毫秒數(shù)
  pygame.time.delay(40)
  # 重新編輯圖像第二個(gè)參數(shù)是坐上角坐標(biāo)
  winSur.blit(bg_suface, (0, 0))
  for i in range(len(drops)):
    text = random.choice(texts)
    # 重新編輯每個(gè)坐標(biāo)點(diǎn)的圖像
    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()

到此這篇關(guān)于python+pygame實(shí)現(xiàn)代碼雨(黑客帝國(guó)既視感)的文章就介紹到這了,更多相關(guān)pygame 代碼雨 內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評(píng)論