Upgrade to Pro — share decks privately, control downloads, hide ads and more …

B0129046

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
Avatar for kai820228 kai820228
June 19, 2014
95

 B0129046

Avatar for kai820228

kai820228

June 19, 2014
Tweet

Transcript

  1. 程式碼 import random, pygame, sys from pygame.locals import * def

    主程式(): global 時間暫停, 視窗 pygame.init() 時間暫停 = pygame.time.Clock() 視窗 = pygame.display.set_mode((640, 480)) 變數1 = 0 變數2 = 0 pygame.display.set_caption('記憶遊戲') 變數3 = 函式甲() 串列1 = 串列函式(False) 變數4 = None 視窗.fill((60, 60, 100)) 函式丑(變數3) 主程式->
  2. while True: 變數5 = False 視窗.fill((60, 60, 100)) 函式癸(變數3, 串列1)

    for 變數8 in pygame.event.get(): if 變數8.type == QUIT or (變數8.type == KEYUP and 變數 8.key == K_ESCAPE): pygame.quit() sys.exit() elif 變數8.type == MOUSEMOTION: 變數1, 變數2 = 變數8.pos elif 變數8.type == MOUSEBUTTONUP: 變數1, 變數2 = 變數8.pos 變數5 = True 變數6, 變數7 = 函式丁(變數1, 變數2)
  3. if 變數6 != None and 變數7 != None: if not

    串列1[變數6][變數7]: 函式子(變數6, 變數7) if not 串列1[變數6][變數7] and 變數5: 函式辛(變數3, [(變數6, 變數7)]) 串列1[變數6][變數7] = True if 變數4 == None: 變數4 = (變數6, 變數7) else: 變數9, 變數10 = 函式己(變數3, 變數4[0], 變數 4[1]) 變數11, 變數12 = 函式己(變數3, 變數6, 變數7) if 變數9 != 變數11 or 變數10 != 變數12: pygame.time.wait(1000) 函式壬(變數3, [(變數4[0], 變數4[1]), (變數6, 變 數7)]) 串列1[變數4[0]][變數4[1]] = False 串列1[變數6][變數7] = False
  4. elif 函式卯(串列1): 函式寅(變數3) pygame.time.wait(2000) 變數3 = 函式甲() 串列1 = 串列函式(False)

    函式癸(變數3, 串列1) pygame.display.update() pygame.time.wait(1000) 函式丑(變數3) 變數4 = None pygame.display.update() 時間暫停.tick(30)
  5. def 串列函式(變數13): 串列1 = [] for 變數3 in range(10): 串列1.append([變數13]

    * 7) return 串列1 def 函式甲(): 串列2 = [] for 變數14 in ((255, 0, 0), (0, 255, 0), (0, 0, 255), (255, 255, 0), (255, 128, 0), (255, 0, 255), (0, 255, 255)): for 變數23 in ('a', '視窗', '函式甲', '串列函式', '變數5'): 串列2.append( (變數23, 變數14) ) random.shuffle(串列2) 串列2 = 串列2[:35] * 2 random.shuffle(串列2) 串列3 = [] for 變數15 in range(10): 串列4 = [] for 變數16 in range(7): 串列4.append(串列2[0]) del 串列2[0] 串列3.append(串列4) return 串列3 各個功能函式->
  6. def 函式乙(變數17, 變數18): 串列5 = [] for 變數3 in range(0,

    len(變數18), 變數17): 串列5.append(變數18[變數3:變數3 + 變數17]) return 串列5 def 函式丙(變數6, 變數7): return (變數6 * 50 + 70, 變數7 * 50 + 65) def 函式丁(變數15, 變數16): for 變數6 in range(10): for 變數7 in range(7): 變數19, 變數20 = 函式丙(變數6, 變數7) 變數22 = pygame.Rect(變數19, 變數20, 40, 40) if 變數22.collidepoint(變數15, 變數16): return (變數6, 變數7) return (None, None)
  7. def 函式戊(變數23, 變數14, 變數6, 變數7): 變數19, 變數20 = 函式丙(變數6, 變數7)

    if 變數23 == 'a': pygame.draw.circle(視窗, 變數14, (變數19 + 20, 變數20 + 20), 15) pygame.draw.circle(視窗, (60, 60, 100), (變數19 + 20, 變數20 + 20), 5) elif 變數23 == '視窗': pygame.draw.rect(視窗, 變數14, (變數19 + 10, 變數20 + 10, 20, 20)) elif 變數23 == '函式甲': pygame.draw.polygon(視窗, 變數14, ((變數19 + 20, 變數20), (變數19 + 40 - 1, 變數20 + 20), (變數19 + 20, 變數20 + 40 - 1), (變數19, 變數20 + 20))) elif 變數23 == '串列函式': for 變數3 in range(0, 40, 4): pygame.draw.line(視窗, 變數14, (變數19, 變數20 + 變數3), (變數19 + 變 數3, 變數20)) pygame.draw.line(視窗, 變數14, (變數19 + 變數3, 變數20 + 39), (變數19 + 39, 變數20 + 變數3)) elif 變數23 == '變數5': pygame.draw.ellipse(視窗, 變數14, (變數19, 變數20 + 10, 40, 20))
  8. def 函式己(串列3, 變數6, 變數7): return 串列3[變數6][變數7][0], 串列3[變數6][變數7][1] def 函式庚(串列3, 變數24,

    變數25): for 變數26 in 變數24: 變數19, 變數20 = 函式丙(變數26[0], 變數26[1]) pygame.draw.rect(視窗, (60, 60, 100), (變數19, 變數20, 40, 40)) 變數23, 變數14 = 函式己(串列3, 變數26[0], 變數26[1]) 函式戊(變數23, 變數14, 變數26[0], 變數26[1]) if 變數25 > 0: pygame.draw.rect(視窗, (255, 255, 255), (變數19, 變數20, 變數 25, 40)) pygame.display.update() 時間暫停.tick(30) def 函式辛(串列3, 變數27): for 變數25 in range(40, (-8) - 1, -8): 函式庚(串列3, 變數27, 變數25) def 函式壬(串列3, 變數28): for 變數25 in range(0, 48, 8): 函式庚(串列3, 變數28, 變數25)
  9. def 函式癸(串列3, 變數29): for 變數6 in range(10): for 變數7 in

    range(7): 變數19, 變數20 = 函式丙(變數6, 變數7) if not 變數29[變數6][變數7]: pygame.draw.rect(視窗, (255, 255, 255), (變數19, 變數20, 40, 40)) else: 變數23, 變數14 = 函式己(串列3, 變數6, 變數7) 函式戊(變數23, 變數14, 變數6, 變數7) def 函式子(變數6, 變數7): 變數19, 變數20 = 函式丙(變數6, 變數7) pygame.draw.rect(視窗, (0, 0, 255), (變數19 - 5, 變數20 - 5, 50, 50), 4) def 函式丑(串列3): 變數21 = 串列函式(False) 變數24 = [] for 變數15 in range(10): for 變數16 in range(7): 變數24.append( (變數15, 變數16) ) random.shuffle(變數24) 變數31 = 函式乙(8, 變數24) 函式癸(串列3, 變數21) for 變數30 in 變數31: 函式辛(串列3, 變數30) 函式壬(串列3, 變數30)
  10. def 函式寅(串列3): 變數21 = 串列函式(True) 變數32 = (100, 100, 100)

    變數33 = (60, 60, 100) for 變數3 in range(13): 變數32, 變數33 = 變數33, 變數32 視窗.fill(變數32) 函式癸(串列3, 變數21) pygame.display.update() pygame.time.wait(300) def 函式卯(串列1): for 變數3 in 串列1: if False in 變數3: return False return True if __name__ == '__main__': 主程式()