{"id":887797,"student_id":1444,"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 \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 gd.x \u003e 1800: status = 2\n if status == 2:\n vy += 0.2\n player.y += vy\n if player.y \u003e= 850: status = 3\n if player.y \u003e 750 and gd.x \u003c 1800:\n status = 5\n player.costume_id = 4\n\n if status == 3:\n player.y += 1\n player.costume_id = 2\n if player.y \u003e= 1000: status = 4\n if status == 4:\n player.y -= 5\n player.costume_id = 3\n if player.y \u003c 850: status = 5\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-11-16T16:06:32.371+08:00","updated_at":"2024-11-16T17:28:47.339+08:00","name":"4_叩叮入浴_預設版 副本","language":"python","screenshot":{"url":"https://cdn6.koding.school/uploads/project/screenshot/887797/94057865957e12040807fb06c3a30cd6.jpg"},"parent_id":869306,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":7,"hashid":"4y3s35nkg","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":34537536,"file_name":"split_2.png","project_id":887797,"asset_id":786066,"created_at":"2024-11-16T16:06:32.379+08:00","updated_at":"2024-11-16T16:06:32.379+08:00"},{"id":34537537,"file_name":"m_5.png","project_id":887797,"asset_id":786067,"created_at":"2024-11-16T16:06:32.380+08:00","updated_at":"2024-11-16T16:06:32.380+08:00"},{"id":34537538,"file_name":"m.png","project_id":887797,"asset_id":786068,"created_at":"2024-11-16T16:06:32.381+08:00","updated_at":"2024-11-16T16:06:32.381+08:00"},{"id":34537539,"file_name":"p_0.png","project_id":887797,"asset_id":786069,"created_at":"2024-11-16T16:06:32.382+08:00","updated_at":"2024-11-16T16:06:32.382+08:00"},{"id":34537540,"file_name":"p_1.png","project_id":887797,"asset_id":786070,"created_at":"2024-11-16T16:06:32.383+08:00","updated_at":"2024-11-16T16:06:32.383+08:00"},{"id":34537541,"file_name":"6.png","project_id":887797,"asset_id":786071,"created_at":"2024-11-16T16:06:32.384+08:00","updated_at":"2024-11-16T16:06:32.384+08:00"},{"id":34537542,"file_name":"7.png","project_id":887797,"asset_id":786072,"created_at":"2024-11-16T16:06:32.385+08:00","updated_at":"2024-11-16T16:06:32.385+08:00"},{"id":34537543,"file_name":"8.png","project_id":887797,"asset_id":786073,"created_at":"2024-11-16T16:06:32.386+08:00","updated_at":"2024-11-16T16:06:32.386+08:00"},{"id":34537544,"file_name":"9.png","project_id":887797,"asset_id":786074,"created_at":"2024-11-16T16:06:32.387+08:00","updated_at":"2024-11-16T16:06:32.387+08:00"},{"id":34537545,"file_name":"m_1.png","project_id":887797,"asset_id":786075,"created_at":"2024-11-16T16:06:32.388+08:00","updated_at":"2024-11-16T16:06:32.388+08:00"},{"id":34537546,"file_name":"m_2.png","project_id":887797,"asset_id":786076,"created_at":"2024-11-16T16:06:32.389+08:00","updated_at":"2024-11-16T16:06:32.389+08:00"},{"id":34537547,"file_name":"0.png","project_id":887797,"asset_id":786077,"created_at":"2024-11-16T16:06:32.390+08:00","updated_at":"2024-11-16T16:06:32.390+08:00"},{"id":34537548,"file_name":"1.png","project_id":887797,"asset_id":786078,"created_at":"2024-11-16T16:06:32.391+08:00","updated_at":"2024-11-16T16:06:32.391+08:00"},{"id":34537549,"file_name":"m_3.png","project_id":887797,"asset_id":786079,"created_at":"2024-11-16T16:06:32.392+08:00","updated_at":"2024-11-16T16:06:32.392+08:00"},{"id":34537550,"file_name":"m_4.png","project_id":887797,"asset_id":786080,"created_at":"2024-11-16T16:06:32.393+08:00","updated_at":"2024-11-16T16:06:32.393+08:00"},{"id":34537551,"file_name":"2.png","project_id":887797,"asset_id":786081,"created_at":"2024-11-16T16:06:32.394+08:00","updated_at":"2024-11-16T16:06:32.394+08:00"},{"id":34537552,"file_name":"3.png","project_id":887797,"asset_id":786082,"created_at":"2024-11-16T16:06:32.395+08:00","updated_at":"2024-11-16T16:06:32.395+08:00"},{"id":34537553,"file_name":"p_2.png","project_id":887797,"asset_id":786083,"created_at":"2024-11-16T16:06:32.396+08:00","updated_at":"2024-11-16T16:06:32.396+08:00"},{"id":34537554,"file_name":"p_3.png","project_id":887797,"asset_id":786084,"created_at":"2024-11-16T16:06:32.397+08:00","updated_at":"2024-11-16T16:06:32.397+08:00"},{"id":34537555,"file_name":"p_4.png","project_id":887797,"asset_id":786085,"created_at":"2024-11-16T16:06:32.398+08:00","updated_at":"2024-11-16T16:06:32.398+08:00"},{"id":34537556,"file_name":"reset_btn.png","project_id":887797,"asset_id":786086,"created_at":"2024-11-16T16:06:32.399+08:00","updated_at":"2024-11-16T16:06:32.399+08:00"},{"id":34537557,"file_name":"bg_0.png","project_id":887797,"asset_id":786087,"created_at":"2024-11-16T16:06:32.400+08:00","updated_at":"2024-11-16T16:06:32.400+08:00"},{"id":34537558,"file_name":"4.png","project_id":887797,"asset_id":786088,"created_at":"2024-11-16T16:06:32.401+08:00","updated_at":"2024-11-16T16:06:32.401+08:00"},{"id":34537559,"file_name":"5.png","project_id":887797,"asset_id":786089,"created_at":"2024-11-16T16:06:32.403+08:00","updated_at":"2024-11-16T16:06:32.403+08:00"},{"id":34537560,"file_name":"bg_1.png","project_id":887797,"asset_id":786090,"created_at":"2024-11-16T16:06:32.404+08:00","updated_at":"2024-11-16T16:06:32.404+08:00"},{"id":34537561,"file_name":"ground.png","project_id":887797,"asset_id":786091,"created_at":"2024-11-16T16:06:32.404+08:00","updated_at":"2024-11-16T16:06:32.404+08:00"},{"id":34537562,"file_name":"m_0.png","project_id":887797,"asset_id":786092,"created_at":"2024-11-16T16:06:32.405+08:00","updated_at":"2024-11-16T16:06:32.405+08:00"},{"id":34537563,"file_name":"split_1.png","project_id":887797,"asset_id":786093,"created_at":"2024-11-16T16:06:32.406+08:00","updated_at":"2024-11-16T16:06:32.406+08:00"},{"id":34537564,"file_name":"split_0.png","project_id":887797,"asset_id":786094,"created_at":"2024-11-16T16:06:32.407+08:00","updated_at":"2024-11-16T16:06:32.407+08:00"},{"id":34537565,"file_name":"rules.png","project_id":887797,"asset_id":786095,"created_at":"2024-11-16T16:06:32.408+08:00","updated_at":"2024-11-16T16:06:32.408+08:00"},{"id":34537566,"file_name":"shadow.png","project_id":887797,"asset_id":786096,"created_at":"2024-11-16T16:06:32.409+08:00","updated_at":"2024-11-16T16:06:32.409+08:00"},{"id":34537567,"file_name":"bgm.mp3","project_id":887797,"asset_id":786097,"created_at":"2024-11-16T16:06:32.410+08:00","updated_at":"2024-11-16T16:06:32.410+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦