Python版《开心消消乐》进阶版

您所在的位置:网站首页 开心消消乐新功能 Python版《开心消消乐》进阶版

Python版《开心消消乐》进阶版

2024-07-09 23:29| 来源: 网络整理| 查看: 265

file 上次分享了一版消消乐,内容毕竟简单,没有升级,过关的乐趣,可消除的区域是固定的,娱乐性不是特别的大,今天给大家带来的是一款进阶版的消消乐。 进阶版的消消乐新增了以下内容,界面也很上一版完全不同。 1、新的游戏界面: file 2、新增过关属性,玩家可以根据提示完成相关目标的消除数即可进入下一关。 file 3、背景音乐升级为更加娱乐性的音乐,欢快更贴合游戏。 4、过关提供相应奖励,增加闯关的乐趣和挑战性。 file 5、增加连续消除的提示信息,包括(good,great,excellent,unbelievable),提供音效。 6、新增步数特性,玩家需要仔细考虑消除的方块是否可以带来更多效果,确保当前可用剩余步数足够完成过关的目标,当剩余步数已经用完,系统会弹出提示,并可以赠送5步,或者选择重新开始。 file file

由于代码量比较多,这里就不全部贴出来了,贴部分比较重要的:

闯关树: from pygame.sprite import Sprite from pygame.image import load class Tree(Sprite): '''Tree sprite''' # Images tree = 'img/tree.png' fruit = 'img/fruit.png' energy_num = 'img/energy/num.png' money = 'img/money.png' energy_buy = 'img/energy/buy.png' # Positioning x, y = 340, 510 h = 90 position = ([x, y], [x + 50, y - 25], [x + 105, y - 45], [x - 5, y - h - 5], [x + 55, y - 25 - h + 10], [x + 105, y - 45 - h], [x, y - h * 2], [x + 50 + 10, y - 25 - h * 2 - 5], [x + 105 + 25, y - 45 - h * 2 - 14], [x + 30, y - h * 3 - 30]) # Fruit positions energy_num_position = (15, 70) # Energy position energy_buy_position = (250, 400) # "Buy energy" position def __init__(self, icon, position): super().__init__() self.image = load(icon).convert_alpha() self.rect = self.image.get_rect() self.rect.bottomleft = position def draw(self, screen): '''Display the tree on the given screen.''' screen.blit(self.image, self.rect) class Board(Sprite): '''Wooden boards''' # Images step_board = 'img/board/step.png' num_format = 'img/text/%d.png' task_board = 'img/task.png' ok = 'img/ok.png' level_format = 'img/level/%d.png' success = 'img/board/success.png' fail = 'img/board/fail.png' step_add = 'img/button/step_add.png' next = 'img/button/next.png' replay = 'img/button/replay.png' stars = 'img/star.png' money = 'img/money.png' energy = 'img/energ.png' # Positioning button_position = [[300, 465], [500, 465]] starts_position = [[330, 340], [413, 340], [495, 340]] def __init__(self, icon, position): super().__init__() self.image = load(icon).convert_alpha() self.speed = [0, 45] self.rect = self.image.get_rect() self.rect.bottomleft = position def move(self): '''Move the board with its speed.''' self.rect = self.rect.move(self.speed) if self.rect.bottom >= 543: self.speed = [0, -45] if self.speed == [0, -45] and self.rect.bottom


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3