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

宁波易企网做的网站常州做网站哪家好

宁波易企网做的网站,常州做网站哪家好,北京市住房和城乡建设部网站,佛山网站建设公司哪家性价比高目录 新年祝福语 一、作品展示 二、作品所用资源 三、代码与资源说明 四、代码库 五、完整代码 六、总结 新年祝福语 岁月总是悄然流转#xff0c;让人感叹时间的飞逝#xff0c;转眼间又快到了中国传统的新年#xff08;龙年#xff09;。 回首过去#xf…目录 新年祝福语 一、作品展示  二、作品所用资源  三、代码与资源说明  四、代码库 五、完整代码  六、总结  新年祝福语 岁月总是悄然流转让人感叹时间的飞逝转眼间又快到了中国传统的新年龙年。 回首过去我们经历了许多挑战也收获了成长。展望未来我们充满期待。 在这特别的时刻我想对所有粉丝送上真挚祝福。愿新年带给你们无尽的快乐与幸福健康与平安。 感谢你们的支持新的一年我将继续努力创造更多精彩。 祝大家新年快乐 一、作品展示  以下是我用 [python] 制作的一个新年小作品希望大家喜欢龙年背景图是免费下载的 二、作品所用资源  由于 pygame 本身不支持中文显示所以需要自行下载中文字体而其自带的数字字体不好看所以也一并下载了代码中的字体与背景图大家自行更换。 1. 小清新中文字体 2. 立体数字字体 3. 免费的背景图 三、代码与资源说明  百度云盘完整资源下载新年快乐 这里展示代码与资源存放位置是为了方便大家看代码时容易理解其中的内容。  四、代码库 本文主要用到了以下四个库。如果大家还没安装可以 win r 输入 cmd 安装。 pip install pygame pip install random pip install math pip install os 五、完整代码  以下是完整的代码。其中爆竹音效我没有添加但有预留实现接口大家如果感兴趣可以网上找相应的音频文件并且将已注释的接口打开来播放即可。 import pygame import random import math import os# 初始化pygame pygame.init()# 设置窗口大小和标题 screen_width, screen_height 800, 600 screen pygame.display.set_mode((screen_width, screen_height)) pygame.display.set_caption(Fireworks)# 加载动态背景图 bg_images [] for i in range(1, 3): # 替换为你的动态背景图文件名的范围image_path fD:\\share\\python\\HappNewYear\\pic\\dragon_animation_{i}.png # 替换为你的动态背景图路径image pygame.image.load(image_path).convert()bg_images.append(image)# 加载爆炸音效 # explosion_sound pygame.mixer.Sound(explosion.wav)# 定义烟花线条类 class FireworkParticle(pygame.sprite.Sprite):def __init__(self, x, y, color):super().__init__()self.color colorself.length random.randint(5, 15) # 线条长度self.angle random.uniform(0, 2 * math.pi)self.speed random.uniform(1, 5)self.dx self.speed * math.cos(self.angle)self.dy self.speed * math.sin(self.angle)self.gravity 0.1self.x xself.y ydef update(self):self.x self.dxself.y self.dyself.dy self.gravitydef draw(self, screen):end_x self.x self.length * math.cos(self.angle)end_y self.y self.length * math.sin(self.angle)pygame.draw.line(screen, self.color, (self.x, self.y), (end_x, end_y), 2) # 绘制线条# 颜色列表 colors [(253, 215, 88), (254, 254, 252), (255, 255, 217), (252, 253, 249), (248, 247, 106), (255, 255, 162)]# 字体显示 font_path os.path.join(os.path.dirname(__file__), font_ttf\\xiaoqingxin.ttf) zn_font pygame.font.Font(font_path, 100) def font_show(font, string, color):text font.render(string, True, color)text_rect text.get_rect(center(screen_width // 2, screen_height // 2))screen.blit(text, text_rect)# 烟花爆炸函数 def explode(x, y, timeout):# explosion_sound.play() # 播放爆炸音效particles pygame.sprite.Group()for _ in range(1000): #燃放的烟火密度值越大越好看color random.choice(colors)particle FireworkParticle(x, y, color) # 烟花燃放位置particles.add(particle)# 爆炸动画循环current_bg_image 0 # 当前显示的背景图索引last_explode_time pygame.time.get_ticks()while True:current_time pygame.time.get_ticks()if current_time - last_explode_time timeout:break # 退出循环particles.update()# 切换背景图if current_time % 50 0: # 每50毫秒切换一次背景图current_bg_image (current_bg_image 1) % len(bg_images)screen.blit(bg_images[current_bg_image], (0, 0)) # 绘制背景图font_show(zn_font, 龙年行大运, (255, 0, 0))for particle in particles:particle.draw(screen) # 绘制烟花粒子pygame.display.flip() # 更新屏幕显示pygame.time.Clock().tick(60) # 控制帧率# explosion_sound.stop() # 停止音效# 显示新年倒数 def countdown():screen.fill((255, 0, 0)) # 清空屏幕font_show(zn_font, 跨年倒数, (255, 215, 0))pygame.display.flip() # 更新屏幕显示pygame.time.delay(1000) # 延迟1秒# font pygame.font.Font(None, 100)font_path os.path.join(os.path.dirname(__file__), font_ttf\\Antology.ttf)font pygame.font.Font(font_path, 100)countdown_time 3 # 倒数时间last_countdown_time pygame.time.get_ticks()while countdown_time 0:current_time pygame.time.get_ticks()if current_time - last_countdown_time 1000:last_countdown_time current_timecountdown_time - 1screen.fill((255, 0, 0)) # 清空屏幕font_show(font, str(countdown_time), (255, 215, 0))pygame.display.flip() # 更新屏幕显示pygame.time.Clock().tick(60) # 控制帧率screen.fill((255, 0, 0)) # 清空屏幕font_show(zn_font, 积步千里祝大家, (255, 215, 0))pygame.display.flip() # 更新屏幕显示pygame.time.delay(1000) # 延迟1秒screen.fill((255, 0, 0)) # 清空屏幕font_show(zn_font, 新年快乐, (255, 215, 0))pygame.display.flip() # 更新屏幕显示pygame.time.delay(1000) # 延迟1秒# 主程序循环 running True auto_explode_interval 2000 # 自动循环燃放的时间间隔毫秒 last_explode_time pygame.time.get_ticks()countdown() # 显示新年倒数while running:for event in pygame.event.get():if event.type pygame.QUIT:running Falsecurrent_time pygame.time.get_ticks()if current_time - last_explode_time auto_explode_interval:last_explode_time current_timex_offset screen_width // 2 - 240y_offset screen_heightfor i in range(4):x_offset (i * 80)y_offset screen_height // (2 i)explode(x_offset, y_offset, 2000)pygame.display.flip() # 更新屏幕显示pygame.time.Clock().tick(60) # 控制帧率# 退出pygame pygame.quit()六、总结  至此本文内容已全部讲解完毕。祝愿大家在新的一年里龙腾虎跃龙行天下龙凤呈祥
http://www.pierceye.com/news/290950/

相关文章:

  • 素材网站怎么做利用小程序反向做网站
  • 怎么自己做网站地图做网站详细步骤
  • 做网站的整体风格确定方式郑州seo代理外包
  • 语种网站建设沭阳做网站好的
  • wordpress网站换字体颜色网站建设案例包括哪些
  • 北京市环境建设办公室网站怎么找到合适的网站建设商
  • 网站在线优化中国品牌加盟网
  • 网站可以做章子吗什么是网络营销?其特点是什么?
  • 网站优化人员中小型网站设计公司
  • 旅游网网站的设计wordpress添加网页背景图片大小
  • 学网站建设难不难wordpress5分钟安装
  • 建网站优化中山做网站专业的公司
  • 网站cmd做路由分析七牛云官网登录
  • 怎么在网站上打广告网站制作方案范文
  • 关键词搜不到我的网站wordpress 内网访问
  • 检察机关门户网站建设工作自查报告网站建设服务领域
  • 网站排名seo软件泉州高端模板建站
  • 昆山网站建设苦瓜网站建设费用会计分录
  • 免费pc网站建设网页设计与制作自学
  • 酒店 网站构建东莞常平碧桂园铂悦府
  • 子域名做微信开放平台网站应用公司做网站需要网站维护人员吗
  • 百度游戏排行榜风云榜青岛seo关键词优化排名
  • html写手机网站备案网站负责人
  • 做网站价位西安工程建设信息中心
  • 国外购物网站建设盐城做网站的哪家公司好
  • wordpress仿站软件遵化市城乡建设规划局网站
  • 湖北大网站建设贵州住房建设厅官网查询
  • 买个网站域名要多少钱一年网站建设热门吗
  • 高埗网站建设软件开发工程师就是程序员吗
  • 青岛正一品网站建设seo搜索优化排名