文学起点网
当前位置: 首页 文学百科

愤怒的小鸟宇宙版激活码(第三版本最终确认)

时间:2023-08-02 作者: 小编 阅读量: 2 栏目名: 文学百科

第三版本最终确认前言《愤怒的小鸟》其实活得还不错,尽管我们一直在嘲笑它的IP帝国梦做得太大但要知道,把休闲益智游戏的生意做到这个份上的,恐怕也就独此一家了尤其还是这样的一款古早、过时、难让人相信还能翻出什么花样的游戏。

前言

《愤怒的小鸟》其实活得还不错,尽管我们一直在嘲笑它的IP帝国梦做得太大。

但要知道,把休闲益智游戏的生意做到这个份上的,恐怕也就独此一家了。尤其还是这样的一

款古早、过时、难让人相信还能翻出什么花样的游戏。继前两期的效果来看,大家还是依旧挺

喜欢这款游戏的啦~嘿!我是栗子,今天终于迎来了最终版本啦~

这一期给大家写完《愤怒的小鸟最终版》三期完结撒花!

后续再想想给大家更新一些什么内容,爬虫的内容一般过不了,这就没办法!还有其他的游

戏、opencv方面的可以给大家继续更新研究一下啦!大家如果有想学的也可以评论区评论,或

许下一次更新的内容就是你的评论哦~

正文一)运行环境

本文用到的环境:Python3.6、Pycharm社区版、Pygame游戏模块、pymunk模块自带的就不展示。

pip install -i https://pypi.douban.com/simple/模块名

图片素材:

(还有很多素材音频、字体、图片等就不展示啦,比较多,啊随机展示了一点点)

二)代码展示

代码分为四大块,内容有很多代码,这里直接展示主程序,其他的直接找我拿,就直接给你们

看下效果展示一下哈!

​​

主程序:

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.95line.friction = 1line.collision_type = 3for line in static_lines1:line.elasticity = 0.95line.friction = 1line.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 pointsp0 = (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 pointsv = (a,b)"""h = ((v[0]**2) (v[1]**2))**0.5if h == 0:h = 0.000000000000001ua = v[0] / hub = v[1] / hreturn (ua, ub)def distance(xo, yo, x, y):"""distance between points"""dx = x - xody = y - yod = ((dx ** 2)(dy ** 2)) ** 0.5return 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_distanceglobal rope_lenghtglobal angleglobal x_mouseglobal y_mouse# Fixing bird to the sling ropev = 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 = 102x_redbird = x_mouse - 20y_redbird = y_mouse - 20if mouse_distance > rope_lenght:pux, puy = pupux -= 20puy -= 20pul = pux, puyscreen.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= 10pu3 = (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 impulsedy = y_mouse - sling_ydx = x_mouse - sling_xif dx == 0:dx = 0.00000000000001angle = math.atan((float(dy))/dx)def draw_level_cleared():"""Draw level cleared"""global game_stateglobal bonus_score_onceglobal scorelevel_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) * 10000bonus_score_once = Falsegame_state = 4rect = 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_statefailed = bold_font3.render("Level Failed", 1, WHITE)if level.number_of_birds <= 0 and time.time() - t2 > 5 and len(pigs) > 0:game_state = 3rect = 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=screena, b = arbiter.shapesbird_body = a.bodypig_body = b.bodyp = to_pygame(bird_body.position)p2 = to_pygame(pig_body.position)r = 30pygame.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 -= 20pigs_to_remove.append(pig)global scorescore= 10000for 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.shapesfor 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 scorescore= 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.shapesfor pig in pigs:if pig_shape == pig.shape:pig.life -= 20global scorescore= 10000if 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 handlingfor event in pygame.event.get():if event.type == pygame.QUIT:running = Falseelif event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE:running = Falseelif event.type == pygame.KEYDOWN and event.key == pygame.K_w:# Toggle wallif wall:for line in static_lines1:space.remove(line)wall = Falseelse:for line in static_lines1:space.add(line)wall = Trueelif event.type == pygame.KEYDOWN and event.key == pygame.K_s:space.gravity = (0.0, -10.0)level.bool_space = Trueelif event.type == pygame.KEYDOWN and event.key == pygame.K_n:space.gravity = (0.0, -700.0)level.bool_space = Falseif (pygame.mouse.get_pressed()[0] and x_mouse > 100 andx_mouse < 250 and y_mouse > 370 and y_mouse < 550):mouse_pressed = Trueif (event.type == pygame.MOUSEBUTTONUP andevent.button == 1 and mouse_pressed):# Release new birdmouse_pressed = Falseif level.number_of_birds > 0:level.number_of_birds -= 1t1 = time.time()*1000xo = 154yo = 156if mouse_distance > rope_lenght:mouse_distance = rope_lenghtif 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 = 1if game_state == 1:if x_mouse > 500 and y_mouse > 200 and y_mouse < 300:# Resume in the paused screengame_state = 0if x_mouse > 500 and y_mouse > 300:# Restart in the paused screenrestart()level.load_level()game_state = 0bird_path = []if game_state == 3:# Restart in the failed level screenif x_mouse > 500 and x_mouse < 620 and y_mouse > 450:restart()level.load_level()game_state = 0bird_path = []score = 0if game_state == 4:# Build next levelif x_mouse > 610 and y_mouse > 450:restart()level.number= 1game_state = 0level.load_level()score = 0bird_path = []bonus_score_once = Trueif x_mouse < 610 and x_mouse > 500 and y_mouse > 450:# Restart in the level cleared screenrestart()level.load_level()game_state = 0bird_path = []score = 0x_mouse, y_mouse = pygame.mouse.get_pos()# Draw backgroundscreen.fill((130, 200, 100))screen.blit(background2, (0, -50))# Draw first part of the slingrect = pygame.Rect(50, 0, 70, 220)screen.blit(sling_image, (138, 420), rect)# Draw the trail left behindfor point in bird_path:pygame.draw.circle(screen, WHITE, point, 5, 0)# Draw the birds in the wait lineif 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 behaviorif 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 birdsfor bird in birds:if bird.shape.body.position.y < 0:birds_to_remove.append(bird)p = to_pygame(bird.shape.body.position)x, y = px -= 22y -= 20screen.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 = Trueif restart_counter:counter = 0restart_counter = False# Remove birds and pigsfor 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 linesfor line in static_lines:body = line.bodypv1 = body.positionline.a.rotated(body.angle)pv2 = body.positionline.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 pigsfor pig in pigs:i= 1# print (i,pig.life)pig = pig.shapeif pig.body.position.y < 0:pigs_to_remove.append(pig)p = to_pygame(pig.body.position)x, y = pangle_degrees = math.degrees(pig.body.angle)img = pygame.transform.rotate(pig_image, angle_degrees)w,h = img.get_size()x -= w*0.5y -= h*0.5screen.blit(img, (x, y))pygame.draw.circle(screen, BLUE, p, int(pig.radius), 2)# Draw columns and Beamsfor column in columns:column.draw_poly('columns', screen)for beam in beams:beam.draw_poly('beams', screen)# Update physicsdt = 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 slingrect = pygame.Rect(0, 0, 60, 200)screen.blit(sling_image, (120, 420), rect)# Draw scorescore_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 optionif 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()))

​三)效果展示1)第一关

2)闯关成功

​3)其他关卡(随机截图)

4)闯关失败

其实还有很多关卡,还有只有小猪在自己往上跳,需要你命中的......很有趣很好玩,想自己试试

后面的关卡就找我拿源码吧!

总结

嘻嘻,这个第三版本可真好玩儿,喜欢的小可爱记得点点关注的啦!

✨完整的素材等:滴滴我吖!私信小编06即可获取源码啦往期推荐阅读——

项目1.0 《愤怒的小鸟》全系列游戏——这些都玩过,你就碉堡了~(版本一)

项目1.1 《愤怒的小鸟》全系列游戏——风靡全国,空降奴改:愤怒的小猪来袭~(版本二)

项目1.2 Pygame小游戏:玩扫雷就在瞎点的,不止你一个人。

项目1.3 Pygame小游戏:死磕《球球版—贪吃蛇蛇》,你中招了嘛?

还有更多更多源码等你来领区啦!文章汇总——

汇总: Python文章合集 | (入门到实战、游戏、Turtle、案例等)

(文章汇总还有更多你案例等你来学习啦~源码找我即可免费!)

    推荐阅读
  • 苏州旅游攻略景点必去(苏州旅游必去景点有哪些)

    位于苏州市东北街一百七十八号,始建于明朝正德年间。虎丘是AAAAA级景区及全国文明单位,首批十佳文明风景旅游区示范点。中午,周庄最为欢闹,游人穿梭熙熙攘攘,船儿来回摇摇荡荡,各地的游客与热情的商铺融为一体,热闹非凡,安静的古镇着实多了些欢闹的气息。狮子林为苏州四大名园之一,位于苏州市市城东北园林路。

  • 买的玉米种子是瘪的(去年买的玉米种子剩了很多)

    去年买的陈玉米种子建议不要用针对去年的陈玉米种子,大多情况下不建议再次使用,会影响到玉米后期的生长和产量情况。陈年的因为保管的问题,可能会出现很多因素影响玉米的出苗率或者后期的生长。陈玉米种子隔了一年后再种植,种子自身水分含量降低,水分降低严重的情况下,影响播种的效率和玉米的后期生长,由于活性降低,即使能出芽,也不一定能出苗。

  • 173.2亿!国庆消费火爆 国庆消费市场

    今年国庆、重阳两节叠加,全省消费市场呈现平衡较快增长态势,服装、家电、汽车等商品消费亮点突出,大众餐饮、旅行休闲、文体娱乐等主要服务消费备受青睐。根据商务部业务统一平台生存必需品监测系统显示,国庆黄金周期间,全省生存必需品市场供应充沛,价格总体平衡。除了买买买,国庆还是婚庆、团圆、会友高峰,各地亲友聚餐、婚寿宴等大众化餐饮生意兴隆。

  • 吴承恩是怎么写出的西游记(吴承恩怎么写出的西游记)

    吴承恩怎么写出的西游记诸葛长青:吴承恩写西游记诸葛长青:吴承恩怎么写出的《西游记》西游记,广泛流传西游记,作者吴承恩西游记,包含了儒释道大智慧那么,吴承恩是怎么写出的《西游记》呢?诸葛长青把自己对吴承恩写《西游记》,研究成。

  • 李逵扮演者(大家一起来看看吧)

    我们一起去了解并探讨一下这个问题吧!李逵扮演者赵小锐的李逵应该算是很多人印象当中的经典所在了,他的李逵也是很粗犷,但是这种粗犷当中却带着细腻,也是因为这个角色,他开始受到了不少的观众的关注和喜爱。其实之前的他也有出演过一些电视剧的,但是可惜的是一直都没能够真正的红起来,是李逵这个角色,让他一夜成名爆火了。

  • 汽车空间大小怎么看轴距(什么因素会影响车内空间)

    大众速腾,长度4655mm,轴距2651mm。看外观就明白了,因为宝马320i是后驱车,发动机采用纵置布局;而大众速腾是前驱车,发动机采用横置布局。而且由于发动机纵置,后驱设计,对于车内空间侵占较为严重,所以宝马320的长轴距实际上对于空间的帮助是“虚高”的。前面我们就提到了,宝马3系采用了后驱,大众速腾采用了前驱。回到我们的主题,通常来说,麦弗逊与扭力梁对于车辆空间的侵占是最小的,而多连杆和双叉臂对于车辆空间侵占是要更大的。

  • 湖南省医保局2015年工作思路与安排 湖南省医疗保障局领导班子组成人员

    督促指导各统筹地区核实提高缴费基数,强化保险费足额征收。继续加强工伤认定参与,把好工伤入口关。认真核实、积极处理群众举报问题,始终保持高压态势。加强生育医疗服务管理,规范生育津贴发放。二是启动实施工伤保险信息系统改造升级,改进工伤职工异地就医联网结算,方便工伤职工救治。三是加强财务、业务数据清理,提高数据质量;通报全省“三险”基金运行分析,指导市州加强基金运行风险管控。

  • 民国最渣四大渣男(民国著名4大渣男)

    当时很多文人在接受自由恋爱的思想时,家中已经有了父母为之安排的妻子。郁达夫一生有过三位妻子,一位同居情人。郁达夫后来还是和王映霞离婚,1940年在新加坡认识了比他小20岁的播音员李莜英,两人很快就同居了。第二任妻子佐藤富子,是个日本女人,为了和郭沫若在一起,不仅改名为“郭安娜”,还和父母断绝了关系。1937年,郭沫若抛弃妻子回国,和女明星于立群同居,两人于2年后再重庆结婚。

  • 电脑怎么连打印机教程(教会你快速学会电脑如何连接打印机的安装使用方法)

    最近很多网友都在私信给小编,小编也无法一一回复,有些问题也无法简约介绍,所以只能在头条文章内与大家共享。

  • 爱吃鸡蛋的注意了这3种鸡蛋不能买(这些鸡蛋没你想的那么好)

    营养均衡的孩子没必要补这种元素;真正缺乏硒,靠富硒蛋补,根本起不了多大作用。这类蛋再好,也别给孩子吃那就是全生或半熟的蛋,比如溏心蛋。一般溏心蛋的加热时间短,不能完全杀死细菌,生蛋液根本没有处理细菌,对于抵抗力低、易感染的宝宝来说,非常容易被细菌感染。