国产xxxx99真实实拍_久久不雅视频_高清韩国a级特黄毛片_嗯老师别我我受不了了小说

資訊專欄INFORMATION COLUMN

python學習教程,python版大富翁游戲開發源代碼分享

davidac / 3687人閱讀

摘要:物網王璞劼理工大富翁基于的一個大富翁游戲游戲地圖為自己使用各種網絡素材制作各種按鈕和選項,小圖標等也是使用制作。玩家在大富翁的主要操作是投擲骰子,由隨機函數進行判定然后進行移動,進行位置判斷,然后開始進行相關的判定。

本文實例為大家分享了python版大富翁游戲的具體代碼,供大家參考,具體內容如下

# -*- coding: utf-8 -*-
  
"""
在學習過程中有什么不懂得可以加我的python學習交流扣扣qun,934109170,群里有不錯的學習教程、開發工具與電子書籍。
與你分享python企業當下人才需求及怎么從零基礎學習好python,和學習什么內容。
"""  
# code by: 物網141 王璞劼Khalil
# name:   理工大富翁beta2.0
# describe: 基于python的一個2D大富翁游戲
"""
1.游戲地圖為自己使用各種網絡素材制作;
 各種按鈕和選項,小圖標等也是使用PS制作。
2.聲音效果主要為背景音樂和幾種游戲中音效;
3.游戲設定了兩個類:玩家和建筑
 玩家的參數和方法都在代碼中給出;
 具體有:移動方法、位置判斷方法、
  購買房屋方法、添加小房子方法、
 事件判斷方法。
4.玩家在大富翁的主要操作是投擲骰子,由隨機函數
 進行判定然后進行移動,進行位置判斷,然后開始
 進行相關的判定。
5.游戲中的按鍵有:是、否、和結束回合;
 每個按鍵由沒按下與按下兩種狀態的圖片組成,
 這個設計花費了一定時間。
 還有 開始游戲 和 扔骰子 的兩個明暗按鈕,
 由pygame優化后的一個函數實現。
6.玩家的位置與電腦重疊時會將雙方的位置進行一定
 偏移,防止進行覆蓋,分不清自己的位置。
7.游戲基礎功能有移動,購買房子,在已經購買的房子下
 搭建新的小房子增加過路費,被收費,判斷勝負的基礎
 功能,此外還加入了幸運事件:
  財神 - 免收費一次
  衰神 - 雙倍被收費一次
  破壞神 - 直接破壞一個建筑 無論敵我
  土地神 - 強占對面建筑
 這四項功能在位置處于左上角和右下角的時候會被觸發,
 添加了很多游戲樂趣哦~~~ ^_^
8.游戲基于python的一個模塊pygame實現,給我提供了很
 多快樂的時光,謝謝老師的閱覽與郭寧同學的協助答辯
 :)
"""
  
#####################準備工作##################
  
# 初始化各種模塊
import pygame
import random
import sys
  
# 定義類
class Player():
  def __init__(self, image ,name , isPlayer):
    self.name = name
    self.money = 10000
    self.isGoingToMove = False
    self.movable = True
    self.image = image
    self.position = 0
    self.temp_position = False
    self.dice_value = 0
    self.locatedBuilding = 0
    self.showText = []
    self.isPlayer = isPlayer
    self.ownedBuildings = []
    self.isShowText = False
    self.soundPlayList = 0
    self.caishen = 0
    self.shuaishen = 0
    self.tudishen = 0
    self.pohuaishen = 0
     
   
  def judgePosition(self,buildings): # 位置判斷 返回值是所在位置的建筑
    for each in buildings:
      for every in each.location:
        if self.position == every:
          return each
           
       
      # 當使用元組時 當元組中只有一個元素時 發現該元素不可迭代 
      # 出現錯誤 換成列表后解決
      """ 
      try:
        for every in each.location:
          if self.position == every:
            print(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.name
      self.locatedBuilding.wasBought = True
      self.ownedBuildings.append(self.locatedBuilding)
      self.money -= self.locatedBuilding.price
      self.showText = [self.name + "購買了" + self.locatedBuilding.name + "!"]
      self.soundPlayList = 1
      return True
    else:
      return False
     
      
       
  def addaHouse(self,isPressYes): # 在建筑物上添加一個房子
    try:
      if isPressYes and self.locatedBuilding.owner == self.name:
        self.locatedBuilding.builtRoom += 1
        self.money -= self.locatedBuilding.payment
        self.showText = [self.name + "在" + self.locatedBuilding.name + "上!","蓋了一座房子!",
                "有%d" % self.locatedBuilding.builtRoom + "個房子了!",
                "它的過路費是%d" % (self.locatedBuilding.payment * 
                        (self.locatedBuilding.builtRoom + 1)) ]
        self.soundPlayList = 2
        return True
      else:
        return False
    except:
      pass
   
  def move(self,buildings,allplayers):  # 移動方法 返回值是所在的建筑位置
    self.dice_value = random.randint(1,6)
    self.position += self.dice_value
    if self.position >= 16:
      self.position -= 16
    self.locatedBuilding = self.judgePosition(buildings)
    self.isShowText = True
    return self.eventInPosition(allplayers)
   
   
  def eventInPosition(self,allplayers):    # 判斷在建筑位置應該發生的事件    
    building = self.locatedBuilding
    if 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.price
          textLine3 = "過路收費:%d" % building.payment
          textLine4 = "是否購買?"
          self.showText = [textLine0,textLine1,textLine2,textLine3,textLine4]
          return True
        else :
          self.addaHouse(not self.buyaBuilding(True))
           
        # ----- 動畫 -------
        # ----- 是否購買 ------
      elif building.owner == self.name: # 路過自己的房子開始加蓋建筑!
        if self.pohuaishen == 1:
          textLine0 = self.name + "破壞神附體!"
          textLine1 = "摧毀了自己的房子!"
          building.owner = "no"
          building.wasBought = False
          self.showText = [textLine0,textLine1]
          self.pohuaishen = 0
        else:
          if self.isPlayer == True:
            textLine0 = self.name + "扔出了" + "%d"% self.dice_value + "點!"
            textLine1 = "來到了ta的"+ self.locatedBuilding.name +"!"
            textLine2 = "可以加蓋小房子!"
            textLine3 = "加蓋收費:%d" % building.payment
            textLine4 = "是否加蓋?"
            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 = 0
            else:
              if self.tudishen == 1:
                textLine0 = self.name + "土地神附體!"
                textLine1 = "強占土地!"
                textLine2 = building.name + "現在屬于"+ self.name
                self.locatedBuilding.owner = self.name
                self.showText = [textLine0,textLine1,textLine2]
                self.tudishen = 0
              else:
                if self.pohuaishen == 1:
                  textLine0 = self.name + "破壞神附體!"
                  textLine1 = "摧毀了對手的房子!"
                  building.owner = "no"
                  building.wasBought = False
                  self.showText = [textLine0,textLine1]
                  self.pohuaishen = 0 
                else:
                  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 = 0
                  else:
                    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 & except 來解決!然后加入了幸運事件功能!
      # 后來發現 try except 弊端太大 找不到錯誤的根源 換為if else嵌套。。
      whichone = self.dice_value % 4
      if whichone == 0:
        self.caishen = 1
        textLine2 = "遇到了財神!"
        textLine3 = "免一次過路費!"
      if whichone == 1:
        self.shuaishen = 1
        textLine2 = "遇到了衰神!"
        textLine3 = "過路費加倍一次!"
      if whichone == 2:
        self.tudishen = 1
        textLine2 = "遇到了土地神!"
        textLine3 = "強占一次房子!"
      if whichone == 3:
        self.pohuaishen = 1
        textLine3 = "摧毀路過的房子!"
        textLine2 = "遇到了破壞神!"
      textLine0 = self.name +"扔出了" +"%d"% self.dice_value + "點!"
      textLine1 = "來到了運氣地點!"
      self.showText = [textLine0,textLine1,textLine2,textLine3]
  
   
   
   
class Building():              # 好像所有功能都在Player類里實現了=_=
  def __init__(self,name,price,payment,location):
    self.name = name
    self.price = price
    self.payment = payment
    self.location = location
    self.wasBought = False        # 是否被購買
    self.builtRoom = 0          # 小房子建造的數目
    self.owner = "no"
  
# 帶透明度的繪圖方法 by turtle 2333
def blit_alpha(target,source,location,opacity):
  x = location[0]
  y = location[1]
  temp = pygame.Surface((source.get_width(),source.get_height())).convert()
  temp.blit(target , (-x , -y))
  temp.blit(source,(0,0))
  temp.set_alpha(opacity)
  target.blit(temp,location)
  
########################主函數#########################  
  
  
def main():
  pygame.init()
  clock = pygame.time.Clock()
   
  # 初始化屏幕
  size = (1270,768)
  screen = pygame.display.set_mode(size)
  pygame.display.set_caption("理工大大富翁 - made by 王璞劼")
   
  # 讀取字體以及有關數據
  textColorInMessageBox = (141,146,152)
  white = (255,255,255)
  black = (0,0,0)
  red = (255,0,0)
  font = pygame.font.Font("resourcefontmyfont.ttf",30)
   
   
  # 讀取資源
  backgroud = pygame.image.load("resourcepicGameMap.png")
  chess = pygame.image.load("resourcepicchess.png")
  chess_com = pygame.image.load("resourcepicchess1.png")
  bigdice_image = pygame.image.load("resourcepicdice.png").convert_alpha()
  dice_1 = pygame.image.load("resourcepicdice_1.png")
  dice_2 = pygame.image.load("resourcepicdice_2.png")
  dice_3 = pygame.image.load("resourcepicdice_3.png")
  dice_4 = pygame.image.load("resourcepicdice_4.png")
  dice_5 = pygame.image.load("resourcepicdice_5.png")
  dice_6 = pygame.image.load("resourcepicdice_6.png")
  dices = [dice_1,dice_2,dice_3,dice_4,dice_5,dice_6]
  yes = pygame.image.load("resourcepicyes.png")
  yes2 = pygame.image.load("resourcepicyes2.png")
  no = pygame.image.load("resourcepic
o.png")
  no2 = pygame.image.load("resourcepic
o2.png")
  GameStart = pygame.image.load("resourcepicGameStart.png")
  StartGameButton = pygame.image.load("resourcepicStartGameButton.png").convert_alpha()
  turnover = pygame.image.load("resourcepic	urnover.png")
  turnover2 = pygame.image.load("resourcepic	urnover2.png")
  shuaishen = pygame.image.load("resourcepicshuaishen.png").convert_alpha()
  tudishen = pygame.image.load("resourcepic	udishen.png").convert_alpha()
  caishen = pygame.image.load("resourcepiccaishen.png").convert_alpha()
  pohuaishen = pygame.image.load("resourcepicpohuaishen.png").convert_alpha()
   
  rollDiceSound = pygame.mixer.Sound("resourcesound
olldicesound.wav")
  bgm = pygame.mixer.music.load("resourcesoundgm.ogg")
  throwcoin = pygame.mixer.Sound("resourcesound	hrowcoin.wav")
  moneysound = pygame.mixer.Sound("resourcesoundmoneysound.wav")
  aiyo = pygame.mixer.Sound("resourcesoundaiyo.wav")
  didong = pygame.mixer.Sound("resourcesounddidong.wav")
   
  # PlayList 在對象中設置應該播放的聲音
  playList = [moneysound ,throwcoin ,aiyo]
   
  # 各種Surface的rect 
  bigdice_rect = bigdice_image.get_rect()
  bigdice_rect.left , bigdice_rect.top = 50 , 600
  yes_rect = yes.get_rect()
  yes_rect.left , yes_rect.top = 500,438
  no_rect = no.get_rect()
  no_rect.left , no_rect.top = 630,438
  button_rect = StartGameButton.get_rect()
  button_rect.left , button_rect.top = 1003,30
  turnover_rect = turnover.get_rect()
  turnover_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 = True
  image_alpha = 255
  button_alpha = 255
  half_alpha = 30
  showdice = True
  showYes2 = False
  showNo2 = False
  showYes_No = False
  pressYes = False
  whetherYes_NoJudge = False
  gameStarted = False
  showButton2 = 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 = 255 
          else:
            button_alpha = 120
             
        if event.type == pygame.MOUSEBUTTONDOWN:
            
          if button_rect.collidepoint(event.pos): # 按下按鈕
            didong.play()           
            gameStarted = True
       
      screen.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 = 255 
          else:
            image_alpha = 190
             
         
        if 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_No
              presentPlayer = player_1
            else:
              presentPlayer.showText = ["還沒到你的回合!"]
             
          if turnover_rect.collidepoint(event.pos): # 按回合結束
            showButton2 = True
            if presentPlayer != player_com1:
              showYes_No = player_com1.move(buildings,allplayers)
              presentPlayer = player_com1
            else:
              presentPlayer.showText = ["還沒到你的回合!"]              
          else:
            showButton2 = False
           
            # 不顯示Yes_No的時候不能點擊它們!
          if whetherYes_NoJudge == True: 
            if yes_rect.collidepoint(event.pos): # 按是否
              showYes2 = True
               
            if no_rect.collidepoint(event.pos): # 按是否
              showNo2 = True
            
        if event.type == pygame.MOUSEBUTTONUP:
           
          if turnover_rect.collidepoint(event.pos): # 按回合結束
            showButton2 = False
           
          if yes_rect.collidepoint(event.pos): # 按是否
            showYes2 = False
            showYes_No = False
            # 只有在可以判定的時候才能算按下了是 同時將判斷條件置為空
            if whetherYes_NoJudge == True:
              pressYes = True
              whetherYes_NoJudge = False
               
               
          if no_rect.collidepoint(event.pos): # 按是否
            showNo2 = False
            pressYes = False
            showYes_No = False      
            whetherYes_NoJudge = False   
       
        # 測試事件選項    
        if event.type == pygame.KEYDOWN:
          if event.key == pygame.K_w:
            showYes_No = player_1.move(buildings,allplayers)
            whetherYes_NoJudge = showYes_No
            presentPlayer = player_1
          if 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 = False
          each.isGoingToMove = False"""
      """
      allisready = True
       
      for each in allplayers:
        if each.movable == True:
          allisready = False
       
      if allisready:
        for each in allplayers:
          each.movable = True
      """      
        
      # 購買房屋!!!!!!!!
       
      if presentPlayer.buyaBuilding(pressYes) == True:
        pressYes = False
         
      if presentPlayer.addaHouse(pressYes) == True:
        pressYes = False   
         
      #########################################################################      
      screen.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].play()
        presentPlayer.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 = True
            every.temp_position = True
             
      for each in players:
        if each.temp_position == False:
          screen.blit(each.image,MapChessPosition_Original[each.position])
          each.temp_position = True
        each.temp_position = not each.temp_position
         
          
      for every in computers:
        if every.temp_position == False:
          screen.blit(every.image,MapChessPosition_Original[every.position])
          every.temp_position = True
        every.temp_position = not every.temp_position
             
       
      # 輸贏判斷
      for each in allplayers:
        if each.money <= 0:
          font = pygame.font.Font("resourcefontmyfont.ttf",200)
          loseText = font.render(each.name +"輸了!", True, red)
          screen.fill(black)
          screen.blit(loseText,(100,100))
          font = pygame.font.Font("resourcefontmyfont.ttf",30)      
          pygame.time.delay(3000)
             
    # 畫面運行
     
    pygame.display.flip()
    clock.tick(60)       # 刷新率
         
  
# 雙擊打開運行      
if __name__ == "__main__":
  main()

因為目前python非常火,應用非常的廣泛,是目前最火的行業之一,競爭很大,工資很高,未來發展也極好。加油加油!

文章版權歸作者所有,未經允許請勿轉載,若此文章存在違規行為,您可以聯系管理員刪除。

轉載請注明本文地址:http://specialneedsforspecialkids.com/yun/44147.html

相關文章

  • 游戲開發上手體驗 - Cocos Creator

    摘要:但開發的游戲是無法通過網頁發給別人在線玩的,更不能做成微信小游戲。它使用作為開發語言,開發出的游戲可以直接生成微信小游戲網頁安卓等平臺上的版本。 微信群里最大的騷擾源有兩種: 一是轉發#吱口令#~!@#¥%……&*,長按復制此消息領紅包之類的 另一種就是各種小程序和小游戲的分享 前天有同學無意間把一個小游戲分享到了答疑群中,我看了一下,其實游戲的代碼邏輯并不復雜(簡化版的跳一跳,套上個...

    zhiwei 評論0 收藏0
  • 編程書單:十本Python編程語言的入門書籍

    摘要:本文與大家分享一些編程語言的入門書籍,其中不乏經典。全書貫穿的主體是如何思考設計開發的方法,而具體的編程語言,只是提供一個具體場景方便介紹的媒介。入門入門容易理解而且讀起來幽默風趣,對于編程初學者和語言新手而言是理想的書籍。 本文與大家分享一些Python編程語言的入門書籍,其中不乏經典。我在這里分享的,大部分是這些書的英文版,如果有中文版的我也加上了。有關書籍的介紹,大部分截取自是官...

    desdik 評論0 收藏0
  • SegmentFault 技術周刊 Vol.40 - 2018,來學習一門新的編程語言吧!

    摘要:入門,第一個這是一門很新的語言,年前后正式公布,算起來是比較年輕的編程語言了,更重要的是它是面向程序員的函數式編程語言,它的代碼運行在之上。它通過編輯類工具,帶來了先進的編輯體驗,增強了語言服務。 showImg(https://segmentfault.com/img/bV1xdq?w=900&h=385); 新的一年不知不覺已經到來了,總結過去的 2017,相信小伙們一定有很多收獲...

    caspar 評論0 收藏0
  • SegmentFault 技術周刊 Vol.40 - 2018,來學習一門新的編程語言吧!

    摘要:入門,第一個這是一門很新的語言,年前后正式公布,算起來是比較年輕的編程語言了,更重要的是它是面向程序員的函數式編程語言,它的代碼運行在之上。它通過編輯類工具,帶來了先進的編輯體驗,增強了語言服務。 showImg(https://segmentfault.com/img/bV1xdq?w=900&h=385); 新的一年不知不覺已經到來了,總結過去的 2017,相信小伙們一定有很多收獲...

    nihao 評論0 收藏0
  • SegmentFault 技術周刊 Vol.40 - 2018,來學習一門新的編程語言吧!

    摘要:入門,第一個這是一門很新的語言,年前后正式公布,算起來是比較年輕的編程語言了,更重要的是它是面向程序員的函數式編程語言,它的代碼運行在之上。它通過編輯類工具,帶來了先進的編輯體驗,增強了語言服務。 showImg(https://segmentfault.com/img/bV1xdq?w=900&h=385); 新的一年不知不覺已經到來了,總結過去的 2017,相信小伙們一定有很多收獲...

    Drummor 評論0 收藏0

發表評論

0條評論

最新活動
閱讀需要支付1元查看
<