{"id":842960,"student_id":2589,"content":"from game import *\nfrom random import *\n\nnums = [str(i) + '.png' for i in range(10)]\nimgs = ['m_0.png', 'm_1.png', 'm_2.png', 'm_3.png', 'm_4.png', 'm_5.png']\ngd = create_sprite('ground.png') #助跑地板\nbg0 = create_sprite('bg_0.png') #底層背景\nm1 = create_sprite(imgs) #猴子1\nm2 = create_sprite(imgs) #猴子2\nplayer = create_sprite('p_0.png', 'p_1.png', 'p_2.png', 'p_3.png', 'p_4.png') #叩叮\nbg1 = create_sprite('bg_1.png') #上層背景\nsplit = create_sprite('split_0.png', 'split_1.png', 'split_2.png')\nm3 = create_sprite(imgs) #猴子3\nn1 = create_sprite(nums) #百位數\nn2 = create_sprite(nums) #個位數\nn3 = create_sprite(nums) #十位數\nunit = create_sprite('m.png') #公尺單位\nrules = create_sprite('rules.png') #遊戲說明\nbtn = create_sprite('reset_btn.png') #重新開始提示按鈕\nshadow = create_sprite('shadow.png') #影子\ncreate_sound('bgm.mp3', True) #背景音樂\n\nn1.move_to(60, 80)\nn2.move_to(120, 80)\nn3.move_to(180, 80)\nunit.move_to(240, 80)\nshadow.y = 750\nsplit.y = 750\n\n# rules.hidden = True #隱藏遊戲說明\n# btn.hidden = True #隱藏重新按鈕\n\nvx = 0 #水平移動速度\nvy = 0 #垂直移動速度\nstatus = 0 #遊戲狀態\n\n#重新開始\ndef reset():\n global vx, vy, status\n status = 0\n vx = 0\n vy = 0\n player.y = 750\n player.costume_id = 0\n gd.x = 0\n bg0.x = -3600\n bg1.x = -3600\n split.hidden = True\n m1.move_to(-2400, 580)\n m2.move_to(-3400, 580)\n m3.move_to(-4400, 780)\n m1.costume_id = randrange(6)\n m2.costume_id = randrange(6)\n m3.costume_id = randrange(6)\n\n#遊戲迴圈\ndef loop():\n update_player() #更新叩叮\n update_scores() #更新分數\n if status == 1 or status == 2: #如果狀態是助跑或跳躍\n update_bg() #更新背景\n update_monkey(m1) #更新猴子1\n update_monkey(m2) #更新猴子2\n update_monkey(m3) #更新猴子3\n animate() #播放動畫\n btn.hidden = status != 5\n if status \u003e= 4: split.costume_id = 2\n btn.hidden = status != 5\n \n#更新叩叮\ndef update_player():\n global status, vx, vy\n if status == 1:\n vx += 0.1\n if status == 2:\n vy += 0.2\n player.y += vy\n if status == 3:\n player.y += 1\n player.costume_id = 2\n if status == 4:\n player.y -= 5\n player.costume_id = 3\n\n#更新背景\ndef update_bg():\n bg0.x += vx\n bg1.x += vx\n gd.x += vx\n if bg0.x \u003e 1200:\n bg0.x -= 2400\n bg1.x -= 2400\n\n#更新猴子\ndef update_monkey(m):\n m.x += vx\n if m.x \u003e 1400:\n m.x -= 3000\n m.costume_id = randrange(6)\n\n#角色動畫\ndef animate():\n player.costume_id = (gd.x // 50) % 2\n split.costume_id = (gd.x // 50) % 2\n split.hidden = player.y \u003c 650 or gd.x \u003c 1800\n shadow.hidden = not split.hidden\n \n#空白鍵按下執行此程式\ndef keydown():\n global status, vy\n if status == 0:\n status = 1\n rules.hidden = True\n elif status == 1:\n status = 2\n vy = -10 #向上跳躍\n elif status == 2:\n jump()\n elif status == 5:\n status = 0\n reset()\n\n#空白鍵跳躍\ndef jump():\n global vx, vy\n #根據觸水線的距離計算彈跳的衰弱程度\n scale = (100 - abs(player.y - 750)) / 100\n if scale \u003e 0: \n vx *= scale #衰弱水平速度\n vy *= scale * -1 #衰弱垂直速度並反轉\n else:\n vx = 0\n \n#更新分數造型\ndef update_scores():\n dist = (gd.x - 1800) // 100\n if dist \u003c 0: dist = 0\n n1.costume_id = (dist // 100) % 10\n n2.costume_id = (dist // 10) % 10\n n3.costume_id = (dist // 1) % 10\n\non('keydown', 'space', keydown) #當空白鍵按下執行 keydown 函式\nforever(loop) #不斷執行遊戲迴圈\nreset() #重置遊戲\n","created_at":"2024-09-20T22:55:18.322+08:00","updated_at":"2024-09-20T23:03:43.559+08:00","name":"4_叩叮入浴_預設版","language":"python","screenshot":{"url":null},"parent_id":4,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":15,"hashid":"5j3s85n6g","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":18512009,"file_name":"bgm.mp3","project_id":842960,"asset_id":777148,"created_at":"2024-09-20T22:56:06.914+08:00","updated_at":"2024-09-20T22:56:06.914+08:00"},{"id":18511978,"file_name":"split_2.png","project_id":842960,"asset_id":777117,"created_at":"2024-09-20T22:56:06.690+08:00","updated_at":"2024-09-20T22:56:06.690+08:00"},{"id":18511979,"file_name":"m_5.png","project_id":842960,"asset_id":777118,"created_at":"2024-09-20T22:56:06.694+08:00","updated_at":"2024-09-20T22:56:06.694+08:00"},{"id":18511980,"file_name":"m.png","project_id":842960,"asset_id":777119,"created_at":"2024-09-20T22:56:06.698+08:00","updated_at":"2024-09-20T22:56:06.698+08:00"},{"id":18511981,"file_name":"p_0.png","project_id":842960,"asset_id":777120,"created_at":"2024-09-20T22:56:06.702+08:00","updated_at":"2024-09-20T22:56:06.702+08:00"},{"id":18511982,"file_name":"p_1.png","project_id":842960,"asset_id":777121,"created_at":"2024-09-20T22:56:06.706+08:00","updated_at":"2024-09-20T22:56:06.706+08:00"},{"id":18511983,"file_name":"6.png","project_id":842960,"asset_id":777122,"created_at":"2024-09-20T22:56:06.710+08:00","updated_at":"2024-09-20T22:56:06.710+08:00"},{"id":18511984,"file_name":"7.png","project_id":842960,"asset_id":777123,"created_at":"2024-09-20T22:56:06.713+08:00","updated_at":"2024-09-20T22:56:06.713+08:00"},{"id":18511985,"file_name":"8.png","project_id":842960,"asset_id":777124,"created_at":"2024-09-20T22:56:06.717+08:00","updated_at":"2024-09-20T22:56:06.717+08:00"},{"id":18511986,"file_name":"9.png","project_id":842960,"asset_id":777125,"created_at":"2024-09-20T22:56:06.720+08:00","updated_at":"2024-09-20T22:56:06.720+08:00"},{"id":18511987,"file_name":"m_1.png","project_id":842960,"asset_id":777126,"created_at":"2024-09-20T22:56:06.724+08:00","updated_at":"2024-09-20T22:56:06.724+08:00"},{"id":18511988,"file_name":"m_2.png","project_id":842960,"asset_id":777127,"created_at":"2024-09-20T22:56:06.728+08:00","updated_at":"2024-09-20T22:56:06.728+08:00"},{"id":18511989,"file_name":"0.png","project_id":842960,"asset_id":777128,"created_at":"2024-09-20T22:56:06.732+08:00","updated_at":"2024-09-20T22:56:06.732+08:00"},{"id":18511990,"file_name":"1.png","project_id":842960,"asset_id":777129,"created_at":"2024-09-20T22:56:06.736+08:00","updated_at":"2024-09-20T22:56:06.736+08:00"},{"id":18511991,"file_name":"m_3.png","project_id":842960,"asset_id":777130,"created_at":"2024-09-20T22:56:06.784+08:00","updated_at":"2024-09-20T22:56:06.784+08:00"},{"id":18511992,"file_name":"m_4.png","project_id":842960,"asset_id":777131,"created_at":"2024-09-20T22:56:06.789+08:00","updated_at":"2024-09-20T22:56:06.789+08:00"},{"id":18511993,"file_name":"2.png","project_id":842960,"asset_id":777132,"created_at":"2024-09-20T22:56:06.793+08:00","updated_at":"2024-09-20T22:56:06.793+08:00"},{"id":18511994,"file_name":"3.png","project_id":842960,"asset_id":777133,"created_at":"2024-09-20T22:56:06.796+08:00","updated_at":"2024-09-20T22:56:06.796+08:00"},{"id":18511995,"file_name":"p_2.png","project_id":842960,"asset_id":777134,"created_at":"2024-09-20T22:56:06.800+08:00","updated_at":"2024-09-20T22:56:06.800+08:00"},{"id":18511996,"file_name":"p_3.png","project_id":842960,"asset_id":777135,"created_at":"2024-09-20T22:56:06.804+08:00","updated_at":"2024-09-20T22:56:06.804+08:00"},{"id":18511997,"file_name":"p_4.png","project_id":842960,"asset_id":777136,"created_at":"2024-09-20T22:56:06.808+08:00","updated_at":"2024-09-20T22:56:06.808+08:00"},{"id":18511998,"file_name":"reset_btn.png","project_id":842960,"asset_id":777137,"created_at":"2024-09-20T22:56:06.812+08:00","updated_at":"2024-09-20T22:56:06.812+08:00"},{"id":18511999,"file_name":"bg_0.png","project_id":842960,"asset_id":777138,"created_at":"2024-09-20T22:56:06.819+08:00","updated_at":"2024-09-20T22:56:06.819+08:00"},{"id":18512000,"file_name":"4.png","project_id":842960,"asset_id":777139,"created_at":"2024-09-20T22:56:06.842+08:00","updated_at":"2024-09-20T22:56:06.842+08:00"},{"id":18512001,"file_name":"5.png","project_id":842960,"asset_id":777140,"created_at":"2024-09-20T22:56:06.847+08:00","updated_at":"2024-09-20T22:56:06.847+08:00"},{"id":18512002,"file_name":"bg_1.png","project_id":842960,"asset_id":777141,"created_at":"2024-09-20T22:56:06.851+08:00","updated_at":"2024-09-20T22:56:06.851+08:00"},{"id":18512003,"file_name":"ground.png","project_id":842960,"asset_id":777142,"created_at":"2024-09-20T22:56:06.857+08:00","updated_at":"2024-09-20T22:56:06.857+08:00"},{"id":18512004,"file_name":"m_0.png","project_id":842960,"asset_id":777143,"created_at":"2024-09-20T22:56:06.861+08:00","updated_at":"2024-09-20T22:56:06.861+08:00"},{"id":18512005,"file_name":"split_1.png","project_id":842960,"asset_id":777144,"created_at":"2024-09-20T22:56:06.865+08:00","updated_at":"2024-09-20T22:56:06.865+08:00"},{"id":18512006,"file_name":"split_0.png","project_id":842960,"asset_id":777145,"created_at":"2024-09-20T22:56:06.869+08:00","updated_at":"2024-09-20T22:56:06.869+08:00"},{"id":18512007,"file_name":"rules.png","project_id":842960,"asset_id":777146,"created_at":"2024-09-20T22:56:06.874+08:00","updated_at":"2024-09-20T22:56:06.874+08:00"},{"id":18512008,"file_name":"shadow.png","project_id":842960,"asset_id":777147,"created_at":"2024-09-20T22:56:06.878+08:00","updated_at":"2024-09-20T22:56:06.878+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦