Python编程实现大雪纷飞

大雪纷飞。

Python编程实现大雪纷飞_第1张图片

import pygame
import random
import math
import numpy as np

# 配置参数
SCREEN_WIDTH, SCREEN_HEIGHT = 1280, 720
SNOW_COLOR = (245, 245, 255)
TERRAIN_COLOR = (45, 65, 89)
BACKGROUND_COLOR = (13, 27, 42)


class TerrainGenerator:
    """多噪声融合地形生成器:ml-citation{ref="3,7" data="citationList"}"""

    def __init__(self, width):
        self.width = width
        self.base_height = SCREEN_HEIGHT // 3

    def generate(self):
        x = np.linspace(0, 5, self.width)
        noise1 = np.sin(x * 2) * 25
        noise2 = np.cos(x * 0.5) * 40
        return (self.base_height + noise1 + noise2).astype(int)


class Snowflake:
    """带风力影响的雪花粒子:ml-citation{ref="2,6" data="citationList"}"""

    def __init__(self):
        sel

你可能感兴趣的:(pygame,python)