{"id":863580,"student_id":1981,"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 = 'auto'\n\n# 播放順序\nnotes = []\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 if status != 'play' and clock % 30 == 0 and clock \u003e 0:\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 elif status == 'intro': #開場演奏切換成自動播放\n status = 'auto'\n \n draw_text(notes[count], 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_b 函式\nc.on('click', click_c) #點擊綿羊執行 click_c 函式\nd.on('click', click_d) #點擊鴨子執行 click_d 函式\nrules.on('click', start_game) #點擊遊戲說明圖開始遊戲\nforever(loop) #重複不斷執行遊戲迴圈\nforever(animate) #縮放動畫以及隱藏顯示遮罩\n \n","created_at":"2024-10-15T16:11:12.980+08:00","updated_at":"2024-10-15T16:11:12.980+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":3,"hashid":"zpes8g38w","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":18911726,"file_name":"cover.png","project_id":863580,"asset_id":771615,"created_at":"2024-10-15T16:11:12.986+08:00","updated_at":"2024-10-15T16:11:12.986+08:00"},{"id":18911727,"file_name":"duck_0.png","project_id":863580,"asset_id":771616,"created_at":"2024-10-15T16:11:12.987+08:00","updated_at":"2024-10-15T16:11:12.987+08:00"},{"id":18911728,"file_name":"bg.jpg","project_id":863580,"asset_id":771617,"created_at":"2024-10-15T16:11:12.988+08:00","updated_at":"2024-10-15T16:11:12.988+08:00"},{"id":18911729,"file_name":"cat_0.png","project_id":863580,"asset_id":771618,"created_at":"2024-10-15T16:11:12.989+08:00","updated_at":"2024-10-15T16:11:12.989+08:00"},{"id":18911730,"file_name":"dog.wav","project_id":863580,"asset_id":771619,"created_at":"2024-10-15T16:11:12.990+08:00","updated_at":"2024-10-15T16:11:12.990+08:00"},{"id":18911731,"file_name":"dog_1.png","project_id":863580,"asset_id":771620,"created_at":"2024-10-15T16:11:12.991+08:00","updated_at":"2024-10-15T16:11:12.991+08:00"},{"id":18911732,"file_name":"cat.wav","project_id":863580,"asset_id":771621,"created_at":"2024-10-15T16:11:12.991+08:00","updated_at":"2024-10-15T16:11:12.991+08:00"},{"id":18911733,"file_name":"pig_0.png","project_id":863580,"asset_id":771622,"created_at":"2024-10-15T16:11:12.992+08:00","updated_at":"2024-10-15T16:11:12.992+08:00"},{"id":18911734,"file_name":"pig_1.png","project_id":863580,"asset_id":771623,"created_at":"2024-10-15T16:11:12.993+08:00","updated_at":"2024-10-15T16:11:12.993+08:00"},{"id":18911735,"file_name":"result.png","project_id":863580,"asset_id":771624,"created_at":"2024-10-15T16:11:12.994+08:00","updated_at":"2024-10-15T16:11:12.994+08:00"},{"id":18911736,"file_name":"rules.png","project_id":863580,"asset_id":771625,"created_at":"2024-10-15T16:11:12.995+08:00","updated_at":"2024-10-15T16:11:12.995+08:00"},{"id":18911737,"file_name":"sheep.wav","project_id":863580,"asset_id":771626,"created_at":"2024-10-15T16:11:12.996+08:00","updated_at":"2024-10-15T16:11:12.996+08:00"},{"id":18911738,"file_name":"cat_1.png","project_id":863580,"asset_id":771627,"created_at":"2024-10-15T16:11:12.997+08:00","updated_at":"2024-10-15T16:11:12.997+08:00"},{"id":18911739,"file_name":"chicken_0.png","project_id":863580,"asset_id":771628,"created_at":"2024-10-15T16:11:12.997+08:00","updated_at":"2024-10-15T16:11:12.997+08:00"},{"id":18911740,"file_name":"duck_1.png","project_id":863580,"asset_id":771629,"created_at":"2024-10-15T16:11:12.998+08:00","updated_at":"2024-10-15T16:11:12.998+08:00"},{"id":18911741,"file_name":"horse_0.png","project_id":863580,"asset_id":771630,"created_at":"2024-10-15T16:11:12.999+08:00","updated_at":"2024-10-15T16:11:12.999+08:00"},{"id":18911742,"file_name":"horse_1.png","project_id":863580,"asset_id":771631,"created_at":"2024-10-15T16:11:13.000+08:00","updated_at":"2024-10-15T16:11:13.000+08:00"},{"id":18911743,"file_name":"note.png","project_id":863580,"asset_id":771632,"created_at":"2024-10-15T16:11:13.001+08:00","updated_at":"2024-10-15T16:11:13.001+08:00"},{"id":18911744,"file_name":"chicken_1.png","project_id":863580,"asset_id":771633,"created_at":"2024-10-15T16:11:13.002+08:00","updated_at":"2024-10-15T16:11:13.002+08:00"},{"id":18911745,"file_name":"cow_0.png","project_id":863580,"asset_id":771634,"created_at":"2024-10-15T16:11:13.002+08:00","updated_at":"2024-10-15T16:11:13.002+08:00"},{"id":18911746,"file_name":"bgm.ogg","project_id":863580,"asset_id":771635,"created_at":"2024-10-15T16:11:13.003+08:00","updated_at":"2024-10-15T16:11:13.003+08:00"},{"id":18911747,"file_name":"cow_1.png","project_id":863580,"asset_id":771636,"created_at":"2024-10-15T16:11:13.004+08:00","updated_at":"2024-10-15T16:11:13.004+08:00"},{"id":18911748,"file_name":"dog_0.png","project_id":863580,"asset_id":771637,"created_at":"2024-10-15T16:11:13.005+08:00","updated_at":"2024-10-15T16:11:13.005+08:00"},{"id":18911749,"file_name":"sheep_0.png","project_id":863580,"asset_id":771638,"created_at":"2024-10-15T16:11:13.006+08:00","updated_at":"2024-10-15T16:11:13.006+08:00"},{"id":18911750,"file_name":"sheep_1.png","project_id":863580,"asset_id":771639,"created_at":"2024-10-15T16:11:13.007+08:00","updated_at":"2024-10-15T16:11:13.007+08:00"},{"id":18911751,"file_name":"duck.mp3","project_id":863580,"asset_id":771640,"created_at":"2024-10-15T16:11:13.007+08:00","updated_at":"2024-10-15T16:11:13.007+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦