{"id":863577,"student_id":1981,"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 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 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-10-15T16:10:50.889+08:00","updated_at":"2024-10-15T17:48:58.762+08:00","name":"4_叩叮入浴_預設版 副本","language":"python","screenshot":{"url":"https://cdn8.koding.school/uploads/project/screenshot/863577/21e2da7c1d45d36a4aa071912a361edf.jpg"},"parent_id":829995,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":3,"hashid":"p93s3qe38","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":18911637,"file_name":"split_2.png","project_id":863577,"asset_id":771747,"created_at":"2024-10-15T16:10:50.895+08:00","updated_at":"2024-10-15T16:10:50.895+08:00"},{"id":18911638,"file_name":"m_5.png","project_id":863577,"asset_id":771748,"created_at":"2024-10-15T16:10:50.896+08:00","updated_at":"2024-10-15T16:10:50.896+08:00"},{"id":18911639,"file_name":"m.png","project_id":863577,"asset_id":771749,"created_at":"2024-10-15T16:10:50.897+08:00","updated_at":"2024-10-15T16:10:50.897+08:00"},{"id":18911640,"file_name":"p_0.png","project_id":863577,"asset_id":771750,"created_at":"2024-10-15T16:10:50.898+08:00","updated_at":"2024-10-15T16:10:50.898+08:00"},{"id":18911641,"file_name":"p_1.png","project_id":863577,"asset_id":771751,"created_at":"2024-10-15T16:10:50.899+08:00","updated_at":"2024-10-15T16:10:50.899+08:00"},{"id":18911642,"file_name":"6.png","project_id":863577,"asset_id":771752,"created_at":"2024-10-15T16:10:50.900+08:00","updated_at":"2024-10-15T16:10:50.900+08:00"},{"id":18911643,"file_name":"7.png","project_id":863577,"asset_id":771753,"created_at":"2024-10-15T16:10:50.901+08:00","updated_at":"2024-10-15T16:10:50.901+08:00"},{"id":18911644,"file_name":"8.png","project_id":863577,"asset_id":771754,"created_at":"2024-10-15T16:10:50.902+08:00","updated_at":"2024-10-15T16:10:50.902+08:00"},{"id":18911645,"file_name":"9.png","project_id":863577,"asset_id":771755,"created_at":"2024-10-15T16:10:50.903+08:00","updated_at":"2024-10-15T16:10:50.903+08:00"},{"id":18911646,"file_name":"m_1.png","project_id":863577,"asset_id":771756,"created_at":"2024-10-15T16:10:50.903+08:00","updated_at":"2024-10-15T16:10:50.903+08:00"},{"id":18911647,"file_name":"m_2.png","project_id":863577,"asset_id":771757,"created_at":"2024-10-15T16:10:50.904+08:00","updated_at":"2024-10-15T16:10:50.904+08:00"},{"id":18911648,"file_name":"0.png","project_id":863577,"asset_id":771758,"created_at":"2024-10-15T16:10:50.905+08:00","updated_at":"2024-10-15T16:10:50.905+08:00"},{"id":18911649,"file_name":"1.png","project_id":863577,"asset_id":771759,"created_at":"2024-10-15T16:10:50.906+08:00","updated_at":"2024-10-15T16:10:50.906+08:00"},{"id":18911650,"file_name":"m_3.png","project_id":863577,"asset_id":771760,"created_at":"2024-10-15T16:10:50.907+08:00","updated_at":"2024-10-15T16:10:50.907+08:00"},{"id":18911651,"file_name":"m_4.png","project_id":863577,"asset_id":771761,"created_at":"2024-10-15T16:10:50.908+08:00","updated_at":"2024-10-15T16:10:50.908+08:00"},{"id":18911652,"file_name":"2.png","project_id":863577,"asset_id":771762,"created_at":"2024-10-15T16:10:50.909+08:00","updated_at":"2024-10-15T16:10:50.909+08:00"},{"id":18911653,"file_name":"3.png","project_id":863577,"asset_id":771763,"created_at":"2024-10-15T16:10:50.910+08:00","updated_at":"2024-10-15T16:10:50.910+08:00"},{"id":18911654,"file_name":"p_2.png","project_id":863577,"asset_id":771764,"created_at":"2024-10-15T16:10:50.910+08:00","updated_at":"2024-10-15T16:10:50.910+08:00"},{"id":18911655,"file_name":"p_3.png","project_id":863577,"asset_id":771765,"created_at":"2024-10-15T16:10:50.911+08:00","updated_at":"2024-10-15T16:10:50.911+08:00"},{"id":18911656,"file_name":"p_4.png","project_id":863577,"asset_id":771766,"created_at":"2024-10-15T16:10:50.912+08:00","updated_at":"2024-10-15T16:10:50.912+08:00"},{"id":18911657,"file_name":"reset_btn.png","project_id":863577,"asset_id":771767,"created_at":"2024-10-15T16:10:50.913+08:00","updated_at":"2024-10-15T16:10:50.913+08:00"},{"id":18911658,"file_name":"bg_0.png","project_id":863577,"asset_id":771768,"created_at":"2024-10-15T16:10:50.914+08:00","updated_at":"2024-10-15T16:10:50.914+08:00"},{"id":18911659,"file_name":"4.png","project_id":863577,"asset_id":771769,"created_at":"2024-10-15T16:10:50.915+08:00","updated_at":"2024-10-15T16:10:50.915+08:00"},{"id":18911660,"file_name":"5.png","project_id":863577,"asset_id":771770,"created_at":"2024-10-15T16:10:50.916+08:00","updated_at":"2024-10-15T16:10:50.916+08:00"},{"id":18911661,"file_name":"bg_1.png","project_id":863577,"asset_id":771771,"created_at":"2024-10-15T16:10:50.917+08:00","updated_at":"2024-10-15T16:10:50.917+08:00"},{"id":18911662,"file_name":"ground.png","project_id":863577,"asset_id":771772,"created_at":"2024-10-15T16:10:50.917+08:00","updated_at":"2024-10-15T16:10:50.917+08:00"},{"id":18911663,"file_name":"m_0.png","project_id":863577,"asset_id":771773,"created_at":"2024-10-15T16:10:50.918+08:00","updated_at":"2024-10-15T16:10:50.918+08:00"},{"id":18911664,"file_name":"split_1.png","project_id":863577,"asset_id":771774,"created_at":"2024-10-15T16:10:50.919+08:00","updated_at":"2024-10-15T16:10:50.919+08:00"},{"id":18911665,"file_name":"split_0.png","project_id":863577,"asset_id":771775,"created_at":"2024-10-15T16:10:50.920+08:00","updated_at":"2024-10-15T16:10:50.920+08:00"},{"id":18911666,"file_name":"rules.png","project_id":863577,"asset_id":771776,"created_at":"2024-10-15T16:10:50.921+08:00","updated_at":"2024-10-15T16:10:50.921+08:00"},{"id":18911667,"file_name":"shadow.png","project_id":863577,"asset_id":771777,"created_at":"2024-10-15T16:10:50.922+08:00","updated_at":"2024-10-15T16:10:50.922+08:00"},{"id":18911668,"file_name":"bgm.mp3","project_id":863577,"asset_id":771778,"created_at":"2024-10-15T16:10:50.923+08:00","updated_at":"2024-10-15T16:10:50.923+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦