Python登录注册系统介绍,Python登录注册模块

本篇文章给大家谈谈Python登录注册页面连接数据库,以及Python登录注册密码只能输三次,希望对各位有所帮助,不要忘了收藏本站喔。

#!/usr/bin/python
# -*- coding: UTF-8 -*-
import pygame
import random
import time  # 导入time模块

# 设置窗口尺寸
WIDTH, HEIGHT = 800, 600
# 颜色定义
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
RED = (255, 0, 0)
GREEN = (0, 255, 0)
BLUE = (0, 0, 255)
YELLOW = (255, 255, 0)

# 初始化pygame
()
screen = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("Fireworks")

# 定义Firework(烟花)类
class Firework:
    def __init__(self):
        self.x = random.randint(50, WIDTH - 50)
        self.y = HEIGHT
        self.color = (random.randint(0, 255), random.randint(0, 255), random.randint(0, 255))
        self.speed = random.randint(5, 12)

    def move(self):
        self.y -= self.speed

    def explode(self, sparks):
        for _ in range(50):
            spark = Spark(self.x, self.y, self.color)
            sparks.append(spark)

    def draw(self, screen):
        .circle(screen, self.color, (self.x, self.y), 3)

# 定义Spark(火花)类
class Spark:
    def __init__(self, x, y, color):
        self.x = x
        self.y = y
        self.color = color
        self.speedx = random.uniform(-1, 1) * 8
        self.speedy = random.uniform(-1, 1) * 8
         = 0

    def move(self):
        self.x += self.speedx
        self.y += self.speedy
        self.speedy += 0.2
         += 1

    def draw(self, screen):
        .circle(screen, self.color, (int(self.x), int(self.y)), 2)

# 主循环
clock = .Clock()

fireworks = []
sparks = []

running = True
start_time = .get_ticks()  # 获取程序开始的时间
total_run_time = 60 * 3  # 设置程序总运行时间为3分钟
current_run_time = 0  # 当前程序运行时间

while current_run_time < total_run_time:  # 循环条件改为判断当前运行时间是否小于总运行时间
    for event in ():
        if  == :
            running = False

    (BLACK)

    # 创建新烟花
    if random.random() < 0.02:
        fireworks.append(Firework())

    # 更新和绘制烟花
    for firework in fireworks:
        ()
        (screen)

        if firework.y < random.randint(50, HEIGHT // 2):
            firework.explode(sparks)
            fireworks.remove(firework)

    # 移动和绘制火花
    for spark in sparks:
        ()
        (screen)

        if  > 100:
            sparks.remove(spark)

    ()
    (60)

    # 更新程序当前运行时间
    current_run_time = (.get_ticks() - start_time) / 1000  # 转换为秒
    time.sleep(0.1)  # 添加时间延迟,让程序暂停0.1秒

()

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值