当前位置: 首页 > news >正文

2021没封的网站uc做积分商城网站

2021没封的网站uc,做积分商城网站,网站流量跟钱的关系,用于手机的导航网站要怎么做python和pygame实现烟花特效 新年来临之际#xff0c;来一个欢庆新年烟花祝贺#xff0c;需要安装使用第三方库pygame#xff0c;关于Python中pygame游戏模块的安装使用可见 https://blog.csdn.net/cnds123/article/details/119514520 效果图及源码 先看效果图#xff1a…python和pygame实现烟花特效 新年来临之际来一个欢庆新年烟花祝贺需要安装使用第三方库pygame关于Python中pygame游戏模块的安装使用可见 https://blog.csdn.net/cnds123/article/details/119514520 效果图及源码 先看效果图 源码如下 import pygame import random import math# 初始化pygame pygame.init()# 设置窗口大小 width, height 800, 600 screen pygame.display.set_mode((width, height))# 定义颜色 black (0, 0, 0) red (255, 0, 0)# 定义烟花粒子 class Particle:def __init__(self, x, y, color):self.x xself.y yself.color colorself.radius random.randint(2, 4)self.angle random.uniform(0, 2 * math.pi)self.speed random.uniform(1, 3)self.gravity 0.1def move(self):self.x math.cos(self.angle) * self.speedself.y math.sin(self.angle) * self.speed self.gravityself.radius - 0.1 # 粒子逐渐变小def draw(self):pygame.draw.circle(screen, self.color, (int(self.x), int(self.y)), int(self.radius))# 定义烟花 class Firework:def __init__(self, x, y):self.x xself.y yself.color (random.randint(0, 255), random.randint(0, 255), random.randint(0, 255))self.particles []self.exploded Falseself.explode_height random.randint(100, 400) # 设置爆炸高度self.speed random.randint(5, 10) # 设置上升速度self.angle math.pi / 2 # 设置上升角度为垂直向上def launch(self):if not self.exploded:self.y - self.speed * math.sin(self.angle)if self.y self.explode_height: # 到达设定高度后爆炸self.explode()self.exploded Truedef explode(self):for _ in range(100): # 爆炸产生的粒子数量self.particles.append(Particle(self.x, self.y, self.color))def draw(self):if not self.exploded:pygame.draw.circle(screen, self.color, (int(self.x), int(self.y)), 5)else:for particle in self.particles:particle.move()particle.draw()#显示文字 #font pygame.font.Font(None, 36) # 设置字体和大小 font pygame.font.Font(C:\\Windows\\Fonts\\simsun.ttc, 36) text font.render(龙年快乐, True, red) # 渲染文本 text_rect text.get_rect(center(width // 2, height // 2)) # 获取文本的矩形区域# 主循环 fireworks [] clock pygame.time.Clock() running True while running:clock.tick(30) # 控制帧率for event in pygame.event.get():if event.type pygame.QUIT:running Falsescreen.fill(black)# 绘制文本screen.blit(text, text_rect)# 发射烟花if random.randint(1, 20) 1: # 控制烟花发射频率fireworks.append(Firework(random.randint(0, width), height))# 更新烟花并绘制for firework in fireworks[:]:firework.launch()firework.draw()if firework.exploded and all(p.radius 0 for p in firework.particles):fireworks.remove(firework)pygame.display.flip()pygame.quit()pygame在屏幕上显示字体的方法说明 使用pygame.font.Font函数来设置字体和大小然后使用font.render函数将文本渲染为图像。最后使用screen.blit函数将渲染好的文本图像绘制到屏幕上。 pygame.font.Font(None, 字体大小)使用系统默认字体可能不支持汉字。None代表系统默认字体如pygame.font.Font(None, 36)可能不支持汉字。怎么办使用pygame.font. Font(“含路径的字体名”,字体大小)指定支持汉字的字体如pygame.font.Font(C:\\Windows\\Fonts\\simsun.ttc, 36)simsun.ttc是宋体字体的路径和名称。在windows中如何确定字体的路径和名称呢参见下图 改进添加背景音乐增添欢乐的气氛 在“# 主循环”部分前添加如下代码 # 载入背景音乐 pygame.mixer.music.load(踩着开心的节奏 - 橙光音乐.mp3) pygame.mixer.music.set_volume(0.5)  # 设置音量 pygame.mixer.music.play(-1)  #  播放背景音乐-1表示循环播放 其中pygame.mixer.music.load函数加载背景音乐文件例如名为踩着开心的节奏 - 橙光音乐.mp3文件并将其放在与代码文件相同的目录下然后使用pygame.mixer.music.set_volume函数设置音量大小范围为0.0-1.0。最后使用pygame.mixer.music.play函数播放背景音乐参数-1表示循环播放。 请你使用自己背景音乐文件替换踩着开心的节奏 - 橙光音乐.mp3只要保证正确命名文件名和路径即可。
http://wiki.neutronadmin.com/news/301641/

相关文章:

  • linux系统服务器怎么做网站网站没内容
  • 带有客户案例的网站公司名称大全集最新3个字
  • 网站页面做成自适应优缺点为什么我的网站百度不收录
  • 做界面网站用什么语言济宁网站建设流程
  • 网站改版设计流程网络推广哪个公司好
  • 网站打不开怎么办山东网站建设培训
  • 企业内部网站建设工厂怎么推广自己的产品
  • 深深圳市建设局网站做网上推广网站
  • 网站加强队伍建设全国小微企业名录查询官网
  • php购物网站开发桂林网站设计制作
  • 做网站和c 哪个好天猫网站是怎么做seo优化的
  • 网站开发项目范围说明书意义上海营销型网站
  • 企业网站建设上海网站建设的费用预算如何写
  • 手机网站图片轮播做网站的所有代码
  • 周口微网站制作怎么建网站手机版
  • 手机网站广告淘客推广有用吗
  • 百度推广多少钱seo排名优化关键词
  • 国内最有趣的网站深圳品牌网站建设
  • 太原市建设局网站黄冈网络推广服务平台
  • 前端和后端南山做网站推广乐云seo
  • 公众号首图制作网站关于网站集约化建设的意见
  • 石家庄网站建设专家四川省建设厅官方网站首页
  • 怎么做个网站演示免费wap自助建站火星建站
  • 网站上线前准备悟空crm的优势与不足
  • 商丘网站网站建设品牌官网设计
  • 一个专门做ppt的网站二次开发机器人
  • 公司网站开发排名成都微信小程序开发公司
  • 做外贸大一点的网站销客多
  • 在线设计网站可以做ps和ppt网站购物车怎么做
  • 利用店铺网站做灰色优化快站app