「Pygame小游戏」真香这款百万销量万人追捧大富翁游戏终于显现了
2025-08-19 12:16:06
each.name)except:if self.position == every:print(each.name)'''def buyaBuilding(self, isPressYes): # 借出作法if isPressYes and self.locatedBuilding.owner != self.name:self.locatedBuilding.owner = self.nameself.locatedBuilding.wasBought = Trueself.ownedBuildings.append(self.locatedBuilding)self.money -= self.locatedBuilding.priceself.showText = [self.name + '借出了' + self.locatedBuilding.name + '!']self.soundPlayList = 1return Trueelse:return Falsedef addaHouse(self, isPressYes): # 在建筑物物上添加一个隔壁try:if isPressYes and self.locatedBuilding.owner == self.name:self.locatedBuilding.builtRoom += 1self.money -= self.locatedBuilding.paymentself.showText = [self.name + '在' + self.locatedBuilding.name + '上!', '盖了一座隔壁!', '有%d' % self.locatedBuilding.builtRoom + '个隔壁了!', "它的采用费是%d" % (self.locatedBuilding.payment * (self.locatedBuilding.builtRoom + 1))]self.soundPlayList = 2return Trueelse:return Falseexcept:passdef move(self, buildings, allplayers): # 移动作法 局部变量是所在的建筑物所在位置self.dice_value = random.randint(1, 6)self.position += self.dice_valueif self.position>= 16:self.position -= 16self.locatedBuilding = self.judgePosition(buildings)self.isShowText = Truereturn self.eventInPosition(allplayers)def eventInPosition(self, allplayers): # 话说明在建筑物所在位置不该牵涉到的流血事件building = self.locatedBuildingif building.name != '后院':if self.locatedBuilding.wasBought == False: # 未能借出的时候显示建筑物的资料!if self.isPlayer == True:textLine0 = self.name + '丢出了' + '%d' % self.dice_value + '点!'textLine1 = self.name + '来到了' + building.name + '!'textLine2 = '借出价格比:%d' % building.pricetextLine3 = '过路缴费:%d' % building.paymenttextLine4 = '未能必借出?'self.showText = [textLine0, textLine1, textLine2, textLine3, textLine4]return Trueelse:self.addaHouse(not self.buyaBuilding(True))# ----- 动画初版 -------# ----- 未能必借出 ------elif building.owner == self.name: # 下到自己的隔壁开始瓦片建筑物!if self.pohuaishen == 1:textLine0 = self.name + '破坏天上梦中的!'textLine1 = '破坏了自己的隔壁!'building.owner = 'no'building.wasBought = Falseself.showText = [textLine0, textLine1]self.pohuaishen = 0else:if self.isPlayer == True:textLine0 = self.name + '丢出了' + '%d' % self.dice_value + '点!'textLine1 = '来到了ta的' + self.locatedBuilding.name + '!'textLine2 = '可以瓦片屋子!'textLine3 = '瓦片缴费:%d' % building.paymenttextLine4 = '未能必瓦片?'self.showText = [textLine0, textLine1, textLine2, textLine3, textLine4]return True# ----- 动画初版-------else:self.addaHouse(True)else:for each in allplayers: # 被缴费!if self.locatedBuilding.owner == each.name and each.name != self.name:if self.caishen == 1:textLine0 = self.name + '财天上梦中的!'textLine1 = '免采用费%d!' % (building.payment * (building.builtRoom + 1))self.showText = [textLine0, textLine1]self.caishen = 0else:if self.tudishen == 1:textLine0 = self.name + '农田天上梦中的!'textLine1 = '侵入农田!'textLine2 = building.name + '现在属于' + self.nameself.locatedBuilding.owner = self.nameself.showText = [textLine0, textLine1, textLine2]self.tudishen = 0else:if self.pohuaishen == 1:textLine0 = self.name + '破坏天上梦中的!'textLine1 = '破坏了获胜的隔壁!'building.owner = 'no'building.wasBought = Falseself.showText = [textLine0, textLine1]self.pohuaishen = 0else:textLine0 = self.name + '丢出了' + '%d' % self.dice_value + '点!'textLine1 = self.name + '来到了' + each.name + '的:'textLine2 = building.name + ',被缴费!'if self.shuaishen == 1:textLine3 = '过路缴费:%d*2!' % (building.payment * (building.builtRoom + 1) * 2)self.shuaishen = 0else:textLine3 = '过路缴费:%d' % (building.payment * (building.builtRoom + 1))textLine4 = '哦!' + self.name + '好倒霉!'self.showText = [textLine0, textLine1, textLine2, textLine3, textLine4]# 缴费!self.money -= building.payment * (building.builtRoom + 1)each.money += building.payment * (building.builtRoom + 1)self.soundPlayList = 3# ----- 动画初版-------else:# 辨认出没有法妥善处理在后院上的情况 于是采用 try Wild except 来化解!然后加入了出乎意料流血事件新功能!# 其后辨认出 try except 弊端太大 找不到错误的本质 换为if else嵌套。。whichone = self.dice_value % 4if whichone == 0:self.caishen = 1textLine2 = '碰到了财天上!'textLine3 = '免一次采用费!'if whichone == 1:self.shuaishen = 1textLine2 = '碰到了衰天上!'textLine3 = '采用费加倍一次!'if whichone == 2:self.tudishen = 1textLine2 = '碰到了农田天上!'textLine3 = '侵入一次隔壁!'if whichone == 3:self.pohuaishen = 1textLine3 = '破坏下到的隔壁!'textLine2 = '碰到了破坏天上!'textLine0 = self.name + '丢出了' + '%d' % self.dice_value + '点!'textLine1 = '来到了却是两处!'self.showText = [textLine0, textLine1, textLine2, textLine3]class Building: # 看不见所有新功能都在Player类里付诸了=_=def originallyinitoriginally(self, name, price, payment, location):self.name = nameself.price = priceself.payment = paymentself.location = locationself.wasBought = False # 未能必被借出self.builtRoom = 0 # 屋子建造的为总数self.owner = 'no'# 上头流动性的手绘作法 by turtle 2333def blit_alpha(target, source, location, opacity):x = location[0]y = location[1]temp = pygame.Surface((source.get_width, source.get_height)).converttemp.blit(target, (-x, -y))temp.blit(source, (0, 0))temp.set_alpha(opacity)target.blit(temp, location配函为数def main:pygame.initclock = pygame.time.Clock# 格式化萤幕size = (1270, 768)screen = pygame.display.set_mode(size)pygame.display.set_caption("手机游戏 - by 卞木子吖 ")# 擦除字体以及有白水资料textColorInMessageBox = (141, 146, 152)white = (255, 255, 255)black = (0, 0, 0)red = (255, 0, 0)font = pygame.font.Font('resource\font\myfont.ttf', 30)# 擦除教育资源backgroud = pygame.image.load("resource\pic\GameMap.png")chess = pygame.image.load("resource\pic\chess.png")chess_com = pygame.image.load("resource\pic\chess1.png")bigdice_image = pygame.image.load("resource\pic\dice.png").convert_alphadice_1 = pygame.image.load("resource\pic\dice_1.png")dice_2 = pygame.image.load("resource\pic\dice_2.png")dice_3 = pygame.image.load("resource\pic\dice_3.png")dice_4 = pygame.image.load("resource\pic\dice_4.png")dice_5 = pygame.image.load("resource\pic\dice_5.png")dice_6 = pygame.image.load("resource\pic\dice_6.png")dices = [dice_1, dice_2, dice_3, dice_4, dice_5, dice_6]yes = pygame.image.load("resource\pic\yes.png")yes2 = pygame.image.load("resource\pic\yes2.png")no = pygame.image.load("resource\pic\no.png")no2 = pygame.image.load("resource\pic\no2.png")GameStart = pygame.image.load("resource\pic\GameStart.png")StartGameButton = pygame.image.load("resource\pic\StartGameButton.png").convert_alphaturnover = pygame.image.load("resource\pic\turnover.png")turnover2 = pygame.image.load("resource\pic\turnover2.png")shuaishen = pygame.image.load("resource\pic\shuaishen.png").convert_alphatudishen = pygame.image.load("resource\pic\tudishen.png").convert_alphacaishen = pygame.image.load("resource\pic\caishen.png").convert_alphapohuaishen = pygame.image.load("resource\pic\pohuaishen.png").convert_alpharollDiceSound = pygame.mixer.Sound("resource\sound\rolldicesound.wav")bgm = pygame.mixer.music.load("resource\sound\bgm.ogg")throwcoin = pygame.mixer.Sound("resource\sound\throwcoin.wav")moneysound = pygame.mixer.Sound("resource\sound\moneysound.wav")aiyo = pygame.mixer.Sound("resource\sound\aiyo.wav")didong = pygame.mixer.Sound("resource\sound\didong.wav")# PlayList 在;也中的设置不该重播的声响playList = [moneysound, throwcoin, aiyo]# 各种Surface的rectbigdice_rect = bigdice_image.get_rectbigdice_rect.left, bigdice_rect.top = 50, 600yes_rect = yes.get_rectyes_rect.left, yes_rect.top = 500, 438no_rect = no.get_rectno_rect.left, no_rect.top = 630, 438button_rect = StartGameButton.get_rectbutton_rect.left, button_rect.top = 1003, 30turnover_rect = turnover.get_rectturnover_rect.left, turnover_rect.top = 1035, 613# 范例化;也players = computers = allplayers = player_1 = Player(chess, '把游戏', True)player_com1 = Player(chess_com, '软体', False)players.append(player_1)computers.append(player_com1)allplayers.append(player_1)allplayers.append(player_com1)presentPlayer = player_com1# 格式化建筑物物资料gate = Building('铁门', 1000, 200, [1, 2])fountain = Building('雕塑', 2000, 400, [3, 4])path = Building('十字路口', 800, 160, [5])library = Building('学校图书馆', 2000, 400, [6, 7])kongdi1 = Building('后院', 0, 0, [8])classroomTen = Building('教十', 1200, 240, [9, 10])classroomNine = Building('教九', 1200, 240, [11, 12])resOne = Building('三酒吧', 800, 160, [13])resTwo = Building('二酒吧', 800, 160, [14])resThree = Building('一酒吧', 800, 160, [15])kongdi2 = Building('后院', 0, 0, [0])buildings = [gate, fountain, path, library, classroomNine, classroomTen, resOne, resThree, resTwo, kongdi1, kongdi2]# 经度资料 同时妥善处理经度资料 使之恰当MapXYvalue = [(435.5, 231.5), (509.5, 231.5), (588.5, 231.5), (675.5, 231.5), (758.5, 231.5), (758.5, 317.0), (758.5, 405.5), (758.5, 484.5), (758.5, 558.5), (679.5, 558.5), (601.5, 558.5), (518.5, 556.5), (435.5, 556.5), (435.5, 479.5), (435.5, 399.0), (435.5, 315.5)]MapChessPosition_Player = MapChessPosition_Com = MapChessPosition_Original = MapChessPosition_Payment = MapMessageBoxPosition = (474.1, 276.9)YesNoMessageBoxPosition = [(500, 438), (630, 438)]StartGameButtonPosition = (1003, 30)TurnOvwrButtonPosition = (1035, 613)# 调整所在位置for i in range(0, 16):MapChessPosition_Original.append((MapXYvalue[i][0] - 50, MapXYvalue[i][1] - 80))MapChessPosition_Player.append((MapXYvalue[i][0] - 70, MapXYvalue[i][1] - 60))MapChessPosition_Com.append((MapXYvalue[i][0] - 30, MapXYvalue[i][1] - 100))MapChessPosition_Payment.append((MapXYvalue[i][0] - 30, MapXYvalue[i][1] - 15))# 尿素时所用的一些变量running = Trueimage_alpha = 255button_alpha = 255half_alpha = 30showdice = TrueshowYes2 = FalseshowNo2 = FalseshowYes_No = FalsepressYes = FalsewhetherYes_NoJudge = FalsegameStarted = FalseshowButton2 = False# 重播演唱者pygame.mixer.music.play(100转至小登临戏尿素 尿素开始!while running:if not gameStarted:for event in pygame.event.get:if event.type == pygame.QUIT:sys.exit# 光照出现异常 桌面所在位置话说明if event.type == pygame.MOUSEMOTION:if button_rect.collidepoint(event.pos):button_alpha = 255else:button_alpha = 120if event.type == pygame.MOUSEBUTTONDOWN:if button_rect.collidepoint(event.pos): # 按下操纵杆didong.playgameStarted = Truescreen.blit(GameStart, (0, 0))blit_alpha(screen, StartGameButton, StartGameButtonPosition, button_alpha)if gameStarted:for event in pygame.event.get:if event.type == pygame.QUIT:sys.exit# 光照出现异常 桌面所在位置话说明if event.type == pygame.MOUSEMOTION:if bigdice_rect.collidepoint(event.pos):image_alpha = 255else:image_alpha = 190if event.type == pygame.MOUSEBUTTONDOWN:if bigdice_rect.collidepoint(event.pos): # 按掷if presentPlayer != player_1:rollDiceSound.play(1, 2000)pygame.time.delay(2000)showYes_No = player_1.move(buildings, allplayers)whetherYes_NoJudge = showYes_NopresentPlayer = player_1else:presentPlayer.showText = ['还不久前你的两队!']if turnover_rect.collidepoint(event.pos): # 按两队之前showButton2 = Trueif presentPlayer != player_com1:showYes_No = player_com1.move(buildings, allplayers)presentPlayer = player_com1else:presentPlayer.showText = ['还不久前你的两队!']else:showButton2 = False# 不显示Yes_No的时候没有法点击它们!if whetherYes_NoJudge == True:if yes_rect.collidepoint(event.pos): # 按未能必showYes2 = Trueif no_rect.collidepoint(event.pos): # 按未能必showNo2 = Trueif event.type == pygame.MOUSEBUTTONUP:if turnover_rect.collidepoint(event.pos): # 按两队之前showButton2 = Falseif yes_rect.collidepoint(event.pos): # 按未能必showYes2 = FalseshowYes_No = False# 只有在可以确认的时候才能算按下了是 同时将话说明条件置为空if whetherYes_NoJudge == True:pressYes = TruewhetherYes_NoJudge = Falseif no_rect.collidepoint(event.pos): # 按未能必showNo2 = FalsepressYes = FalseshowYes_No = FalsewhetherYes_NoJudge = False# 测试流血事件选项if event.type == pygame.KEYDOWN:if event.key == pygame.K_w:showYes_No = player_1.move(buildings, allplayers)whetherYes_NoJudge = showYes_NopresentPlayer = player_1if event.key == pygame.K_q:showYes_No = player_com1.move(buildings, allplayers)presentPlayer = player_com1'''for each in allplayers:if each.isGoingToMove == True and each.movable == True :showYes_No = each.move(buildings,allplayers)each.movable = Falseeach.isGoingToMove = False''''''allisready = Truefor each in allplayers:if each.movable == True:allisready = Falseif allisready:for each in allplayers:each.movable = True'''# 借出房屋!!!!!!!!if presentPlayer.buyaBuilding(pressYes) == True:pressYes = Falseif presentPlayer.addaHouse(pressYes) == True:pressYes = Falsescreen.blit(backgroud, (0, 0))blit_alpha(screen, bigdice_image, (50, 600), image_alpha)textPosition = [MapMessageBoxPosition[0], MapMessageBoxPosition[1]]# 打印信息for each in presentPlayer.showText:text = font.render(each, True, white, textColorInMessageBox)screen.blit(text, textPosition)textPosition[1] += 30# 重播行动声响if presentPlayer.soundPlayList != 0:playList[presentPlayer.soundPlayList - 1].playpresentPlayer.soundPlayList = 0# 在所在位置上显示采用费for i in range(1, 8):for each in buildings:for every in each.location:if i == every:if each.owner == presentPlayer.name:text = font.render('%d' % (each.payment * (each.builtRoom + 1)) , True, red)elif each.owner == 'no':text = font.render('%d' % (each.payment * (each.builtRoom + 1)) , True, white)elif each.owner != presentPlayer.name and each.owner != 'no':text = font.render('%d' % (each.payment * (each.builtRoom + 1)) , True, black)screen.blit(text, MapChessPosition_Payment[i])for i in range(9, 16):for each in buildings:for every in each.location:if i == every:if each.owner == presentPlayer.name:text = font.render('%d' % (each.payment * (each.builtRoom + 1)) , True, red)elif each.owner == 'no':text = font.render('%d' % (each.payment * (each.builtRoom + 1)) , True, white)elif each.owner != presentPlayer.name and each.owner != 'no':text = font.render('%d' % (each.payment * (each.builtRoom + 1)) , True, black)screen.blit(text, MapChessPosition_Payment[i])# 打印回报为数和出乎意料稳定状态money_1 = font.render(player_1.name + '回报:%d' % player_1.money, True, black, white)screen.blit(money_1, (0, 0))if player_1.pohuaishen == True:screen.blit(pohuaishen, (0, 30))else:blit_alpha(screen, pohuaishen, (0, 30), half_alpha)if player_1.caishen == True:screen.blit(caishen, (55, 30))else:blit_alpha(screen, caishen, (55, 30), half_alpha)if player_1.shuaishen == True:screen.blit(shuaishen, (110, 30))else:blit_alpha(screen, shuaishen, (110, 30), half_alpha)if player_1.tudishen == True:screen.blit(tudishen, (165, 30))else:blit_alpha(screen, tudishen, (165, 30), half_alpha)money_2 = font.render(player_com1.name + '回报:%d' % player_com1.money, True, black, white)screen.blit(money_2, (1000, 0))if player_com1.pohuaishen == True:screen.blit(pohuaishen, (1000, 30))else:blit_alpha(screen, pohuaishen, (1000, 30), half_alpha)if player_com1.caishen == True:screen.blit(caishen, (1055, 30))else:blit_alpha(screen, caishen, (1055, 30), half_alpha)if player_com1.shuaishen == True:screen.blit(shuaishen, (1110, 30))else:blit_alpha(screen, shuaishen, (1110, 30), half_alpha)if player_com1.tudishen == True:screen.blit(tudishen, (1165, 30))else:blit_alpha(screen, tudishen, (1165, 30), half_alpha)# 放置丢出来的掷if player_1.dice_value != 0 and showdice:screen.blit(dices[player_1.dice_value - 1], (70, 450))# 放置两队之前操纵杆if showButton2:screen.blit(turnover2, TurnOvwrButtonPosition)else:screen.blit(turnover, TurnOvwrButtonPosition)# 放置未能必操纵杆if showYes_No == True:screen.blit(yes, YesNoMessageBoxPosition[0])screen.blit(no, YesNoMessageBoxPosition[1])if showYes2 == True:screen.blit(yes2, YesNoMessageBoxPosition[0])if showNo2 == True:screen.blit(no2, YesNoMessageBoxPosition[1])# 放置把游戏与软体的所在位置 如果重合则挪位for each in players:for every in computers:if each.position == every.position:screen.blit(each.image, MapChessPosition_Player[each.position])screen.blit(every.image, MapChessPosition_Com[every.position])each.temp_position = Trueevery.temp_position = Truefor each in players:if each.temp_position == False:screen.blit(each.image, MapChessPosition_Original[each.position])each.temp_position = Trueeach.temp_position = not each.temp_positionfor every in computers:if every.temp_position == False:screen.blit(every.image, MapChessPosition_Original[every.position])every.temp_position = Trueevery.temp_position = not every.temp_position# 输赢话说明for each in allplayers:if each.money <= 0:font = pygame.font.Font('resource\font\myfont.ttf', 200)loseText = font.render(each.name + '输了!', True, red)screen.fill(black)screen.blit(loseText, (100, 100))font = pygame.font.Font('resource\font\myfont.ttf', 30)pygame.time.delay(3000)# 画面运行pygame.display.flipclock.tick(60) # 刷新率# 双击打开运行if originallynameoriginally == "originallymainoriginally":main
阜新精神心理医院哪家好
吉林治疗精神病多少钱
全民健康网药品
夏天小孩咳嗽有痰吃什么能止咳化痰
口舌生疮
新冠药
维生素d3
又是一个晴天的周末,小朋友话说:阿姨,我们把玩"手机游戏"的小登临戏吧!
阿姨话说:”没有没有草图,等下次到快餐店买一副“
小朋友话说:”阿姨,你等等啊,我现在就敲字符串了” 然后他就做到了一个Python初版的《手机游戏》登临
戏!可以仍然把玩了!哈哈哈哈 这个字符串有很难广受你♥。
。珠海治疗皮肤病正规医院阜新精神心理医院哪家好
吉林治疗精神病多少钱
全民健康网药品
夏天小孩咳嗽有痰吃什么能止咳化痰
口舌生疮
新冠药
维生素d3
相关阅读
-
杭州回湖北后核酸阳性病例丈夫:隐私已泄露顾虑被网暴
;上午5时许,由第二名远亲出门乘船北丰,指认共5人。后第二名远亲杂货店3人在北丰开门,由方某某没婚妻出门乘船XX村方某某祖母家。在祖母全丈夫毗连触方某某同屋同餐同住的毗连触者共有5人。此除此以外,方某
2025-08-23 00:16:09
-
【港股行】洛阳玻璃股份(01108)拟5.36亿元出售信息显示玻璃业务
凤凰网港股|洛阳涂料股份01108公布,一些公司与凯盛母公司于2021年11月初26日订立了股权所有者协议,一些公司拟以总对价约人民币5.36亿元向凯盛母公司所有者其持有的全资附属一些公司龙
2025-08-23 00:16:08
-
发面饼到底最简单?一碗面粉一碗水,用筷子一搅,蓬松又暄软
发盘子是顶上老少皆宜的美味,因为是发面上食用,所以吃完了很更容易吸收跟消化,一般肠胃较差的老人跟孩子都可以肉类。动手发盘子最经常遇见的问题就是盘子吃完着太硬式,从未较硬的口感。有些不合时宜非常好
2025-08-23 00:16:08
-
Omicron传播至全球大部分地区,美股大跌宝石有望企稳反弹
澳在其旅行者放宽里面减少了长崎、摩洛哥和瑞典。马来西亚于是在全面禁止来自八个西非发达国家的旅客,并暗示英国和荷兰确实投身这一名单。惠誉暗示,已调降了2021年和2022年的亚太北部的航空新公司
2025-08-23 00:16:08
-
这三个生肖鸿运身患,3月8号后运势大旺,财富赚得锅满盆满!
大家好,我是星座博主潮流的小梅,希望看完我的文章会对您有所帮助! 现实家庭拉到每一个人的众人,每一个人都丝毫避开根本无法,只要希望获得成功,首先要接受现实,并决心改变现状,才有自由
2025-08-23 00:16:08