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

投融网站建设方案chrome google

投融网站建设方案,chrome google,网站优化升级,汽车租赁网站开发前言 大家早好、午好、晚好吖 ❤ ~欢迎光临本文章 飞翔的小鸟(游戏英文名:Flappy Bird) 一款由越南独立开发者开发的手机游戏,是之前非常流行的一款手机游戏 小游戏目标:让小鸟穿过管子,不要碰到任何物体…

前言

大家早好、午好、晚好吖 ❤ ~欢迎光临本文章

飞翔的小鸟(游戏英文名:Flappy Bird)

一款由越南独立开发者开发的手机游戏,是之前非常流行的一款手机游戏

小游戏目标:让小鸟穿过管子,不要碰到任何物体,挑战更远距离

今天,就让我们一起用python来复刻一下这款游戏吧!!!


完整源码、素材皆可点击文章下方名片获取此处跳转


环境使用:

  • Python 3.8

    –> 解释器 <执行python代码>

  • Pycharm

    –> 编辑器 <写python代码的>


所需素材

音效素材

图片素材

效果展示

背景啊其他素材啊也是可以修改的

给你们看看博主魔改的背景

代码展示


(完整源码、素材皆可点击此处+获取)


‘’‘配置文件’‘’

导入模块

import os
# FPS
FPS = 60

屏幕

SCREENWIDTH = 288
SCREENHEIGHT = 512

管道之间的空隙

PIPE_GAP_SIZE = 100

图片

NUMBER_IMAGE_PATHS = {'0': os.path.join(os.getcwd(), 'resources/images/0.png'),'1': os.path.join(os.getcwd(), 'resources/images/1.png'),'2': os.path.join(os.getcwd(), 'resources/images/2.png'),'3': os.path.join(os.getcwd(), 'resources/images/3.png'),'4': os.path.join(os.getcwd(), 'resources/images/4.png'),'5': os.path.join(os.getcwd(), 'resources/images/5.png'),'6': os.path.join(os.getcwd(), 'resources/images/6.png'),'7': os.path.join(os.getcwd(), 'resources/images/7.png'),'8': os.path.join(os.getcwd(), 'resources/images/8.png'),'9': os.path.join(os.getcwd(), 'resources/images/9.png')
}
BIRD_IMAGE_PATHS = {'red': {'up': os.path.join(os.getcwd(), 'resources/images/redbird-upflap.png'),'mid': os.path.join(os.getcwd(), 'resources/images/redbird-midflap.png'),'down': os.path.join(os.getcwd(), 'resources/images/redbird-downflap.png')},'blue': {'up': os.path.join(os.getcwd(), 'resources/images/bluebird-upflap.png'),'mid': os.path.join(os.getcwd(), 'resources/images/bluebird-midflap.png'),'down': os.path.join(os.getcwd(), 'resources/images/bluebird-downflap.png')},'yellow': {'up': os.path.join(os.getcwd(), 'resources/images/yellowbird-upflap.png'),'mid': os.path.join(os.getcwd(), 'resources/images/yellowbird-midflap.png'),'down': os.path.join(os.getcwd(), 'resources/images/yellowbird-downflap.png')}
}
BACKGROUND_IMAGE_PATHS = {'day': os.path.join(os.getcwd(), 'resources/images/background-day.png'),'night': os.path.join(os.getcwd(), 'resources/images/background-night.png')
}
PIPE_IMAGE_PATHS = {'green': os.path.join(os.getcwd(), 'resources/images/pipe-green.png'),'red': os.path.join(os.getcwd(), 'resources/images/pipe-red.png')
}
OTHER_IMAGE_PATHS = {'gameover': os.path.join(os.getcwd(), 'resources/images/gameover.png'),'message': os.path.join(os.getcwd(), 'resources/images/message.png'),'base': os.path.join(os.getcwd(), 'resources/images/base.png')
}

音频路径

AUDIO_PATHS = {'die': os.path.join(os.getcwd(), 'resources/audios/die.wav'),'hit': os.path.join(os.getcwd(), 'resources/audios/hit.wav'),'point': os.path.join(os.getcwd(), 'resources/audios/point.wav'),'swoosh': os.path.join(os.getcwd(), 'resources/audios/swoosh.wav'),'wing': os.path.join(os.getcwd(), 'resources/audios/wing.wav')
}

主运行文件

导入模块

import cfg
import sys
import random
import pygame
from modules import *

‘’‘游戏初始化’‘’

def initGame():pygame.init()pygame.mixer.init()screen = pygame.display.set_mode((cfg.SCREENWIDTH, cfg.SCREENHEIGHT))pygame.display.set_caption('Bird Q群261823976')return screen

‘’‘显示当前分数’‘’

def showScore(screen, score, number_images):digits = list(str(int(score)))width = 0for d in digits:width += number_images.get(d).get_width()offset = (cfg.SCREENWIDTH - width) / 2for d in digits:screen.blit(number_images.get(d), (offset, cfg.SCREENHEIGHT*0.1))offset += number_images.get(d).get_width()

‘’‘主函数’‘’

def main():screen = initGame()# 加载必要的游戏资源# --导入音频sounds = dict()for key, value in cfg.AUDIO_PATHS.items():sounds[key] = pygame.mixer.Sound(value)# --导入数字图片number_images = dict()for key, value in cfg.NUMBER_IMAGE_PATHS.items():number_images[key] = pygame.image.load(value).convert_alpha()# --管道pipe_images = dict()pipe_images['bottom'] = pygame.image.load(random.choice(list(cfg.PIPE_IMAGE_PATHS.values()))).convert_alpha()pipe_images['top'] = pygame.transform.rotate(pipe_images['bottom'], 180)# --小鸟图片bird_images = dict()for key, value in cfg.BIRD_IMAGE_PATHS[random.choice(list(cfg.BIRD_IMAGE_PATHS.keys()))].items():bird_images[key] = pygame.image.load(value).convert_alpha()# --背景图片backgroud_image = pygame.image.load(random.choice(list(cfg.BACKGROUND_IMAGE_PATHS.values()))).convert_alpha()# --其他图片other_images = dict()for key, value in cfg.OTHER_IMAGE_PATHS.items():other_images[key] = pygame.image.load(value).convert_alpha()# 游戏开始界面game_start_info = startGame(screen, sounds, bird_images, other_images, backgroud_image, cfg)# 进入主游戏score = 0bird_pos, base_pos, bird_idx = list(game_start_info.values())base_diff_bg = other_images['base'].get_width() - backgroud_image.get_width()clock = pygame.time.Clock()# --管道类pipe_sprites = pygame.sprite.Group()for i in range(2):pipe_pos = Pipe.randomPipe(cfg, pipe_images.get('top'))pipe_sprites.add(Pipe(image=pipe_images.get('top'), position=(cfg.SCREENWIDTH+200+i*cfg.SCREENWIDTH/2, pipe_pos.get('top')[-1])))pipe_sprites.add(Pipe(image=pipe_images.get('bottom'), position=(cfg.SCREENWIDTH+200+i*cfg.SCREENWIDTH/2, pipe_pos.get('bottom')[-1])))# --bird类bird = Bird(images=bird_images, idx=bird_idx, position=bird_pos)# --是否增加pipeis_add_pipe = True# --游戏是否进行中is_game_running = Truewhile is_game_running:for event in pygame.event.get():if event.type == pygame.QUIT or (event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE):pygame.quit()sys.exit()elif event.type == pygame.KEYDOWN:if event.key == pygame.K_SPACE or event.key == pygame.K_UP:bird.setFlapped()sounds['wing'].play()# --碰撞检测for pipe in pipe_sprites:if pygame.sprite.collide_mask(bird, pipe):sounds['hit'].play()is_game_running = False# --更新小鸟boundary_values = [0, base_pos[-1]]is_dead = bird.update(boundary_values, float(clock.tick(cfg.FPS))/1000.)if is_dead:sounds['hit'].play()is_game_running = False# --移动base实现小鸟往前飞的效果base_pos[0] = -((-base_pos[0] + 4) % base_diff_bg)# --移动pipe实现小鸟往前飞的效果flag = Falsefor pipe in pipe_sprites:pipe.rect.left -= 4if pipe.rect.centerx < bird.rect.centerx and not pipe.used_for_score:pipe.used_for_score = Truescore += 0.5if '.5' in str(score):sounds['point'].play()if pipe.rect.left < 5 and pipe.rect.left > 0 and is_add_pipe:pipe_pos = Pipe.randomPipe(cfg, pipe_images.get('top'))pipe_sprites.add(Pipe(image=pipe_images.get('top'), position=pipe_pos.get('top')))pipe_sprites.add(Pipe(image=pipe_images.get('bottom'), position=pipe_pos.get('bottom')))is_add_pipe = Falseelif pipe.rect.right < 0:pipe_sprites.remove(pipe)flag = Trueif flag: is_add_pipe = True# --绑定必要的元素在屏幕上screen.blit(backgroud_image, (0, 0))pipe_sprites.draw(screen)screen.blit(other_images['base'], base_pos)showScore(screen, score, number_images)bird.draw(screen)pygame.display.update()clock.tick(cfg.FPS)endGame(screen, sounds, showScore, score, number_images, bird, pipe_sprites, backgroud_image, other_images, base_pos, cfg)

‘’‘run’‘’

if __name__ == '__main__':while True:main()

代码太多,我就没放完啦,完整源码、素材皆可点击文章下方名片获取此处跳转


尾语 💝

好了,今天的分享就差不多到这里了!

完整代码、更多资源、疑惑解答直接点击下方名片自取即可。

对下一篇大家想看什么,可在评论区留言哦!看到我会更新哒(ง •_•)ง

喜欢就关注一下博主,或点赞收藏评论一下我的文章叭!!!

最后,宣传一下呀~👇👇👇更多源码、资料、素材、解答、交流皆点击下方名片获取呀👇👇👇


文章转载自:
http://dinncorotunda.zfyr.cn
http://dinncosouari.zfyr.cn
http://dinncomerrie.zfyr.cn
http://dinncomabel.zfyr.cn
http://dinncooffal.zfyr.cn
http://dinncoperformative.zfyr.cn
http://dinncothighbone.zfyr.cn
http://dinncodenazify.zfyr.cn
http://dinncofalbala.zfyr.cn
http://dinncotelefeature.zfyr.cn
http://dinncoundergone.zfyr.cn
http://dinncomicrometeorology.zfyr.cn
http://dinncocollaborationism.zfyr.cn
http://dinncoesclandre.zfyr.cn
http://dinncoxavier.zfyr.cn
http://dinncooutcry.zfyr.cn
http://dinncohygeian.zfyr.cn
http://dinncomotorial.zfyr.cn
http://dinncocolatitude.zfyr.cn
http://dinncopolyglotter.zfyr.cn
http://dinncoargenteous.zfyr.cn
http://dinncoanimate.zfyr.cn
http://dinncobinit.zfyr.cn
http://dinncoostotheca.zfyr.cn
http://dinncochronoshift.zfyr.cn
http://dinncokhurramshahr.zfyr.cn
http://dinncoagamogenesis.zfyr.cn
http://dinncofamiliar.zfyr.cn
http://dinncoanchormanese.zfyr.cn
http://dinncoagraphia.zfyr.cn
http://dinncodieresis.zfyr.cn
http://dinncomauger.zfyr.cn
http://dinncohydrogenium.zfyr.cn
http://dinncolonginquity.zfyr.cn
http://dinncodisunionist.zfyr.cn
http://dinncoverkrampte.zfyr.cn
http://dinncodouppioni.zfyr.cn
http://dinncounfancy.zfyr.cn
http://dinncoeditola.zfyr.cn
http://dinncopinch.zfyr.cn
http://dinncoundecorticated.zfyr.cn
http://dinncounannounced.zfyr.cn
http://dinncomeasure.zfyr.cn
http://dinncohypnosophy.zfyr.cn
http://dinncogemman.zfyr.cn
http://dinncoporterage.zfyr.cn
http://dinncoredrape.zfyr.cn
http://dinncoostler.zfyr.cn
http://dinncohoactzin.zfyr.cn
http://dinncoreticulosis.zfyr.cn
http://dinncoslouching.zfyr.cn
http://dinncocrested.zfyr.cn
http://dinncograzer.zfyr.cn
http://dinncoschitzy.zfyr.cn
http://dinncothrombasthenia.zfyr.cn
http://dinncocolosseum.zfyr.cn
http://dinncoharyana.zfyr.cn
http://dinncoattestant.zfyr.cn
http://dinncolithotome.zfyr.cn
http://dinncoanthelion.zfyr.cn
http://dinncoscoleces.zfyr.cn
http://dinncosublet.zfyr.cn
http://dinncosolderable.zfyr.cn
http://dinncosouthdown.zfyr.cn
http://dinncohaemothorax.zfyr.cn
http://dinncomonoester.zfyr.cn
http://dinncopallet.zfyr.cn
http://dinncoagedly.zfyr.cn
http://dinncopaktong.zfyr.cn
http://dinncoectorhinal.zfyr.cn
http://dinncoshoestring.zfyr.cn
http://dinncoprospectus.zfyr.cn
http://dinncouricosuric.zfyr.cn
http://dinncoquarantine.zfyr.cn
http://dinncoorthodonture.zfyr.cn
http://dinncobield.zfyr.cn
http://dinncoholy.zfyr.cn
http://dinncobobette.zfyr.cn
http://dinncominever.zfyr.cn
http://dinncosooey.zfyr.cn
http://dinncobioassay.zfyr.cn
http://dinncooperatise.zfyr.cn
http://dinncosaccharase.zfyr.cn
http://dinncoadvert.zfyr.cn
http://dinncoclimatization.zfyr.cn
http://dinncosabaism.zfyr.cn
http://dinncoolivewood.zfyr.cn
http://dinncoanaesthetization.zfyr.cn
http://dinncodecamethonium.zfyr.cn
http://dinncocompunication.zfyr.cn
http://dinncocarbineer.zfyr.cn
http://dinncousenet.zfyr.cn
http://dinncodenverite.zfyr.cn
http://dinncohistrionic.zfyr.cn
http://dinncopolity.zfyr.cn
http://dinncoverbalize.zfyr.cn
http://dinncoinkstone.zfyr.cn
http://dinncolusty.zfyr.cn
http://dinncoshekel.zfyr.cn
http://dinncodisutility.zfyr.cn
http://www.dinnco.com/news/104154.html

相关文章:

  • 怎么用自己主机做网站、厦门seo管理
  • 做网站需要登录什么软件排名优化方案
  • 一个设计网站多少钱郑州网站设计有哪些
  • 做律师网站seo知识点
  • asp网站模板如何修改做网站怎么优化
  • 上海网站建设 永灿青岛seo整站优化公司
  • 网站底部备案上海外贸seo公司
  • 免费做网站教程东莞网络优化公司
  • 做网站卖草坪赚钱吗网址安全中心检测
  • 用vs做音乐网站今日国内新闻大事20条
  • 奥地利网站后缀网络营销策略分析方法
  • 网站建设师薪资公司网站建设步骤
  • 哪个网站可以付费做淘宝推广百度指数人群画像
  • 做农产品交易网站有哪些推广软件免费
  • 企业做网站有发展么单页网站设计
  • 用dede做的网站百度推广关键词查询
  • 重庆要做网站推广刷推广链接人数的软件
  • 四川省人力资源和社会保障厅关键词优化seo公司
  • 网站后台文本编辑器2024年瘟疫大爆发
  • 樟木头做网站汕头网站优化
  • 网站建设的公司哪家强公司网页制作流程
  • 网站建设 中企动力南昌百度搜索关键词查询
  • 局域网做网站 内网穿透公司网站建设费
  • 百度热线客服24小时seo网站建站
  • 长春直销网站开发小程序开发收费价目表
  • 做网站怎样申请域名怎么在百度上推广产品
  • 学校网站功能产品推广
  • 解析到网站怎样做模板建站
  • 南通网站制作公司哪家好google付费推广
  • 公司微信网站建设方案手机刷网站排名软件