{"id":884862,"student_id":2589,"content":"from game import *\nfrom random import *\n\nset_backdrop('bg.jpg')\ncover = create_sprite('cover.png')\na = create_sprite('cat_0.png', 'cat_1.png') #上方貓咪\nb = create_sprite('dog_0.png', 'dog_1.png') #右方狗狗\nc = create_sprite('sheep_0.png', 'sheep_1.png') #下方綿羊\nd = create_sprite('duck_0.png', 'duck_1.png') #左方鴨子\nrules = create_sprite('rules.png') #遊戲規則\nbgm = create_sound('bgm.ogg', True)\n\na.y -= 250 #移至上方\nb.x += 250 #移至右方\nc.y += 250 #移至下方\nd.x -= 250 #移至左方\ncover.hidden = True\n\nclock = 0 #遊戲迴圈次數\ncount = 0 #目前演奏到哪\n\n# 狀態 intro 開場演奏\n# 狀態 auto 自動演奏\n# 狀態 play 玩家演奏\nstatus = 'intro'\n\n# 播放順序\nnotes = [1, 1, 2, 2, 3, 3, 4, 4, 1, 2, 3, 4, 1, 2, 3, 4]\n\n# 開始遊戲時隱藏遊戲規則\ndef start_game():\n rules.hidden = True\n\n# 遊戲主迴圈\ndef loop():\n global clock, count, status\n \n if not rules.hidden: return\n\n clock += 1\n \n # 如果狀態是自動而且 clock 每執行 30 次而且 clock 大於 0\n space = 15 if status == 'intro' else 30\n if status != 'play' and clock % space == 0 and clock \u003e 0:\n if notes[count] == 1: play_a()\n if notes[count] == 2: play_b()\n if notes[count] == 3: play_c()\n if notes[count] == 4: play_d()\n count += 1\n \n # 如果數到超過 notes 的長度時就切換狀態\n if count == len(notes):\n count = 0\n clock = -60\n if status == 'auto': #如果狀態為自動播放\n status = 'play' #切換成玩家遊玩\n elif status == 'play': #如果狀態為玩家遊玩\n status = 'auto' #切換成自動播放\n notes.append(randint(1, 4))\n elif status == 'intro':\n status = 'auto'\n notes.clear()\n notes.append(randint(1, 4))\n \n draw_text(len(notes) - 1, 80, 80, 'black', 60)\n\n#播放貓咪叫聲\ndef play_a():\n create_sound('cat.wav')\n a.scale = 0.7\n\n#播放狗狗叫聲\ndef play_b():\n create_sound('dog.wav')\n b.scale = 0.7\n\n#播放綿羊叫聲\ndef play_c():\n create_sound('sheep.wav')\n c.scale = 0.7\n\n#播放鴨子叫聲\ndef play_d():\n create_sound('duck.mp3')\n d.scale = 0.7\n\n#動物的縮放動畫\ndef animate():\n if a.scale \u003c= 1: a.scale += 0.1\n if b.scale \u003c= 1: b.scale += 0.1\n if c.scale \u003c= 1: c.scale += 0.1\n if d.scale \u003c= 1: d.scale += 0.1\n cover.hidden = status != 'play'\n\n#點擊貓咪執行此程式\ndef click_a():\n global count\n if status == 'play':\n if notes[count] == 1:\n play_a()\n count += 1\n else:\n stop()\n\n#點擊狗狗執行此程式\ndef click_b():\n global count\n if status == 'play':\n if notes[count] == 2:\n play_b()\n count += 1\n else:\n stop()\n\n#點擊綿羊執行此程式\ndef click_c():\n global count\n if status == 'play':\n if notes[count] == 3:\n play_c()\n count += 1\n else:\n stop()\n\n#點擊鴨子執行此程式\ndef click_d():\n global count\n if status == 'play':\n if notes[count] == 4:\n play_d()\n count += 1\n else:\n stop()\n\na.on('click', click_a) #點擊貓咪執行 click_a 函式\nb.on('click', click_b) #點擊狗狗執行 click_a 函式\nc.on('click', click_c) #點擊綿羊執行 click_a 函式\nd.on('click', click_d) #點擊鴨子執行 click_a 函式\nrules.on('click', start_game) #點擊遊戲說明圖開始遊戲\nforever(loop) #重複不斷執行遊戲迴圈\nforever(animate) #縮放動畫以及隱藏顯示遮罩\n \n","created_at":"2024-11-15T12:15:48.445+08:00","updated_at":"2024-11-15T12:16:00.031+08:00","name":"3_小小音樂家_完整版","language":"python","screenshot":{"url":null},"parent_id":829980,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":8,"hashid":"rdvsdjj8z","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":34443214,"file_name":"cover.png","project_id":884862,"asset_id":791918,"created_at":"2024-11-15T12:15:59.881+08:00","updated_at":"2024-11-15T12:15:59.881+08:00"},{"id":34443215,"file_name":"duck_0.png","project_id":884862,"asset_id":791919,"created_at":"2024-11-15T12:15:59.886+08:00","updated_at":"2024-11-15T12:15:59.886+08:00"},{"id":34443216,"file_name":"bg.jpg","project_id":884862,"asset_id":791920,"created_at":"2024-11-15T12:15:59.890+08:00","updated_at":"2024-11-15T12:15:59.890+08:00"},{"id":34443217,"file_name":"cat_0.png","project_id":884862,"asset_id":791921,"created_at":"2024-11-15T12:15:59.894+08:00","updated_at":"2024-11-15T12:15:59.894+08:00"},{"id":34443218,"file_name":"dog.wav","project_id":884862,"asset_id":791922,"created_at":"2024-11-15T12:15:59.899+08:00","updated_at":"2024-11-15T12:15:59.899+08:00"},{"id":34443219,"file_name":"dog_1.png","project_id":884862,"asset_id":791923,"created_at":"2024-11-15T12:15:59.903+08:00","updated_at":"2024-11-15T12:15:59.903+08:00"},{"id":34443220,"file_name":"cat.wav","project_id":884862,"asset_id":791924,"created_at":"2024-11-15T12:15:59.909+08:00","updated_at":"2024-11-15T12:15:59.909+08:00"},{"id":34443221,"file_name":"pig_0.png","project_id":884862,"asset_id":791925,"created_at":"2024-11-15T12:15:59.913+08:00","updated_at":"2024-11-15T12:15:59.913+08:00"},{"id":34443222,"file_name":"pig_1.png","project_id":884862,"asset_id":791926,"created_at":"2024-11-15T12:15:59.917+08:00","updated_at":"2024-11-15T12:15:59.917+08:00"},{"id":34443223,"file_name":"result.png","project_id":884862,"asset_id":791927,"created_at":"2024-11-15T12:15:59.922+08:00","updated_at":"2024-11-15T12:15:59.922+08:00"},{"id":34443224,"file_name":"rules.png","project_id":884862,"asset_id":791928,"created_at":"2024-11-15T12:15:59.927+08:00","updated_at":"2024-11-15T12:15:59.927+08:00"},{"id":34443225,"file_name":"sheep.wav","project_id":884862,"asset_id":791929,"created_at":"2024-11-15T12:15:59.932+08:00","updated_at":"2024-11-15T12:15:59.932+08:00"},{"id":34443226,"file_name":"cat_1.png","project_id":884862,"asset_id":791930,"created_at":"2024-11-15T12:15:59.936+08:00","updated_at":"2024-11-15T12:15:59.936+08:00"},{"id":34443227,"file_name":"chicken_0.png","project_id":884862,"asset_id":791931,"created_at":"2024-11-15T12:15:59.940+08:00","updated_at":"2024-11-15T12:15:59.940+08:00"},{"id":34443228,"file_name":"duck_1.png","project_id":884862,"asset_id":791932,"created_at":"2024-11-15T12:15:59.944+08:00","updated_at":"2024-11-15T12:15:59.944+08:00"},{"id":34443229,"file_name":"horse_0.png","project_id":884862,"asset_id":791933,"created_at":"2024-11-15T12:15:59.948+08:00","updated_at":"2024-11-15T12:15:59.948+08:00"},{"id":34443230,"file_name":"horse_1.png","project_id":884862,"asset_id":791934,"created_at":"2024-11-15T12:15:59.952+08:00","updated_at":"2024-11-15T12:15:59.952+08:00"},{"id":34443231,"file_name":"note.png","project_id":884862,"asset_id":791935,"created_at":"2024-11-15T12:15:59.956+08:00","updated_at":"2024-11-15T12:15:59.956+08:00"},{"id":34443232,"file_name":"chicken_1.png","project_id":884862,"asset_id":791936,"created_at":"2024-11-15T12:15:59.960+08:00","updated_at":"2024-11-15T12:15:59.960+08:00"},{"id":34443233,"file_name":"cow_0.png","project_id":884862,"asset_id":791937,"created_at":"2024-11-15T12:15:59.964+08:00","updated_at":"2024-11-15T12:15:59.964+08:00"},{"id":34443234,"file_name":"bgm.ogg","project_id":884862,"asset_id":791938,"created_at":"2024-11-15T12:15:59.993+08:00","updated_at":"2024-11-15T12:15:59.993+08:00"},{"id":34443235,"file_name":"cow_1.png","project_id":884862,"asset_id":791939,"created_at":"2024-11-15T12:15:59.997+08:00","updated_at":"2024-11-15T12:15:59.997+08:00"},{"id":34443236,"file_name":"dog_0.png","project_id":884862,"asset_id":791940,"created_at":"2024-11-15T12:16:00.002+08:00","updated_at":"2024-11-15T12:16:00.002+08:00"},{"id":34443237,"file_name":"sheep_0.png","project_id":884862,"asset_id":791941,"created_at":"2024-11-15T12:16:00.021+08:00","updated_at":"2024-11-15T12:16:00.021+08:00"},{"id":34443238,"file_name":"sheep_1.png","project_id":884862,"asset_id":791942,"created_at":"2024-11-15T12:16:00.025+08:00","updated_at":"2024-11-15T12:16:00.025+08:00"},{"id":34443239,"file_name":"duck.mp3","project_id":884862,"asset_id":791943,"created_at":"2024-11-15T12:16:00.029+08:00","updated_at":"2024-11-15T12:16:00.029+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦