{"id":805916,"student_id":10,"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-07-29T18:15:29.435+08:00","updated_at":"2024-10-29T18:14:11.492+08:00","name":"叩叮入浴_完整版","language":"python","screenshot":{"url":"https://cdn4.koding.school/uploads/project/screenshot/805916/38c6aa03d2fae001c24bf7b60ba51314.jpg"},"parent_id":4,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":36,"hashid":"6rpsrq8ym","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":18065239,"file_name":"split_2.png","project_id":805916,"asset_id":766795,"created_at":"2024-08-16T15:18:01.520+08:00","updated_at":"2024-08-16T15:18:01.520+08:00"},{"id":18065193,"file_name":"m_5.png","project_id":805916,"asset_id":766754,"created_at":"2024-08-16T15:10:03.229+08:00","updated_at":"2024-08-16T15:10:03.229+08:00"},{"id":18065194,"file_name":"m.png","project_id":805916,"asset_id":766755,"created_at":"2024-08-16T15:10:03.233+08:00","updated_at":"2024-08-16T15:10:03.233+08:00"},{"id":18065195,"file_name":"p_0.png","project_id":805916,"asset_id":766756,"created_at":"2024-08-16T15:10:03.237+08:00","updated_at":"2024-08-16T15:10:03.237+08:00"},{"id":18065196,"file_name":"p_1.png","project_id":805916,"asset_id":766757,"created_at":"2024-08-16T15:10:03.241+08:00","updated_at":"2024-08-16T15:10:03.241+08:00"},{"id":18065198,"file_name":"6.png","project_id":805916,"asset_id":766759,"created_at":"2024-08-16T15:10:03.248+08:00","updated_at":"2024-08-16T15:10:03.248+08:00"},{"id":18065199,"file_name":"7.png","project_id":805916,"asset_id":766760,"created_at":"2024-08-16T15:10:03.252+08:00","updated_at":"2024-08-16T15:10:03.252+08:00"},{"id":18065200,"file_name":"8.png","project_id":805916,"asset_id":766761,"created_at":"2024-08-16T15:10:03.256+08:00","updated_at":"2024-08-16T15:10:03.256+08:00"},{"id":18065201,"file_name":"9.png","project_id":805916,"asset_id":766762,"created_at":"2024-08-16T15:10:03.260+08:00","updated_at":"2024-08-16T15:10:03.260+08:00"},{"id":18065202,"file_name":"m_1.png","project_id":805916,"asset_id":766763,"created_at":"2024-08-16T15:10:03.264+08:00","updated_at":"2024-08-16T15:10:03.264+08:00"},{"id":18065203,"file_name":"m_2.png","project_id":805916,"asset_id":766764,"created_at":"2024-08-16T15:10:03.268+08:00","updated_at":"2024-08-16T15:10:03.268+08:00"},{"id":18065206,"file_name":"0.png","project_id":805916,"asset_id":766767,"created_at":"2024-08-16T15:10:03.281+08:00","updated_at":"2024-08-16T15:10:03.281+08:00"},{"id":18065207,"file_name":"1.png","project_id":805916,"asset_id":766768,"created_at":"2024-08-16T15:10:03.285+08:00","updated_at":"2024-08-16T15:10:03.285+08:00"},{"id":18065208,"file_name":"m_3.png","project_id":805916,"asset_id":766769,"created_at":"2024-08-16T15:10:03.289+08:00","updated_at":"2024-08-16T15:10:03.289+08:00"},{"id":18065209,"file_name":"m_4.png","project_id":805916,"asset_id":766770,"created_at":"2024-08-16T15:10:03.293+08:00","updated_at":"2024-08-16T15:10:03.293+08:00"},{"id":18065210,"file_name":"2.png","project_id":805916,"asset_id":766771,"created_at":"2024-08-16T15:10:03.297+08:00","updated_at":"2024-08-16T15:10:03.297+08:00"},{"id":18065211,"file_name":"3.png","project_id":805916,"asset_id":766772,"created_at":"2024-08-16T15:10:03.301+08:00","updated_at":"2024-08-16T15:10:03.301+08:00"},{"id":18065212,"file_name":"p_2.png","project_id":805916,"asset_id":766773,"created_at":"2024-08-16T15:10:03.305+08:00","updated_at":"2024-08-16T15:10:03.305+08:00"},{"id":18065213,"file_name":"p_3.png","project_id":805916,"asset_id":766774,"created_at":"2024-08-16T15:10:03.310+08:00","updated_at":"2024-08-16T15:10:03.310+08:00"},{"id":18065214,"file_name":"p_4.png","project_id":805916,"asset_id":766775,"created_at":"2024-08-16T15:10:03.314+08:00","updated_at":"2024-08-16T15:10:03.314+08:00"},{"id":18065215,"file_name":"reset_btn.png","project_id":805916,"asset_id":766776,"created_at":"2024-08-16T15:10:03.318+08:00","updated_at":"2024-08-16T15:10:03.318+08:00"},{"id":18065216,"file_name":"bg_0.png","project_id":805916,"asset_id":766777,"created_at":"2024-08-16T15:10:03.342+08:00","updated_at":"2024-08-16T15:10:03.342+08:00"},{"id":18065217,"file_name":"4.png","project_id":805916,"asset_id":766778,"created_at":"2024-08-16T15:10:03.346+08:00","updated_at":"2024-08-16T15:10:03.346+08:00"},{"id":18065218,"file_name":"5.png","project_id":805916,"asset_id":766779,"created_at":"2024-08-16T15:10:03.350+08:00","updated_at":"2024-08-16T15:10:03.350+08:00"},{"id":18065219,"file_name":"bg_1.png","project_id":805916,"asset_id":766780,"created_at":"2024-08-16T15:10:03.354+08:00","updated_at":"2024-08-16T15:10:03.354+08:00"},{"id":18065220,"file_name":"ground.png","project_id":805916,"asset_id":766781,"created_at":"2024-08-16T15:10:03.360+08:00","updated_at":"2024-08-16T15:10:03.360+08:00"},{"id":18065221,"file_name":"m_0.png","project_id":805916,"asset_id":766782,"created_at":"2024-08-16T15:10:03.364+08:00","updated_at":"2024-08-16T15:10:03.364+08:00"},{"id":18065236,"file_name":"split_1.png","project_id":805916,"asset_id":760248,"created_at":"2024-08-16T15:15:23.876+08:00","updated_at":"2024-08-16T15:15:23.876+08:00"},{"id":18065237,"file_name":"split_0.png","project_id":805916,"asset_id":760247,"created_at":"2024-08-16T15:15:24.028+08:00","updated_at":"2024-08-16T15:15:24.028+08:00"},{"id":18065233,"file_name":"rules.png","project_id":805916,"asset_id":766792,"created_at":"2024-08-16T15:12:52.462+08:00","updated_at":"2024-08-16T15:12:52.462+08:00"},{"id":18065234,"file_name":"shadow.png","project_id":805916,"asset_id":766793,"created_at":"2024-08-16T15:13:57.888+08:00","updated_at":"2024-08-16T15:13:57.888+08:00"},{"id":19116342,"file_name":"bgm.mp3","project_id":805916,"asset_id":769391,"created_at":"2024-10-29T18:13:06.545+08:00","updated_at":"2024-10-29T18:13:06.545+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦