{"id":857578,"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 \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) #不斷執行遊戲迴圈\nbtn.on('click', reset) #點擊按鈕重新開始\nreset() #重置遊戲\n","created_at":"2024-10-07T12:07:29.264+08:00","updated_at":"2024-11-19T18:45:26.744+08:00","name":"叩叮入浴_完整版","language":"python","screenshot":{"url":"https://cdn8.koding.school/uploads/project/screenshot/857578/129a000133912413278e15e72f6c36b7.jpg"},"parent_id":4,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":3,"hashid":"gk4s8wr9k","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":19116343,"file_name":"split_2.png","project_id":857578,"asset_id":788075,"created_at":"2024-10-29T18:19:04.709+08:00","updated_at":"2024-10-29T18:19:04.709+08:00"},{"id":19116344,"file_name":"m_5.png","project_id":857578,"asset_id":788076,"created_at":"2024-10-29T18:19:04.714+08:00","updated_at":"2024-10-29T18:19:04.714+08:00"},{"id":19116345,"file_name":"m.png","project_id":857578,"asset_id":788077,"created_at":"2024-10-29T18:19:04.718+08:00","updated_at":"2024-10-29T18:19:04.718+08:00"},{"id":19116346,"file_name":"p_0.png","project_id":857578,"asset_id":788078,"created_at":"2024-10-29T18:19:04.722+08:00","updated_at":"2024-10-29T18:19:04.722+08:00"},{"id":19116347,"file_name":"p_1.png","project_id":857578,"asset_id":788079,"created_at":"2024-10-29T18:19:04.727+08:00","updated_at":"2024-10-29T18:19:04.727+08:00"},{"id":19116348,"file_name":"6.png","project_id":857578,"asset_id":788080,"created_at":"2024-10-29T18:19:04.731+08:00","updated_at":"2024-10-29T18:19:04.731+08:00"},{"id":19116349,"file_name":"7.png","project_id":857578,"asset_id":788081,"created_at":"2024-10-29T18:19:04.736+08:00","updated_at":"2024-10-29T18:19:04.736+08:00"},{"id":19116350,"file_name":"8.png","project_id":857578,"asset_id":788082,"created_at":"2024-10-29T18:19:04.740+08:00","updated_at":"2024-10-29T18:19:04.740+08:00"},{"id":19116351,"file_name":"9.png","project_id":857578,"asset_id":788083,"created_at":"2024-10-29T18:19:04.746+08:00","updated_at":"2024-10-29T18:19:04.746+08:00"},{"id":19116352,"file_name":"m_1.png","project_id":857578,"asset_id":788084,"created_at":"2024-10-29T18:19:04.751+08:00","updated_at":"2024-10-29T18:19:04.751+08:00"},{"id":19116353,"file_name":"m_2.png","project_id":857578,"asset_id":788085,"created_at":"2024-10-29T18:19:04.755+08:00","updated_at":"2024-10-29T18:19:04.755+08:00"},{"id":19116354,"file_name":"0.png","project_id":857578,"asset_id":788086,"created_at":"2024-10-29T18:19:04.759+08:00","updated_at":"2024-10-29T18:19:04.759+08:00"},{"id":19116355,"file_name":"1.png","project_id":857578,"asset_id":788087,"created_at":"2024-10-29T18:19:04.763+08:00","updated_at":"2024-10-29T18:19:04.763+08:00"},{"id":19116356,"file_name":"m_3.png","project_id":857578,"asset_id":788088,"created_at":"2024-10-29T18:19:04.767+08:00","updated_at":"2024-10-29T18:19:04.767+08:00"},{"id":19116357,"file_name":"m_4.png","project_id":857578,"asset_id":788089,"created_at":"2024-10-29T18:19:04.830+08:00","updated_at":"2024-10-29T18:19:04.830+08:00"},{"id":19116358,"file_name":"2.png","project_id":857578,"asset_id":788090,"created_at":"2024-10-29T18:19:04.836+08:00","updated_at":"2024-10-29T18:19:04.836+08:00"},{"id":19116359,"file_name":"3.png","project_id":857578,"asset_id":788091,"created_at":"2024-10-29T18:19:04.840+08:00","updated_at":"2024-10-29T18:19:04.840+08:00"},{"id":19116360,"file_name":"p_2.png","project_id":857578,"asset_id":788092,"created_at":"2024-10-29T18:19:04.845+08:00","updated_at":"2024-10-29T18:19:04.845+08:00"},{"id":19116361,"file_name":"p_3.png","project_id":857578,"asset_id":788093,"created_at":"2024-10-29T18:19:04.849+08:00","updated_at":"2024-10-29T18:19:04.849+08:00"},{"id":19116362,"file_name":"p_4.png","project_id":857578,"asset_id":788094,"created_at":"2024-10-29T18:19:04.853+08:00","updated_at":"2024-10-29T18:19:04.853+08:00"},{"id":19116363,"file_name":"reset_btn.png","project_id":857578,"asset_id":788095,"created_at":"2024-10-29T18:19:04.857+08:00","updated_at":"2024-10-29T18:19:04.857+08:00"},{"id":19116364,"file_name":"bg_0.png","project_id":857578,"asset_id":788096,"created_at":"2024-10-29T18:19:04.866+08:00","updated_at":"2024-10-29T18:19:04.866+08:00"},{"id":19116365,"file_name":"4.png","project_id":857578,"asset_id":788097,"created_at":"2024-10-29T18:19:04.870+08:00","updated_at":"2024-10-29T18:19:04.870+08:00"},{"id":19116366,"file_name":"5.png","project_id":857578,"asset_id":788098,"created_at":"2024-10-29T18:19:04.893+08:00","updated_at":"2024-10-29T18:19:04.893+08:00"},{"id":19116367,"file_name":"bg_1.png","project_id":857578,"asset_id":788099,"created_at":"2024-10-29T18:19:04.898+08:00","updated_at":"2024-10-29T18:19:04.898+08:00"},{"id":19116368,"file_name":"ground.png","project_id":857578,"asset_id":788100,"created_at":"2024-10-29T18:19:04.904+08:00","updated_at":"2024-10-29T18:19:04.904+08:00"},{"id":19116369,"file_name":"m_0.png","project_id":857578,"asset_id":788101,"created_at":"2024-10-29T18:19:04.908+08:00","updated_at":"2024-10-29T18:19:04.908+08:00"},{"id":19116370,"file_name":"split_1.png","project_id":857578,"asset_id":788102,"created_at":"2024-10-29T18:19:04.912+08:00","updated_at":"2024-10-29T18:19:04.912+08:00"},{"id":19116371,"file_name":"split_0.png","project_id":857578,"asset_id":788103,"created_at":"2024-10-29T18:19:04.916+08:00","updated_at":"2024-10-29T18:19:04.916+08:00"},{"id":19116372,"file_name":"rules.png","project_id":857578,"asset_id":788104,"created_at":"2024-10-29T18:19:04.922+08:00","updated_at":"2024-10-29T18:19:04.922+08:00"},{"id":19116373,"file_name":"shadow.png","project_id":857578,"asset_id":788105,"created_at":"2024-10-29T18:19:04.926+08:00","updated_at":"2024-10-29T18:19:04.926+08:00"},{"id":19116374,"file_name":"bgm.mp3","project_id":857578,"asset_id":788106,"created_at":"2024-10-29T18:19:05.024+08:00","updated_at":"2024-10-29T18:19:05.024+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦