濮阳杆衣贸易有限公司

主頁(yè) > 知識(shí)庫(kù) > python+pygame實(shí)現(xiàn)代碼雨(黑客帝國(guó)既視感)

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

熱門標(biāo)簽:長(zhǎng)春人工智能電銷機(jī)器人官網(wǎng) 地圖標(biāo)注推廣單頁(yè) n400電話申請(qǐng)多少錢 如何在地圖標(biāo)注文字 百應(yīng)ai電銷機(jī)器人鄭州 廈門crm外呼系統(tǒng)如何 女王谷地圖標(biāo)注 西藏快速地圖標(biāo)注地點(diǎn) ai地圖標(biāo)注

本文主要介紹了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ì)算可以在畫板上放幾列坐標(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)文章希望大家以后多多支持腳本之家!

您可能感興趣的文章:
  • python 基于pygame實(shí)現(xiàn)俄羅斯方塊
  • python pygame 憤怒的小鳥游戲示例代碼
  • Python Pygame實(shí)現(xiàn)俄羅斯方塊
  • python之pygame模塊實(shí)現(xiàn)飛機(jī)大戰(zhàn)完整代碼
  • Python使用Pygame繪制時(shí)鐘
  • python基于pygame實(shí)現(xiàn)飛機(jī)大作戰(zhàn)小游戲
  • 如何基于Python pygame實(shí)現(xiàn)動(dòng)畫跑馬燈
  • Python3.8安裝Pygame教程步驟詳解
  • python+pygame實(shí)現(xiàn)坦克大戰(zhàn)小游戲的示例代碼(可以自定義子彈速度)
  • Python趣味挑戰(zhàn)之教你用pygame畫進(jìn)度條

標(biāo)簽:內(nèi)江 廊坊 拉薩 興安盟 亳州 綿陽(yáng) 黔東 渭南

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《python+pygame實(shí)現(xiàn)代碼雨(黑客帝國(guó)既視感)》,本文關(guān)鍵詞  python+pygame,實(shí)現(xiàn),代碼,雨,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《python+pygame實(shí)現(xiàn)代碼雨(黑客帝國(guó)既視感)》相關(guān)的同類信息!
  • 本頁(yè)收集關(guān)于python+pygame實(shí)現(xiàn)代碼雨(黑客帝國(guó)既視感)的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    昭平县| 白沙| 曲麻莱县| 洛宁县| 巫溪县| 上林县| 尤溪县| 信丰县| 马边| 马公市| 安乡县| 健康| 金门县| 勐海县| 东阿县| 伽师县| 专栏| 乐安县| 平利县| 威宁| 宿迁市| 沛县| 池州市| 桐梓县| 溆浦县| 北碚区| 平远县| 元江| 铜川市| 白玉县| 民权县| 邹城市| 北辰区| 芦山县| 阜城县| 商都县| 贵定县| 托克托县| 唐山市| 郧西县| 雅安市|