{"id":795232,"student_id":10,"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(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_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-07-18T12:47:31.989+08:00","updated_at":"2024-07-29T13:47:02.596+08:00","name":"小小音樂家_預設版","language":"python","screenshot":{"url":"https://cdn8.koding.school/uploads/project/screenshot/795232/3af779a2b18cf17b117007d7dc329d7c.jpg"},"parent_id":4,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":42,"hashid":"ej9s62356","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":17637280,"file_name":"cover.png","project_id":795232,"asset_id":756501,"created_at":"2024-07-18T15:24:19.269+08:00","updated_at":"2024-07-18T15:24:19.269+08:00"},{"id":17636322,"file_name":"duck_0.png","project_id":795232,"asset_id":746579,"created_at":"2024-07-18T12:49:36.226+08:00","updated_at":"2024-07-18T12:49:36.226+08:00"},{"id":17636313,"file_name":"bg.jpg","project_id":795232,"asset_id":746570,"created_at":"2024-07-18T12:49:33.614+08:00","updated_at":"2024-07-18T12:49:33.614+08:00"},{"id":17636314,"file_name":"cat_0.png","project_id":795232,"asset_id":746571,"created_at":"2024-07-18T12:49:33.616+08:00","updated_at":"2024-07-18T12:49:33.616+08:00"},{"id":17638216,"file_name":"dog.wav","project_id":795232,"asset_id":756807,"created_at":"2024-07-18T16:56:48.347+08:00","updated_at":"2024-07-18T16:56:48.347+08:00"},{"id":17636321,"file_name":"dog_1.png","project_id":795232,"asset_id":746578,"created_at":"2024-07-18T12:49:36.224+08:00","updated_at":"2024-07-18T12:49:36.224+08:00"},{"id":17638188,"file_name":"cat.wav","project_id":795232,"asset_id":756796,"created_at":"2024-07-18T16:54:08.221+08:00","updated_at":"2024-07-18T16:54:08.221+08:00"},{"id":17636327,"file_name":"pig_0.png","project_id":795232,"asset_id":746584,"created_at":"2024-07-18T12:49:38.676+08:00","updated_at":"2024-07-18T12:49:38.676+08:00"},{"id":17636328,"file_name":"pig_1.png","project_id":795232,"asset_id":746585,"created_at":"2024-07-18T12:49:38.678+08:00","updated_at":"2024-07-18T12:49:38.678+08:00"},{"id":17636329,"file_name":"result.png","project_id":795232,"asset_id":746638,"created_at":"2024-07-18T12:49:39.366+08:00","updated_at":"2024-07-18T12:49:39.366+08:00"},{"id":17636330,"file_name":"rules.png","project_id":795232,"asset_id":746587,"created_at":"2024-07-18T12:49:39.367+08:00","updated_at":"2024-07-18T12:49:39.367+08:00"},{"id":17638217,"file_name":"sheep.wav","project_id":795232,"asset_id":756808,"created_at":"2024-07-18T16:58:47.752+08:00","updated_at":"2024-07-18T16:58:47.752+08:00"},{"id":17636315,"file_name":"cat_1.png","project_id":795232,"asset_id":746572,"created_at":"2024-07-18T12:49:34.335+08:00","updated_at":"2024-07-18T12:49:34.335+08:00"},{"id":17636316,"file_name":"chicken_0.png","project_id":795232,"asset_id":746573,"created_at":"2024-07-18T12:49:34.337+08:00","updated_at":"2024-07-18T12:49:34.337+08:00"},{"id":17636323,"file_name":"duck_1.png","project_id":795232,"asset_id":746580,"created_at":"2024-07-18T12:49:36.978+08:00","updated_at":"2024-07-18T12:49:36.978+08:00"},{"id":17636324,"file_name":"horse_0.png","project_id":795232,"asset_id":746581,"created_at":"2024-07-18T12:49:36.980+08:00","updated_at":"2024-07-18T12:49:36.980+08:00"},{"id":17636325,"file_name":"horse_1.png","project_id":795232,"asset_id":746582,"created_at":"2024-07-18T12:49:38.130+08:00","updated_at":"2024-07-18T12:49:38.130+08:00"},{"id":17636326,"file_name":"note.png","project_id":795232,"asset_id":746639,"created_at":"2024-07-18T12:49:38.132+08:00","updated_at":"2024-07-18T12:49:38.132+08:00"},{"id":17636317,"file_name":"chicken_1.png","project_id":795232,"asset_id":746574,"created_at":"2024-07-18T12:49:34.908+08:00","updated_at":"2024-07-18T12:49:34.908+08:00"},{"id":17636318,"file_name":"cow_0.png","project_id":795232,"asset_id":746575,"created_at":"2024-07-18T12:49:34.910+08:00","updated_at":"2024-07-18T12:49:34.910+08:00"},{"id":17637708,"file_name":"bgm.ogg","project_id":795232,"asset_id":756717,"created_at":"2024-07-18T16:04:41.813+08:00","updated_at":"2024-07-18T16:04:41.813+08:00"},{"id":17636319,"file_name":"cow_1.png","project_id":795232,"asset_id":746576,"created_at":"2024-07-18T12:49:35.639+08:00","updated_at":"2024-07-18T12:49:35.639+08:00"},{"id":17636320,"file_name":"dog_0.png","project_id":795232,"asset_id":746577,"created_at":"2024-07-18T12:49:35.641+08:00","updated_at":"2024-07-18T12:49:35.641+08:00"},{"id":17636331,"file_name":"sheep_0.png","project_id":795232,"asset_id":746588,"created_at":"2024-07-18T12:49:39.975+08:00","updated_at":"2024-07-18T12:49:39.975+08:00"},{"id":17636332,"file_name":"sheep_1.png","project_id":795232,"asset_id":746589,"created_at":"2024-07-18T12:49:39.977+08:00","updated_at":"2024-07-18T12:49:39.977+08:00"},{"id":17638218,"file_name":"duck.mp3","project_id":795232,"asset_id":756809,"created_at":"2024-07-18T17:01:19.671+08:00","updated_at":"2024-07-18T17:01:19.671+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦