找回密码
 立即注册

扫一扫,访问微社区

QQ登录

只需一步,快速开始

查看: 19506|回复: 12

[代码与实例] 用python实现最火的游戏《2048》

50

主题

1057

帖子

1108

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1108

活跃会员热心会员最佳导师默默耕耘突出贡献优秀版主荣誉管理论坛元老

blueelwang 发表于 2014-6-6 09:31:18 | 显示全部楼层 |阅读模式
高手真是太多了,居然用python实现了2048,我就直接上代码吧


  1. import random
  2. from sys import exit
  3. from copy import deepcopy
  4. import pygame
  5. from pygame.locals import *

  6. board = [[0, 0, 0, 0],
  7.          [0, 0, 0, 0],
  8.          [0, 0, 0, 0],
  9.          [0, 0, 0, 0]]

  10. pygame.init()

  11. box_size = 50
  12. box_gap  = 5
  13. top_of_screen = 100
  14. bottom_of_screen = 30
  15. left_of_screen = 20
  16. screen_width  = box_size * 4 + box_gap * 5 + left_of_screen * 2
  17. screen_height = top_of_screen + box_gap * 5 + box_size * 4 + left_of_screen + bottom_of_screen
  18. screen = pygame.display.set_mode((screen_width, screen_height), 0, 32)
  19. pygame.display.set_caption("2048")
  20. background = pygame.image.load('background.png').convert()
  21. score = 0

  22. OLDLACE    = pygame.color.THECOLORS["oldlace"]
  23. IVORY   = pygame.color.THECOLORS["ivory3"]
  24. BLACK   = pygame.color.THECOLORS["black"]
  25. RED     = pygame.color.THECOLORS["red"]
  26. RED2    = pygame.color.THECOLORS["red2"]
  27. DARKGOLD  = pygame.color.THECOLORS["darkgoldenrod1"]
  28. GOLD    =  pygame.color.THECOLORS["gold"]
  29. GRAY    = pygame.color.THECOLORS["gray41"]
  30. CHOCOLATE = pygame.color.THECOLORS["chocolate"]
  31. CHOCOLATE1 = pygame.color.THECOLORS["chocolate1"]
  32. CORAL   = pygame.color.THECOLORS["coral"]
  33. CORAL2  = pygame.color.THECOLORS["coral2"]
  34. ORANGED = pygame.color.THECOLORS["orangered"]
  35. ORANGED2 = pygame.color.THECOLORS["orangered2"]
  36. DARKORANGE = pygame.color.THECOLORS["darkorange"]
  37. DARKORANGE2 = pygame.color.THECOLORS["darkorange2"]
  38. FORESTGREEN = pygame.color.THECOLORS['forestgreen']


  39. class Box:
  40.     def __init__(self, topleft, text, color):
  41.         self.topleft = topleft
  42.         self.text = text
  43.         self.color = color
  44.     def render(self, surface):
  45.         x, y = self.topleft
  46.         pygame.draw.rect(surface, self.color, (x, y, box_size, box_size))
  47.         text_height  = int(box_size * 0.35)
  48.         font_obj     = pygame.font.Font("FreeSansBold.ttf", text_height)
  49.         text_surface = font_obj.render(self.text, True, BLACK)
  50.         text_rect    = text_surface.get_rect()
  51.         text_rect.center = (x + box_size / 2, y + box_size / 2)
  52.         surface.blit(text_surface, text_rect)


  53. def draw_box():
  54.     global board
  55.     # colors = {0:GRAY, 2:(239, 233, 182), 4:(239, 228, 151), 8:(243, 212, 77), 16:(239, 206, 25),
  56.     #           32:(242, 157, 12), 64:(214, 214, 42), 128:(239, 207, 108), 256:(239, 207, 99),
  57.     #           512:(239, 203, 82), 1024:(239, 199, 57), 2048:(239, 195, 41), 4096:(255, 60, 57)}
  58.     colors = {0:(192, 192, 192), 2:(176, 224, 230), 4:(127, 255, 212), 8:(135, 206, 235), 16:(64, 224, 208),
  59.               32:(0, 255, 255), 64:(0, 201, 87), 128:(50, 205, 50), 256:(34, 139, 34),
  60.               512:(0, 255, 127), 1024:(61, 145, 64), 2048:(48, 128, 20), 4096:(65, 105, 255),
  61.               8192:(8, 46, 84), 16384:(11, 23, 70), 32768:(25, 25, 112), 65536:(0, 0, 255)}
  62.     x, y = left_of_screen, top_of_screen
  63.     size = box_size * 4 + box_gap * 5
  64.     pygame.draw.rect(screen, BLACK, (x, y, size, size))
  65.     x, y = x + box_gap, y + box_gap
  66.     for i in range(4):
  67.         for j in range(4):
  68.             idx = board[i][j]
  69.             if idx == 0:
  70.                 text = ""
  71.             else:
  72.                 text = str(idx)
  73.             if idx > 65536: idx = 65536
  74.             color = colors[idx]
  75.             box = Box((x, y), text, color)
  76.             box.render(screen)
  77.             x += box_size + box_gap
  78.         x = left_of_screen + box_gap
  79.         y += box_size + box_gap


  80. def set_random_number():
  81.     pool = []
  82.     for i in range(4):
  83.         for j in range(4):
  84.             if board[i][j] == 0:
  85.                 pool.append((i, j))
  86.     m = random.choice(pool)
  87.     pool.remove(m)
  88.     value = random.uniform(0, 1)
  89.     if value < 0.1:
  90.         value = 4
  91.     else:
  92.         value = 2
  93.     board[m[0]][m[1]] = value

  94. def init_board():
  95.     for i in range(2):
  96.         set_random_number()

  97. def combinate(L):
  98.     global score
  99.     ans = [0, 0, 0, 0]
  100.     num = []
  101.     for i in L:
  102.         if i != 0:
  103.             num.append(i)
  104.     length = len(num)
  105.     if length == 4:
  106.         if num[0] == num[1]:
  107.             ans[0] = num[0] + num[1]
  108.             score += ans[0]
  109.             if num[2] == num[3]:
  110.                 ans[1] = num[2] + num[3]
  111.                 score += ans[1]
  112.             else:
  113.                 ans[1] = num[2]
  114.                 ans[2] = num[3]
  115.         elif num[1] == num[2]:
  116.             ans[0] = num[0]
  117.             ans[1] = num[1] + num[2]
  118.             ans[2] = num[3]
  119.             score += ans[1]
  120.         elif num[2] == num[3]:
  121.             ans[0] = num[0]
  122.             ans[1] = num[1]
  123.             ans[2] = num[2] + num[3]
  124.             score += ans[2]
  125.         else:
  126.             for i in range(length):
  127.                 ans[i] = num[i]
  128.     elif length == 3:
  129.         if num[0] == num[1]:
  130.             ans[0] = num[0] + num[1]
  131.             ans[1] = num[2]
  132.             score += ans[0]
  133.         elif num[1] == num[2]:
  134.             ans[0] = num[0]
  135.             ans[1] = num[1] + num[2]
  136.             score += ans[1]
  137.         else:
  138.             for i in range(length):
  139.                 ans[i] = num[i]
  140.     elif length == 2:
  141.         if num[0] == num[1]:
  142.             ans[0] = num[0] + num[1]
  143.             score += ans[0]
  144.         else:
  145.             for i in range(length):
  146.                 ans[i] = num[i]
  147.     elif length == 1:
  148.         ans[0] = num[0]
  149.     else:
  150.         pass
  151.     return ans

  152. def left():
  153.     # global score
  154.     for i in range(4):
  155.         temp = combinate(board[i])
  156.         for j in range(4):
  157.             board[i][j] = temp[j]
  158.             # score += temp[1]
  159.     # return score

  160.    
  161. def right():
  162.     # global score
  163.     for i in range(4):
  164.         temp = combinate(board[i][::-1])
  165.         for j in range(4):
  166.             board[i][3-j] = temp[j]
  167.             # score += temp[1]
  168.     # return score

  169. def up():
  170.     for i in range(4):
  171.         to_comb = []
  172.         for j in range(4):
  173.             to_comb.append(board[j][i])
  174.         temp = combinate(to_comb)
  175.         for k in range(4):
  176.             board[k][i] = temp[k]
  177.             # score += temp[1]
  178.     # return score

  179. def down():
  180.     for i in range(4):
  181.         to_comb = []
  182.         for j in range(4):
  183.             to_comb.append(board[3-j][i])
  184.         temp = combinate(to_comb)
  185.         for k in range(4):
  186.             board[3-k][i] = temp[k]
  187.             # score += temp[1]
  188.     # return score

  189. def write(msg="pygame is cool", color= BLACK, height = 14):   
  190.     #myfont = pygame.font.SysFont("None", 32) #To avoid py2exe error
  191.     myfont = pygame.font.Font("FreeSansBold.ttf", height)
  192.     mytext = myfont.render(msg, True, color)
  193.     mytext = mytext.convert_alpha()
  194.     return mytext

  195. def is_over():
  196.     ### if 0 in board
  197.     for i in range(4):
  198.         for j in range(4):
  199.             if board[i][j] == 0:
  200.                 return False

  201.     for i in range(4):
  202.         for j in range(3):
  203.             if board[i][j] == board[i][j+1]:
  204.                 return False

  205.     for i in range(3):
  206.         for j in range(4):
  207.             if board[i][j] == board[i+1][j]:
  208.                 return False

  209.     return True

  210. def read_best():
  211.     try:
  212.         f = open('best.rec', 'r')
  213.         best = int(f.read())
  214.         f.close()
  215.     except:
  216.         best = 0
  217.     return best

  218. def write_best(best):
  219.     try:
  220.         f = open('best.rec', 'w')
  221.         f.write(str(best))
  222.         f.close()
  223.     except IOError:
  224.         pass

  225. def main():
  226.     global score
  227.     screen.blit(background, (0, 0))
  228.     init_board()
  229.     newboard = deepcopy(board)
  230.     gameover = is_over()
  231.    
  232.     #### test text and color in box
  233.     # for i in range(4):
  234.     #     for j in range(4):
  235.     #         board[i][j] = 2 ** (i+4*j)
  236.     # board[0][0] = 0
  237.     ### end test text and color

  238.     draw_box()
  239.     screen.blit(write("2048", height = 40, color = GOLD), (left_of_screen, left_of_screen // 2))

  240.     screen.blit(write("SCORE", height=14, color=FORESTGREEN), (left_of_screen+105, left_of_screen//2 + 5))
  241.     rect1 = pygame.draw.rect(screen, FORESTGREEN, (left_of_screen+100, left_of_screen//2 + 30, 60, 20))
  242.     text1 = write(str(score), height=14, color=GOLD)
  243.     text1_rect = text1.get_rect()
  244.     text1_rect.center = (left_of_screen+100+30, left_of_screen//2 + 40)
  245.     screen.blit(text1, text1_rect)

  246.     screen.blit(write("BEST", height=14, color=FORESTGREEN), (left_of_screen+175, left_of_screen//2 + 5))
  247.     rect2 = pygame.draw.rect(screen, FORESTGREEN, (left_of_screen+165, left_of_screen//2 + 30, 60, 20))
  248.     best = read_best()
  249.     if best < score:
  250.         best = score
  251.     text2 = write(str(best), height=14, color=GOLD)
  252.     text2_rect = text2.get_rect()
  253.     text2_rect.center = (left_of_screen+165+30, left_of_screen//2 + 40)
  254.     screen.blit(text2, text2_rect)


  255.     screen.blit(write("Use LEFT, RIGHT, UP, DOWN", height=16, color=GRAY), (left_of_screen, screen_height - bottom_of_screen))
  256.     while True:
  257.         for event in pygame.event.get():
  258.             if event.type == QUIT or (event.type == KEYUP and event.key == K_ESCAPE):
  259.                 write_best(best)
  260.                 pygame.quit()
  261.                 exit()
  262.             elif not gameover:
  263.                 if event.type == KEYUP and event.key == K_UP:
  264.                     up()
  265.                 elif event.type == KEYUP and event.key == K_DOWN:
  266.                     down()
  267.                 elif event.type == KEYUP and event.key == K_LEFT:
  268.                     left()
  269.                 elif event.type == KEYUP and event.key == K_RIGHT:
  270.                     right()
  271.                 if newboard != board:
  272.                     set_random_number()
  273.                     newboard = deepcopy(board)
  274.                     draw_box()
  275.                 gameover = is_over()
  276.                
  277.                 rect1 = pygame.draw.rect(screen, FORESTGREEN, (left_of_screen+100, left_of_screen//2 + 30, 60, 20))
  278.                 text1 = write(str(score), height=14, color=GOLD)
  279.                 text_rect = text1.get_rect()
  280.                 text_rect.center = (left_of_screen+100+30, left_of_screen//2 + 40)
  281.                 screen.blit(text1, text_rect)

  282.                 rect2 = pygame.draw.rect(screen, FORESTGREEN, (left_of_screen+165, left_of_screen//2 + 30, 60, 20))
  283.                 if best < score:
  284.                     best = score
  285.                 text2 = write(str(best), height=14, color=GOLD)
  286.                 text2_rect = text2.get_rect()
  287.                 text2_rect.center = (left_of_screen+165+30, left_of_screen//2 + 40)
  288.                 screen.blit(text2, text2_rect)

  289.             else:
  290.                 write_best(best)
  291.                 screen.blit(write("Game Over!", height = 40, color = FORESTGREEN), (left_of_screen, screen_height // 2))
  292.             
  293.             
  294.         pygame.display.update()

  295. if __name__ == "__main__":
  296.     main()
  297.     # test()
  298.     # print(combinate([4,2,2,2]))
复制代码



回复

使用道具 举报

0

主题

3

帖子

10

积分

贫民

积分
10
QQ
ideas4u 发表于 2014-6-8 23:37:31 | 显示全部楼层
这是python 2 还是python 3 呢?
回复 支持 反对

使用道具 举报

0

主题

5

帖子

5

积分

贫民

积分
5
sy392956236 发表于 2014-6-9 08:57:54 | 显示全部楼层
本帖最后由 sy392956236 于 2014-6-9 09:02 编辑

之前我也用pygame写了个2048  嘿

代码贴错了  见下边回复  牙哥多指教啊
回复 支持 反对

使用道具 举报

0

主题

5

帖子

5

积分

贫民

积分
5
sy392956236 发表于 2014-6-9 08:59:13 | 显示全部楼层
:( 原来代码要这样帖啊

  1. #encoding=utf-8
  2. import pygame
  3. import random
  4. import numpy
  5. from pygame.locals import *

  6. SIZE = 4                                                                                 #游戏尺寸
  7. SCORE = 0                                                                                #初始分数
  8. NUM_BLOCK = 110                                                                 #数字块大小
  9. BLOCK_SPACE = 10                                                                 #数字块间隙
  10. H=NUM_BLOCK*SIZE+BLOCK_SPACE*(SIZE+1)                        #界面宽度
  11. TITLE_RECT = pygame.Rect(0,0,H,110)                                #title大小
  12. DATA = numpy.zeros([SIZE,SIZE])                                        #初始数字矩阵
  13. SCREEN_SIZE = (H,H+110)                                                        #界面尺寸
  14. BLOCK_COLOR = {
  15.         0:(150,150,150),
  16.         2:(255,255,255),
  17.         4:(255,255,128),
  18.         8:(255,255,0),
  19.         16:(255,220,128),
  20.         32:(255,220,0),
  21.         64:(255,190,0),
  22.         128:(255,160,0),
  23.         256:(255,130,0),
  24.         512:(255,100,0),
  25.         1024:(255,70,0),
  26.         2048:(255,40,0),
  27.         4096:(255,10,0),
  28. }                                                                                                #数块颜色



  29. class NumUpdata(object):
  30.         """docstring for NumUpdata"""
  31.         def __init__(self,data):
  32.                 super(NumUpdata, self).__init__()
  33.                 self.data = data
  34.                 self.zerolist=[]
  35.                 self.score=0
  36.        
  37.         def sumSameNum(self,dl):
  38.                 global score
  39.                 start_num=0
  40.                 end_num=len(dl)-dl.count(0)
  41.                 while start_num<end_num-1:
  42.                         if dl[start_num] ==  dl[start_num+1]:
  43.                                 dl[start_num]=dl[start_num]*2                               
  44.                                 self.score+=dl[start_num]
  45.                                 dl[start_num+1:]=dl[start_num+2:]
  46.                                 dl.append(0)
  47.                         start_num+=1
  48.                 return dl
  49.        
  50.         def removeZero(self,dl):
  51.                 while True:
  52.                         mid=dl[:]
  53.                         try:
  54.                                 dl.remove(0)
  55.                                 dl.append(0)
  56.                         except:pass
  57.                         if mid == dl:
  58.                                 break
  59.                 return self.sumSameNum(dl)

  60.         def handleData(self):
  61.                 lastdata=self.data.copy()
  62.                 m,n = self.data.shape
  63.                 for i in xrange(m):
  64.                         newdi = self.removeZero(list(self.data[i]))
  65.                         self.data[i] = newdi
  66.                         for k in range(self.SIZE-1,self.SIZE-newdi.count(0)-1,-1):
  67.                                 self.zerolist.append((i,k))
  68.                 if self.data.min() == 0 and (lastdata != self.data).any():
  69.                         self.data=otherTool().initData(self.SIZE,self.data,self.zerolist)

  70.         def toNormalization(self):
  71.                 pass

  72.         def getNext(self,SIZE,scorenow=0):
  73.                 self.SIZE = SIZE
  74.                 return self.toNormalization().copy(),self.score
  75.                
  76.                
  77. class UpAction(NumUpdata):
  78.         """docstring for UpAction"""
  79.         def __init__(self, data):
  80.                 super(UpAction, self).__init__(data)

  81.         def toNormalization(self):
  82.                 self.data = self.data.T
  83.                 self.handleData()
  84.                 return self.data.T


  85. class DownAction(NumUpdata):
  86.         """docstring for DownAction"""
  87.         def __init__(self, data):
  88.                 super(DownAction, self).__init__(data)

  89.         def toNormalization(self):
  90.                 self.data=self.data[::-1].T
  91.                 self.handleData()
  92.                 return self.data.T[::-1]


  93. class LeftAction(NumUpdata):
  94.         """docstring for LeftAction"""
  95.         def __init__(self, data):
  96.                 super(LeftAction, self).__init__(data)

  97.         def toNormalization(self):
  98.                 self.handleData()
  99.                 return self.data


  100. class RightAction(NumUpdata):
  101.         """docstring for RightAction"""
  102.         def __init__(self, data):
  103.                 super(RightAction, self).__init__(data)

  104.         def toNormalization(self):
  105.                 self.data = self.data[:,::-1]
  106.                 self.handleData()
  107.                 return self.data[:,::-1]

  108.                
  109. class KeyDownFactory(object):
  110.         def getNext(self,SIZE,scorenow):
  111.                 return otherTool().initData(SIZE),-scorenow
  112.         def factory(slef,kp,data):
  113.                 if kp[K_w]:
  114.                         return UpAction(data),True
  115.                 elif kp[K_a]:
  116.                         return LeftAction(data),True
  117.                 elif kp[K_s]:
  118.                         return DownAction(data),True
  119.                 elif kp[K_d]:
  120.                         return RightAction(data),True
  121.                 elif kp[K_SPACE]:
  122.                         return KeyDownFactory(),True
  123.                 else:
  124.                         return False,True


  125. class MouseDownFactory(object):
  126.         pass


  127. class otherTool(object):
  128.         def getInitRandomLocal(self,SIZE):
  129.                 a = random.randint(0,SIZE-1)
  130.                 b = random.randint(0,SIZE-1)
  131.                 return a,b
  132.        
  133.         def getNewNum(self):
  134.                 k = random.random()
  135.                 if k>0.95:n=4
  136.                 else:n=2
  137.                 return n
  138.        
  139.         def getNextRandomLocal(self, zl):
  140.                 return random.sample(zl, 1)[0]

  141.         def initData(self,SIZE,data = None,zl = None):
  142.                 if data == None:data = DATA.copy()
  143.                 else:data = data.copy()
  144.                 if zl == None:a,b = self.getInitRandomLocal(SIZE)
  145.                 else:a,b = self.getNextRandomLocal(zl)
  146.                 n = self.getNewNum()
  147.                 data[a][b] = n
  148.                 return data

  149.         def isEnd(self,data,SIZE):
  150.                 d0 = data.copy()
  151.                 d1 = UpAction(data.copy()).getNext(SIZE)[0]
  152.                 if (d0 != d1).any():return False
  153.                 d2 = DownAction(data.copy()).getNext(SIZE)[0]
  154.                 if (d0 != d2).any():return False
  155.                 d3 = LeftAction(data.copy()).getNext(SIZE)[0]
  156.                 if (d0 != d3).any():return False
  157.                 d4 = RightAction(data.copy()).getNext(SIZE)[0]
  158.                 if (d0 != d4).any():return False
  159.                 return True

  160.         def drawSerface(self,screen,TITLE_RECT,scorenow,data,NUM_BLOCK,BLOCK_SPACE,BLOCK_COLOR):
  161.                 screen.fill((0,0,0))
  162.                 pygame.draw.rect(screen,(255,255,255),TITLE_RECT)
  163.                 font1 = pygame.font.SysFont("stxingkai", 40)
  164.                 font2 = pygame.font.SysFont("stxingkai", 20)
  165.                 screen.blit(font1.render("2048", True, (0, 0, 0)), (0, 0))
  166.                 screen.blit(font2.render(u"←:a  ↓:s  →:d     复位:空格", True, (0, 0, 0)), (250, 25))
  167.                 screen.blit(font2.render(u"↑:w", True, (0, 0, 0)), (294, 0))
  168.                 screen.blit(font1.render("SCORE:", True, (0, 0, 0)), (50, 50))
  169.                 screen.blit(font1.render(str(int(scorenow)), True, (0, 0, 0)), (200, 50))
  170.                 a,b = data.shape
  171.                 for i in xrange(a):
  172.                         for k in xrange(b):
  173.                                 self.drawBlock(i,k,NUM_BLOCK,BLOCK_SPACE,BLOCK_COLOR[data[i][k]],screen,data[i][k])

  174.         def drawBlock(slef,a,b,NUM_BLOCK,BLOCK_SPACE,color,screen,num):
  175.                 font = pygame.font.SysFont("stxingkai", 80)
  176.                 h = a*NUM_BLOCK+(a+1)*BLOCK_SPACE+110
  177.                 w = b*NUM_BLOCK+(b+1)*BLOCK_SPACE
  178.                 pygame.draw.rect(screen,color,(w,h,110,110))
  179.                 if num != 0:
  180.                         f,t=font.size(str(int(num)))
  181.                         screen.blit(font.render(str(int(num)), True, (0, 0, 0)), (w+(110-f)/2, h+(110-t)/2))


  182. def main():
  183.         pygame.init()
  184.         screen = pygame.display.set_mode(SCREEN_SIZE,0,32)
  185.         data = otherTool().initData(SIZE)
  186.         scorenow = SCORE
  187.         end = False
  188.         otherTool().drawSerface(screen,TITLE_RECT,scorenow,data,NUM_BLOCK,BLOCK_SPACE,BLOCK_COLOR)
  189.         #print data
  190.         #print scorenow
  191.         while True:
  192.                 for event in pygame.event.get():
  193.                         if event.type == QUIT:
  194.                                 exit()
  195.                         elif event.type == KEYDOWN:
  196.                                 pressed_keys = pygame.key.get_pressed()
  197.                                 newdata , reset = KeyDownFactory().factory(pressed_keys,data)
  198.                                 if reset:end = False
  199.                                 if newdata and not end:
  200.                                         data,score = newdata.getNext(SIZE,scorenow)
  201.                                         scorenow += score
  202.                                         if data.min() != 0:
  203.                                                 end = otherTool().isEnd(data,SIZE)
  204.                                         otherTool().drawSerface(screen,TITLE_RECT,scorenow,data,NUM_BLOCK,BLOCK_SPACE,BLOCK_COLOR)
  205.                                         #print data
  206.                                         #print scorenow
  207.                                         #print end
  208.                 pygame.display.update()


  209. if __name__ == '__main__':
  210.         main()
复制代码
回复 支持 反对

使用道具 举报

50

主题

1057

帖子

1108

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1108

活跃会员热心会员最佳导师默默耕耘突出贡献优秀版主荣誉管理论坛元老

blueelwang  楼主| 发表于 2014-6-10 15:58:32 | 显示全部楼层
sy392956236 发表于 2014-6-9 08:59
原来代码要这样帖啊

:lol 哈哈啊哈
回复 支持 反对

使用道具 举报

0

主题

2

帖子

8

积分

贫民

积分
8
-死神- 发表于 2014-10-17 23:59:49 | 显示全部楼层
楼主的缺乏几个文件吧,求上传
回复 支持 反对

使用道具 举报

50

主题

1057

帖子

1108

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1108

活跃会员热心会员最佳导师默默耕耘突出贡献优秀版主荣誉管理论坛元老

blueelwang  楼主| 发表于 2014-10-20 14:17:05 | 显示全部楼层
-死神- 发表于 2014-10-17 23:59
楼主的缺乏几个文件吧,求上传

???不缺少文件吧
回复 支持 反对

使用道具 举报

0

主题

1

帖子

4

积分

贫民

积分
4
livan 发表于 2016-6-18 20:57:26 | 显示全部楼层

貌似缺少 background.png
回复 支持 反对

使用道具 举报

0

主题

1

帖子

4

积分

贫民

积分
4
xiaoc 发表于 2016-7-5 17:34:21 | 显示全部楼层
报错啊,亲
import pygame
ImportError: No module named pygame
回复 支持 反对

使用道具 举报

50

主题

1057

帖子

1108

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1108

活跃会员热心会员最佳导师默默耕耘突出贡献优秀版主荣誉管理论坛元老

blueelwang  楼主| 发表于 2016-7-8 12:14:34 | 显示全部楼层
xiaoc 发表于 2016-7-5 17:34
报错啊,亲
import pygame
ImportError: No module named pygame

需要安装pygame模块啊,亲,
建议你先学一下python基础
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表