{"id":755933,"student_id":10,"content":"from game import *\nfrom random import *\n\nset_backdrop('#ccc')\na = create_sprite('a.png')\nb = create_sprite('b.png')\nc = create_sprite('c.png')\nd = create_sprite('d.png')\nrules = create_sprite('rules.png', 'result.png')\nbgm = create_sound('bgm.ogg')\nbgm.set_volume(0.3)\n\na.y -= 250\nb.x += 250\nc.y += 250\nd.x -= 250\n\nanswers = []\nstatus = 0\nclock = 0\ncount = 0\n\ndef gamestart():\n rules.hidden = True\n next_level()\n \ndef next_level():\n global status, clock, count\n clock = -60\n count = 0\n status = 1\n answers.append(randrange(4))\n\ndef loop():\n global status, clock, count\n \n clock += 1\n \n score = len(answers)\n draw_text('分數:' + str(score), 30, 30, 'black', 30)\n \n if count == score:\n status = 2\n count = 0\n \n if clock \u003e 0 and clock % 60 == 0 and status == 1:\n if answers[count] == 0: play_a()\n if answers[count] == 1: play_b()\n if answers[count] == 2: play_c()\n if answers[count] == 3: play_d()\n count += 1\n \n for s in [a, b, c, d]:\n if s.scale \u003e 1: s.scale -= 0.05\n\ndef play_a():\n create_sound('dog.wav')\n a.scale = 1.2\n\ndef play_b():\n create_sound('cat.mp3')\n b.scale = 1.2\n\ndef play_c():\n create_sound('horse.wav')\n c.scale = 1.2\n\ndef play_d():\n create_sound('duck.wav')\n d.scale = 1.2\n \ndef click_a():\n on_click(0, play_a)\n\ndef click_b():\n on_click(1, play_b)\n\ndef click_c():\n on_click(2, play_c)\n\ndef click_d():\n on_click(3, play_d)\n \ndef on_click(idx, func):\n global count\n if status == 2:\n if answers[count] == idx:\n func()\n count += 1\n if count \u003e= len(answers):\n next_level()\n else:\n gameover()\n\ndef gameover():\n global status\n stop()\n status = 4\n # rules.costume_id = 1\n # rules.hidden = False\n create_sprite('result.png')\n create_sound('wrong.mp3')\n for y in range(3):\n for x in range(12):\n n = create_sprite('note.png')\n n.scale = 0.6\n n.x = 200 + 70 * x\n n.y = 300 + 100 * y\n idx = y * 12 + x\n if idx \u003c count: n.opacity = 1\n else: n.opacity = 0.2\n\na.on('click', click_a)\nb.on('click', click_b)\nc.on('click', click_c)\nd.on('click', click_d)\nrules.on('click', gamestart)\nforever(loop)\nnext_level()\n ","created_at":"2024-05-24T10:54:50.738+08:00","updated_at":"2024-05-24T12:00:37.984+08:00","name":"音樂記憶遊戲","language":"python","screenshot":{"url":"https://cdn8.koding.school/uploads/project/screenshot/755933/ea7f74b28aaef473165bc28b55e23e66.jpg"},"parent_id":4,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":136,"hashid":"4y3sknqzv","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":16877416,"file_name":"goose.wav","project_id":755933,"asset_id":62776,"created_at":"2024-05-24T10:56:09.280+08:00","updated_at":"2024-05-24T10:56:09.280+08:00"},{"id":16877417,"file_name":"horse.wav","project_id":755933,"asset_id":230326,"created_at":"2024-05-24T10:56:09.282+08:00","updated_at":"2024-05-24T10:56:09.282+08:00"},{"id":16877432,"file_name":"result.png","project_id":755933,"asset_id":743398,"created_at":"2024-05-24T11:48:13.697+08:00","updated_at":"2024-05-24T11:48:13.697+08:00"},{"id":16877421,"file_name":"d.png","project_id":755933,"asset_id":743392,"created_at":"2024-05-24T11:02:34.816+08:00","updated_at":"2024-05-24T11:02:34.816+08:00"},{"id":16877422,"file_name":"c.png","project_id":755933,"asset_id":743393,"created_at":"2024-05-24T11:02:34.818+08:00","updated_at":"2024-05-24T11:02:34.818+08:00"},{"id":16877433,"file_name":"note.png","project_id":755933,"asset_id":743399,"created_at":"2024-05-24T11:50:02.833+08:00","updated_at":"2024-05-24T11:50:02.833+08:00"},{"id":16877431,"file_name":"rules.png","project_id":755933,"asset_id":743397,"created_at":"2024-05-24T11:42:36.841+08:00","updated_at":"2024-05-24T11:42:36.841+08:00"},{"id":16877420,"file_name":"cat.mp3","project_id":755933,"asset_id":743391,"created_at":"2024-05-24T10:56:22.364+08:00","updated_at":"2024-05-24T10:56:22.364+08:00"},{"id":16877418,"file_name":"duck.wav","project_id":755933,"asset_id":231019,"created_at":"2024-05-24T10:56:09.714+08:00","updated_at":"2024-05-24T10:56:09.714+08:00"},{"id":16877419,"file_name":"dog.wav","project_id":755933,"asset_id":230814,"created_at":"2024-05-24T10:56:09.717+08:00","updated_at":"2024-05-24T10:56:09.717+08:00"},{"id":16877423,"file_name":"b.png","project_id":755933,"asset_id":743394,"created_at":"2024-05-24T11:02:36.056+08:00","updated_at":"2024-05-24T11:02:36.056+08:00"},{"id":16877424,"file_name":"a.png","project_id":755933,"asset_id":743395,"created_at":"2024-05-24T11:02:36.058+08:00","updated_at":"2024-05-24T11:02:36.058+08:00"},{"id":16877429,"file_name":"wrong.mp3","project_id":755933,"asset_id":723475,"created_at":"2024-05-24T11:29:03.548+08:00","updated_at":"2024-05-24T11:29:03.548+08:00"},{"id":16877430,"file_name":"bgm.ogg","project_id":755933,"asset_id":743396,"created_at":"2024-05-24T11:37:24.416+08:00","updated_at":"2024-05-24T11:37:24.416+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦