第三版本最终确认——《愤怒的小鸟梦幻爆破》上线回归,爆赞官网介绍
序
《愤怒的小鸟》其实活得还不错,虽然我们一直在嘲笑它的IP帝国梦。但你知道,恐怕只有它能做休闲益智游戏这一行。
特别是,它是这样一个古老、过时和难以相信的游戏。从前两期的效果来看,大家还是很喜欢这款游戏的~嘿!我是栗子,
今天终于迎来了最终版本~这一期给大家讲完了,《愤怒的小鸟最终版》第三期讲完了!稍后,我会考虑为您更新什么。爬虫的内容一般过不了关。
这没办法!还有其他游戏和opencv可以给大家更新和学习!如果你想学习,也可以在评论区留言。说不定下次更新就是你的评论啦~
主体
I)运行环境本文使用的环境:Python3.6、Pycharm社区版、Pygame游戏模块和pymunk模块未显示。
pip install-I https://pypi.douban.com/simple/模块名称图片素材:(有很多素材,如音频、字体、图片等。所以我不会给他们看。有很多,啊,有一点是随机展示的)。
2)代码显示代码分为四个块,内容中有许多代码。这里直接展示主程序,其他的都是直接从我这里拿的,直接给大家看效果吧!
主程序:
import osimport sysimport mathimport timeimport pygamecurrent_path=os.getcwd()import pymunk as pmfrom characters import Birdfrom level import Levelpygame.init()screen=pygame.display.set_mode((1200, 650))redbird=pygame.image.load( './resources/images/red-bird3.png').convert_alpha()background2=pygame.image.load( './resources/images/background3.png').convert_alpha()sling_image=pygame.image.load( './resources/images/sling-3.png').convert_alpha()full_sprite=pygame.image.load( './resources/images/full-sprite.png').convert_alpha()rect=pygame.Rect(181, 1050, 50, 50)cropped=full_sprite.subsurface(rect).copy()pig_image=pygame.transform.scale(cropped, (30, 30))buttons=pygame.image.load( './resources/images/selected-buttons.png').convert_alpha()pig_happy=pygame.image.load( './resources/images/pig_failed.png').convert_alpha()stars=pygame.image.load( './resources/images/stars-edited.png').convert_alpha()rect=pygame.Rect(0, 0, 200, 200)star1=stars.subsurface(rect).copy()rect=pygame.Rect(204, 0, 200, 200)star2=stars.subsurface(rect).copy()rect=pygame.Rect(426, 0, 200, 200)star3=stars.subsurface(rect).copy()rect=pygame.Rect(164, 10, 60, 60)pause_button=buttons.subsurface(rect).copy()rect=pygame.Rect(24, 4, 100, 100)replay_button=buttons.subsurface(rect).copy()rect=pygame.Rect(142, 365, 130, 100)next_button=buttons.subsurface(rect).copy()clock=pygame.time.Clock()rect=pygame.Rect(18, 212, 100, 100)play_button=buttons.subsurface(rect).copy()clock=pygame.time.Clock()running=True# the base of the physicsspace=pm.Space()space.gravity=(0.0, -700.0)pigs=[]birds=[]balls=[]polys=[]beams=[]columns=[]poly_points=[]ball_number=0polys_dict={}mouse_distance=0rope_lenght=90angle=0x_mouse=0y_mouse=0count=0mouse_pressed=Falset1=0tick_to_next_circle=10RED=(255, 0, 0)BLUE=(0, 0, 255)BLACK=(0, 0, 0)WHITE=(255, 255, 255)sling_x, sling_y=135, 450sling2_x, sling2_y=160, 450score=0game_state=0bird_path=[]counter=0restart_counter=Falsebonus_score_once=Truebold_font=pygame.font.SysFont('arial', 30, bold=True)bold_font2=pygame.font.SysFont('arial', 40, bold=True)bold_font3=pygame.font.SysFont('arial', 50, bold=True)wall=False# Static floorstatic_body=pm.Body(body_type=pm.Body.STATIC)static_lines=[pm.Segment(static_body, (0.0, 060.0), (1200.0, 060.0), 0.0)]static_lines1=[pm.Segment(static_body, (1200.0, 060.0), (1200.0, 800.0), 0.0)]for line in static_lines: line.elasticity=0.95 line.friction=1 line.collision_type=3for line in static_lines1: line.elasticity=0.95 line.friction=1 line.collision_type=3space.add(static_body)for line in static_lines: space.add(line)def to_pygame(p): '''Convert pymunk to pygame coordinates''' return int(p.x), int(-p.y+600)def vector(p0, p1): '''Return the vector of the points p0=(xo,yo), p1=(x1,y1)''' a=p1[0] - p0[0] b=p1[1] - p0[1] return (a, b)def unit_vector(v): '''Return the unit vector of the points v=(a,b)''' h=((v[0]**2)+(v[1]**2))**0.5 if h==0: h=0.000000000000001 ua=v[0]/h ub=v[1]/h return (ua, ub)def distance(xo, yo, x, y): '''distance between points''' dx=x - xo dy=y - yo d=((dx ** 2) + (dy ** 2)) ** 0.5 return ddef load_music(): '''Load the music''' song1='./resources/sounds/angry-birds.ogg' pygame.mixer.music.load(song1) pygame.mixer.music.play(-1)def sling_action(): '''Set up sling behavior''' global mouse_distance global rope_lenght global angle global x_mouse global y_mouse # Fixing bird to the sling rope v=vector((sling_x, sling_y), (x_mouse, y_mouse)) uv=unit_vector(v) uv1=uv[0] uv2=uv[1] mouse_distance=distance(sling_x, sling_y, x_mouse, y_mouse) pu=(uv1*rope_lenght+sling_x, uv2*rope_lenght+sling_y) bigger_rope=102 x_redbird=x_mouse - 20 y_redbird=y_mouse - 20 if mouse_distance rope_lenght: pux, puy=pu pux -=20 puy -=20 pul=pux, puy screen.blit(redbird, pul) pu2=(uv1*bigger_rope+sling_x, uv2*bigger_rope+sling_y) pygame.draw.line(screen, (0, 0, 0), (sling2_x, sling2_y), pu2, 5) screen.blit(redbird, pul) pygame.draw.line(screen, (0, 0, 0), (sling_x, sling_y), pu2, 5) else: mouse_distance +=10 pu3=(uv1*mouse_distance+sling_x, uv2*mouse_distance+sling_y) pygame.draw.line(screen, (0, 0, 0), (sling2_x, sling2_y), pu3, 5) screen.blit(redbird, (x_redbird, y_redbird)) pygame.draw.line(screen, (0, 0, 0), (sling_x, sling_y), pu3, 5) # Angle of impulse dy=y_mouse - sling_y dx=x_mouse - sling_x if dx==0: dx=0.00000000000001 angle=math.atan((float(dy))/dx)def draw_level_cleared(): '''Draw level cleared''' global game_state global bonus_score_once global score level_cleared=bold_font3.render('Level Cleared!', 1, WHITE) score_level_cleared=bold_font2.render(str(score), 1, WHITE) if level.number_of_birds=0 and len(pigs)==0: if bonus_score_once: score +=(level.number_of_birds-1) * 10000 bonus_score_once=False game_state=4 rect=pygame.Rect(300, 0, 600, 800) pygame.draw.rect(screen, BLACK, rect) screen.blit(level_cleared, (450, 90)) if score=level.one_star and score=level.two_star: screen.blit(star1, (310, 190)) if score=level.two_star and score=level.three_star: screen.blit(star1, (310, 190)) screen.blit(star2, (500, 170)) if score=level.three_star: screen.blit(star1, (310, 190)) screen.blit(star2, (500, 170)) screen.blit(star3, (700, 200)) screen.blit(score_level_cleared, (550, 400)) screen.blit(replay_button, (510, 480)) screen.blit(next_button, (620, 480))def draw_level_failed(): '''Draw level failed''' global game_state failed=bold_font3.render('Level Failed', 1, WHITE) if level.number_of_birds=0 and time.time() - t2 5 and len(pigs) 0: game_state=3 rect=pygame.Rect(300, 0, 600, 800) pygame.draw.rect(screen, BLACK, rect) screen.blit(failed, (450, 90)) screen.blit(pig_happy, (380, 120)) screen.blit(replay_button, (520, 460))def restart(): '''Delete all objects of the level''' pigs_to_remove=[] birds_to_remove=[] columns_to_remove=[] beams_to_remove=[] for pig in pigs: pigs_to_remove.append(pig) for pig in pigs_to_remove: space.remove(pig.shape, pig.shape.body) pigs.remove(pig) for bird in birds: birds_to_remove.append(bird) for bird in birds_to_remove: space.remove(bird.shape, bird.shape.body) birds.remove(bird) for column in columns: columns_to_remove.append(column) for column in columns_to_remove: space.remove(column.shape, column.shape.body) columns.remove(column) for beam in beams: beams_to_remove.append(beam) for beam in beams_to_remove: space.remove(beam.shape, beam.shape.body) beams.remove(beam)def post_solve_bird_pig(arbiter, space, _): '''Collision between bird and pig''' surface=screen a, b=arbiter.shapes bird_body=a.body pig_body=b.body p=to_pygame(bird_body.position) p2=to_pygame(pig_body.position) r=30 pygame.draw.circle(surface, BLACK, p, r, 4) pygame.draw.circle(surface, RED, p2, r, 4) pigs_to_remove=[] for pig in pigs: if pig_body==pig.body: pig.life -=20 pigs_to_remove.append(pig) global score score +=10000 for pig in pigs_to_remove: space.remove(pig.shape, pig.shape.body) pigs.remove(pig)def post_solve_bird_wood(arbiter, space, _): '''Collision between bird and wood''' poly_to_remove=[] if arbiter.total_impulse.length 1100: a, b=arbiter.shapes for column in columns: if b==column.shape: poly_to_remove.append(column) for beam in beams: if b==beam.shape: poly_to_remove.append(beam) for poly in poly_to_remove: if poly in columns: columns.remove(poly) if poly in beams: beams.remove(poly) space.remove(b, b.body) global score score +=5000def post_solve_pig_wood(arbiter, space, _): '''Collision between pig and wood''' pigs_to_remove=[] if arbiter.total_impulse.length 700: pig_shape, wood_shape=arbiter.shapes for pig in pigs: if pig_shape==pig.shape: pig.life -=20 global score score +=10000 if pig.life=0: pigs_to_remove.append(pig) for pig in pigs_to_remove: space.remove(pig.shape, pig.shape.body) pigs.remove(pig)# bird and pigsspace.add_collision_handler(0, 1).post_solve=post_solve_bird_pig# bird and woodspace.add_collision_handler(0, 2).post_solve=post_solve_bird_wood# pig and woodspace.add_collision_handler(1, 2).post_solve=post_solve_pig_woodload_music()level=Level(pigs, columns, beams, space)level.number=0level.load_level()while running: # Input handling for event in pygame.event.get(): if event.type==pygame.QUIT: running=False elif event.type==pygame.KEYDOWN and event.key==pygame.K_ESCAPE: running=False elif event.type==pygame.KEYDOWN and event.key==pygame.K_w: # Toggle wall if wall: for line in static_lines1: space.remove(line) wall=False else: for line in static_lines1: space.add(line) wall=True elif event.type==pygame.KEYDOWN and event.key==pygame.K_s: space.gravity=(0.0, -10.0) level.bool_space=True elif event.type==pygame.KEYDOWN and event.key==pygame.K_n: space.gravity=(0.0, -700.0) level.bool_space=False if (pygame.mouse.get_pressed()[0] and x_mouse 100 and x_mouse 250 and y_mouse 370 and y_mouse 550): mouse_pressed=True if (event.type==pygame.MOUSEBUTTONUP and event.button==1 and mouse_pressed): # Release new bird mouse_pressed=False if level.number_of_birds 0: level.number_of_birds -=1 t1=time.time()*1000 xo=154 yo=156 if mouse_distance rope_lenght: mouse_distance=rope_lenght if x_mouse sling_x+5: bird=Bird(mouse_distance, angle, xo, yo, space) birds.append(bird) else: bird=Bird(-mouse_distance, angle, xo, yo, space) birds.append(bird) if level.number_of_birds==0: t2=time.time() if event.type==pygame.MOUSEBUTTONUP and event.button==1: if (x_mouse 60 and y_mouse 155 and y_mouse 90): game_state=1 if game_state==1: if x_mouse 500 and y_mouse 200 and y_mouse 300: # Resume in the paused screen game_state=0 if x_mouse 500 and y_mouse 300: # Restart in the paused screen restart() level.load_level() game_state=0 bird_path=[] if game_state==3: # Restart in the failed level screen if x_mouse 500 and x_mouse 620 and y_mouse 450: restart() level.load_level() game_state=0 bird_path=[] score=0 if game_state==4: # Build next level if x_mouse 610 and y_mouse 450: restart() level.number +=1 game_state=0 level.load_level() score=0 bird_path=[] bonus_score_once=True if x_mouse 610 and x_mouse 500 and y_mouse 450: # Restart in the level cleared screen restart() level.load_level() game_state=0 bird_path=[] score=0 x_mouse, y_mouse=pygame.mouse.get_pos() # Draw background screen.fill((130, 200, 100)) screen.blit(background2, (0, -50)) # Draw first part of the sling rect=pygame.Rect(50, 0, 70, 220) screen.blit(sling_image, (138, 420), rect) # Draw the trail left behind for point in bird_path: pygame.draw.circle(screen, WHITE, point, 5, 0) # Draw the birds in the wait line if level.number_of_birds 0: for i in range(level.number_of_birds-1): x=100 - (i*35) screen.blit(redbird, (x, 508)) # Draw sling behavior if mouse_pressed and level.number_of_birds 0: sling_action() else: if time.time()*1000 - t1 300 and level.number_of_birds 0: screen.blit(redbird, (130, 426)) else: pygame.draw.line(screen, (0, 0, 0), (sling_x, sling_y-8), (sling2_x, sling2_y-7), 5) birds_to_remove=[] pigs_to_remove=[] counter +=1 # Draw birds for bird in birds: if bird.shape.body.position.y 0: birds_to_remove.append(bird) p=to_pygame(bird.shape.body.position) x, y=p x -=22 y -=20 screen.blit(redbird, (x, y)) pygame.draw.circle(screen, BLUE, p, int(bird.shape.radius), 2) if counter=3 and time.time() - t1 5: bird_path.append(p) restart_counter=True if restart_counter: counter=0 restart_counter=False # Remove birds and pigs for bird in birds_to_remove: space.remove(bird.shape, bird.shape.body) birds.remove(bird) for pig in pigs_to_remove: space.remove(pig.shape, pig.shape.body) pigs.remove(pig) # Draw static lines for line in static_lines: body=line.body pv1=body.position + line.a.rotated(body.angle) pv2=body.position + line.b.rotated(body.angle) p1=to_pygame(pv1) p2=to_pygame(pv2) pygame.draw.lines(screen, (150, 150, 150), False, [p1, p2]) i=0 # Draw pigs for pig in pigs: i +=1 # print (i,pig.life) pig=pig.shape if pig.body.position.y 0: pigs_to_remove.append(pig) p=to_pygame(pig.body.position) x, y=p angle_degrees=math.degrees(pig.body.angle) img=pygame.transform.rotate(pig_image, angle_degrees) w,h=img.get_size() x -=w*0.5 y -=h*0.5 screen.blit(img, (x, y)) pygame.draw.circle(screen, BLUE, p, int(pig.radius), 2) # Draw columns and Beams for column in columns: column.draw_poly('columns', screen) for beam in beams: beam.draw_poly('beams', screen) # Update physics dt=1.0/50.0/2. for x in range(2): space.step(dt) # make two updates per frame for better stability # Drawing second part of the sling rect=pygame.Rect(0, 0, 60, 200) screen.blit(sling_image, (120, 420), rect) # Draw score score_font=bold_font.render('SCORE', 1, WHITE) number_font=bold_font.render(str(score), 1, WHITE) screen.blit(score_font, (1060, 90)) if score==0: screen.blit(number_font, (1100, 130)) else: screen.blit(number_font, (1060, 130)) screen.blit(pause_button, (10, 90)) # Pause option if game_state==1: screen.blit(play_button, (500, 200)) screen.blit(replay_button, (500, 300)) draw_level_cleared() draw_level_failed() pygame.display.flip() clock.tick(50) pygame.display.set_caption('fps: ' + str(clock.get_fps()))
3)
第一个层次
2)
3)其他级别(随机截图)
4)未能闯关
其实关卡还是很多的,只有猪自己跳起来,需要你去打.非常有趣好玩。如果你想自己尝试下一个级别,请向我索要源代码!
总结嘻嘻,这个第三版真的很好玩,喜欢的小可爱记得关注哦!
材料齐全等。滴滴我!私信边肖06可以获得源代码。
过去我推荐阅读——项目1.0 《愤怒的小鸟》全系列游戏——。这些游戏你都玩过,你有一个碉堡~(版本1)项目1.1 《愤怒的小鸟》全系列游戏——风靡全国。
空降奴隶改革:愤怒的猪攻击~(版本2)项目1.2 Pygame游戏:玩扫雷是盲目的,不仅是你。Project 1.3 Pygame游戏:崩溃《球球版—贪吃蛇蛇》,你中招了吗?
越来越多的源代码等你来领区!
文章摘要——摘要:Python文章合集|(实战介绍、游戏、海龟、案例等。)(文章总结还有更多的案例等你来学习~免费给我找源代码!)
版权声明
1、本文内容转载自第三版本最终确认——《愤怒的小鸟梦幻爆破》上线回归,爆赞(),或有会员发布,版权归原网站/法人所有。
2、本站仅提供信息发布平台,不承担相关法律责任。
3、文章仅代表作者个人观点,不代表本站立场,未经作者许可,不得转载。
4、若侵犯您的版权或隐私,请联系本站管理员删除。
口碑点评
警告:请理性点评、打分,请文明用语!请给“第三版本最终确认——《愤怒的小鸟梦幻爆破》上线回归,爆赞”打分并给出您的宝贵点评意见
第三版本最终确认——《愤怒的小鸟梦幻爆破》上线回归,爆赞收录查询
第三版本最终确认——《愤怒的小鸟梦幻爆破》上线回归,爆赞SEO综合查询
-
搜索引擎百度PC百度移动头条搜狗360pPC360移动神马
-
权重
-
关键词
-
IP来路
推荐网站
-
盘点几款冷门的国产单机佳作,玩过这些的年纪应该都不小了
2000年前后,应该是国产单机游戏发展的一个黄金期,那个时期的单机市场游戏种类繁多,内容五花八门,让许多平时足不出户的玩家,也能经历丰富的人生奇遇。虽然这个时期的游戏作品良莠不齐,但还是涌现了许多国产单机神作。譬如传统RPG类型的有国产三剑
更新时间:2024-01-25 04:13:37 -
初代《愤怒的小鸟》再遭下架:竟是为了让大家都去玩新作?
初代《愤怒的小鸟》再一次从谷歌应用商店消失了。火爆一时的移动游戏《愤怒的小鸟》于2009年推出,2012年正式上架国区安卓应用商店,到现在已超过10年。在很长一段时间里,国区因为庞大的下载量成为这一系列最大的市场。这款休闲游戏玩法简单,但结
更新时间:2024-01-25 04:13:37 -
每日推荐:女生的最爱的消除手游超过王者荣耀
今天给大家推荐几款好玩的消除类游戏,小编的手机里也保存着消消乐跟蒙特祖玛3。开心消消乐这个游戏长期霸占排行榜,画面卡通,音乐效果好,玩起来爱不释手。玩法还可以比较多样,总的来说不亏榜首这个位置。天天爱消除 “山寨之王”腾讯出品,爆破小鸟式的
更新时间:2024-01-25 04:13:37 -
愤怒的小鸟梦幻爆破:“过气网红”还有如此让人无法自拔的游戏
时隔三年,愤怒的小鸟和蠢蠢的绿猪,再一次在电影《愤怒的小鸟2》中聚首。只不过这次,十年“欢喜冤家”终于放下芥蒂。在电影中,“不速之客”袭击了小鸟岛和绿猪岛。于是,小鸟岛昔日英雄“胖红”联合小鸟们,与曾经的对手绿猪“雷纳德”一行组建了临时联盟
更新时间:2024-01-25 04:13:37 -
不走寻常路的另类消除-《小鸟爆破》
优点: 可爱的Q版小鸟造型,紧张刺激的游戏节奏不足: 对策略、反应速度和手速有一定要求游戏简介:三、二、一,Bomb!相信大家都已经在《愤怒的小鸟》中见识过小鸟化为子弹时无坚不摧的威力,无独有偶,这款消除类游戏《小鸟爆破》中的小鸟也一样是很
更新时间:2024-01-25 04:13:37 -
魔兽世界PVE史:第四章 巅峰 (一)傲视群雄
作者:零守护(CoBeT)第四章 巅峰(一)傲视群雄 2010年10月12日,暴雪发布了魔兽世界的第三部资料片——《大地的裂变》的前夕版本4.0.1。地精和狼人加入到了玩家可选种族里,原来的天赋出现了巨大的改动——85级即将来临。11月23
更新时间:2024-01-25 04:13:37 -
绝地求生玩家为何从380万暴跌到30万?魔兽世界老玩家说出6个字
吃鸡这款游戏自2017年4月上市后、于当年10月开始走红,最高曾达到380万在数。而今它的在线人数降至30万左右,只有全盛时期的十分之一。多数人认为外挂是毁灭吃鸡的罪魁祸首,但也有人持不同意见:可达鸭眉头一皱,发现事情并不简单。究竟是什么
更新时间:2024-01-25 04:13:37 -
魔兽世界史上最难团本:按错一个键团灭,九成玩家没见过BOSS
魔兽世界至今为止,哪个团队副本设计最出色?可能有人会说巫妖王陨落的冰冠堡垒,也可能有人提名曾经60年代的经典熔火之心。但X博士觉得,WOW至今为止,设计最出彩最经典的团本依然是奥杜尔!由于当时国服跳过了奥杜尔版本,直接开了3.2十字军的试炼
更新时间:2024-01-25 04:13:37 -
《魔兽世界》-「冰冠堡垒」成就龙攻略(8.0版本)
魔兽世界有各种各样酷炫的成就坐骑,有很多新入坑的玩家不知道这些五花八门的成就到底要怎么完成,下面小编将会介绍巫妖王版本-【冰冠堡垒】团本—成就龙坐骑的攻略,希望对大家有所帮助。小知识科普:冰冠堡垒-ICC(冰冠堡垒 的 英文简称:Icecr
更新时间:2024-01-25 04:13:37 -
《魔兽世界》8.0「大地的裂变团队的荣耀」成就龙攻略
前2天分享了,【ICC冰冠堡垒】的团本成就龙攻略,发现还有很多玩家不知道,不了解的。本以为魔兽只剩一些老兵了,通过测试 ,原来还有很多跟小编一样蠢萌蠢萌的新玩家,所以今天给大家介绍下【大地的裂变团队的荣耀】成就龙攻略。大地的裂变团队荣耀需要
更新时间:2024-01-25 04:13:37