{"id":711464,"student_id":10,"content":"from game import *\nfrom random import randint\n\nset_backdrop('bg.png')\n\ncover = create_sprite(\"cover.png\")\na = create_sprite(\"a.png\")\nb = create_sprite(\"b.png\")\nc = create_sprite(\"c.png\")\nd = create_sprite(\"d.png\")\ninfo = create_sprite(\"info.png\", \"end.png\")\n\na.move_to(400, 250)\nb.move_to(600, 450)\nc.move_to(400, 650)\nd.move_to(200, 450)\n\nstatus = 0 # 0:遊戲說明、1:開場前奏、2:示範、3:玩家演奏、4:遊戲結束\nclock = -60 # 紀錄遊戲迴圈次數\ncount = 0 # 紀錄玩家演奏到第幾個音符\nanswers = [] #樂譜\ncountdown = 0\n\ndef start_game():\n global answers, status\n answers = [0, -1, 3, 0, 3, -1, 0, -1, 1, -1, 2, 2]\n status = 1\n info.hidden = True\n\ndef loop():\n global clock, count, status, countdown\n clock += 1\n countdown -= 1\n \n speed = 20 if status == 1 else 40\n \n if clock \u003e 0 and clock % speed == 0 and (status == 1 or status == 2):\n if answers[count] == 0: playA()\n if answers[count] == 1: playB()\n if answers[count] == 2: playC()\n if answers[count] == 3: playD()\n count += 1\n if count == len(answers):\n if status == 1:\n answers.clear()\n next_level()\n else:\n count = 0\n status = 3\n countdown = 60\n \n for i in [a, b, c, d]:\n if i.scale \u003e 1: i.scale -= 0.02\n \n cover.opacity = 0.5 if countdown \u003e 0 else 0\n \n draw_text(len(answers), 10, 10, 'white', 30)\n\ndef next_level():\n global count, status, clock\n answers.append(randint(0, 3))\n count = 0\n status = 2\n clock = -60\n\ndef playA():\n a.scale = 1.3\n create_sound(\"mouse.mp3\")\n\ndef playB():\n b.scale = 1.3\n create_sound(\"keyboard.mp3\")\n\ndef playC():\n c.scale = 1.3\n create_sound(\"cough.mp3\")\n\ndef playD():\n d.scale = 1.3\n create_sound(\"phone.mp3\")\n\ndef clickA():\n onClick(0, playA)\n\ndef clickB():\n onClick(1, playB)\n\ndef clickC():\n onClick(2, playC)\n\ndef clickD():\n onClick(3, playD)\n\ndef onClick(number, playFunc):\n global count\n if answers[count] == number:\n playFunc()\n count += 1\n if count == len(answers):\n next_level()\n else:\n gameover()\n\ndef gameover():\n status = 4\n info.hidden = False\n info.costume_id = 1\n\ninfo.on('click', start_game)\na.on('click', clickA)\nb.on('click', clickB)\nc.on('click', clickC)\nd.on('click', clickD)\nforever(loop)\n\n","created_at":"2024-03-11T10:51:02.778+08:00","updated_at":"2024-06-04T15:02:33.796+08:00","name":"音樂記憶遊戲","language":"python","screenshot":{"url":"https://cdn7.koding.school/uploads/project/screenshot/711464/fa77847221d1b084162a940ab7b67b17.jpg"},"parent_id":4,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":56,"hashid":"kdms8e5gw","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":15913159,"file_name":"d.mp3","project_id":711464,"asset_id":726110,"created_at":"2024-03-11T11:12:36.920+08:00","updated_at":"2024-03-11T11:12:36.920+08:00"},{"id":15913160,"file_name":"c.mp3","project_id":711464,"asset_id":726111,"created_at":"2024-03-11T11:12:36.922+08:00","updated_at":"2024-03-11T11:12:36.922+08:00"},{"id":15913157,"file_name":"b.mp3","project_id":711464,"asset_id":726108,"created_at":"2024-03-11T11:12:36.747+08:00","updated_at":"2024-03-11T11:12:36.747+08:00"},{"id":15913158,"file_name":"a.mp3","project_id":711464,"asset_id":726109,"created_at":"2024-03-11T11:12:36.749+08:00","updated_at":"2024-03-11T11:12:36.749+08:00"},{"id":15913163,"file_name":"cover.png","project_id":711464,"asset_id":726114,"created_at":"2024-03-11T14:02:43.593+08:00","updated_at":"2024-03-11T14:02:43.593+08:00"},{"id":16031227,"file_name":"mouse.mp3","project_id":711464,"asset_id":729095,"created_at":"2024-03-22T12:03:15.781+08:00","updated_at":"2024-03-22T12:03:15.781+08:00"},{"id":16031220,"file_name":"bg.png","project_id":711464,"asset_id":729088,"created_at":"2024-03-22T11:40:14.648+08:00","updated_at":"2024-03-22T11:40:14.648+08:00"},{"id":16031230,"file_name":"phone.mp3","project_id":711464,"asset_id":729098,"created_at":"2024-03-22T12:11:16.859+08:00","updated_at":"2024-03-22T12:11:16.859+08:00"},{"id":16031221,"file_name":"d.png","project_id":711464,"asset_id":729089,"created_at":"2024-03-22T11:48:27.574+08:00","updated_at":"2024-03-22T11:48:27.574+08:00"},{"id":16031222,"file_name":"c.png","project_id":711464,"asset_id":729090,"created_at":"2024-03-22T11:48:27.577+08:00","updated_at":"2024-03-22T11:48:27.577+08:00"},{"id":16031225,"file_name":"cough.mp3","project_id":711464,"asset_id":729093,"created_at":"2024-03-22T12:03:15.249+08:00","updated_at":"2024-03-22T12:03:15.249+08:00"},{"id":16031226,"file_name":"keyboard.mp3","project_id":711464,"asset_id":729094,"created_at":"2024-03-22T12:03:15.251+08:00","updated_at":"2024-03-22T12:03:15.251+08:00"},{"id":16031223,"file_name":"b.png","project_id":711464,"asset_id":729091,"created_at":"2024-03-22T11:48:28.028+08:00","updated_at":"2024-03-22T11:48:28.028+08:00"},{"id":16031224,"file_name":"a.png","project_id":711464,"asset_id":729092,"created_at":"2024-03-22T11:48:28.030+08:00","updated_at":"2024-03-22T11:48:28.030+08:00"},{"id":16031218,"file_name":"end.png","project_id":711464,"asset_id":729086,"created_at":"2024-03-22T11:40:14.114+08:00","updated_at":"2024-03-22T11:40:14.114+08:00"},{"id":16031219,"file_name":"info.png","project_id":711464,"asset_id":729087,"created_at":"2024-03-22T11:40:14.116+08:00","updated_at":"2024-03-22T11:40:14.116+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦