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

機率與統計Python期末作業

B0129050
June 20, 2014
210

 機率與統計Python期末作業

Python期末作業

B0129050

June 20, 2014
Tweet

Transcript

  1. 程式碼解說 宣告常數 • 幀數 = 30 # frames per second,

    the general speed of the program • 視窗寬度 = 640 # size of window's width in pixels • 視窗高度 = 480 # size of windows' height in pixels • 揭示速度 = 8 # speed 盒子們' sliding reveals and covers • 盒子大小 = 40 # size of 盒子 height & width in pixels • 間隔大小 = 10 # size of gap between 盒子們 in pixels • 欄寬 = 10 # number of columns of 圖標們 • 列高 = 7 # number of rows of 圖標們 • assert (欄寬 * 列高) % 2 == 0, 'Board needs to have an even number of 盒 子們 for pairs of matches.' • 地圖橫軸範圍 = int((視窗寬度 - (欄寬 * (盒子大小 + 間隔大小))) / 2) • 地圖縱軸範圍 = int((視窗高度 - (列高 * (盒子大小 + 間隔大小))) / 2)
  2. 程式碼解說 • # R G B • 灰色 = (100,

    100, 100) • 深藍色 = ( 60, 60, 100) • 白色 = (255, 255, 255) • 紅色 = (255, 0, 0) • 綠色 = ( 0, 255, 0) • 藍色 = ( 0, 0, 255) • 黃色 = (255, 255, 0) • 橘色 = (255, 128, 0) • 紫色 = (255, 0, 255) • 青色 = ( 0, 255, 255) • 背景顏色 = 深藍色 • 亮背景顏色 = 灰色 • 盒子顏色 = 白色 • 高亮顏色 = 藍色 • 甜甜圈 = 'donut' • 正方形 = 'square' • 鑽石 = 'diamond' • 線條 = 'lines' • 橢圓形 = 'oval'
  3. 函式 • def 產生揭示盒子資料(val):產生data • def 獲得隨機視窗():隨機 • def 分開進入某些群組(groupSize,

    theList):分類 • def 箱子的左邊頂點座標(橫盒子, 縱盒子):定位 • def 獲得箱子在像素(橫, 縱):定位 • def 繪製圖標(外型, 顏色, 橫盒子, 縱盒子):依資料產生圖標 • def 獲得外型與顏色(視窗, 橫盒子, 縱盒子):圖標的外型與顏色 • def 繪製盒子蓋子(視窗, 盒子們, 覆蓋範圍):重新蓋蓋子 • def 揭示盒子動畫(視窗, boxesToReveal):打開盒子的動畫 • def 覆蓋盒子動畫(視窗, boxesToCover):關起盒子的動畫 • def 繪製視窗(視窗, revealed): • def 繪製高亮盒子(橫盒子, 縱盒子): • def 遊戲開始動畫(視窗):開始動畫(提示) • def 遊戲勝利動畫(視窗):結束動畫 • def 獲得勝利(揭示盒子):結束