{"id":245155,"student_id":10,"content":"setBackdrop(\"bg.jpg\") #設定背景圖\ncreateSprite(\"board.png\") #計分板角色\np1 = createSprite(\"otter_0.png\", \"otter_1.png\", \"otter_2.png\", \"otter_3.png\", \"otter_4.png\") #左邊玩家\np2 = createSprite(\"koding_0.png\", \"koding_1.png\", \"koding_2.png\", \"koding_3.png\", \"koding_4.png\") #右邊玩家\nobj = createSprite(\"twig.png\", \"shell.png\") #武器\nhint = createSprite(\"tutorial.jpg\") #開始畫面\n\np1.x = 200\np1.y = 700\np2.x = 1000\np2.y = 700\n\n#將武器移動到左邊玩家\nobj.x = p1.x\nobj.y = p1.y\nobj.hidden = true\n# hint.hidden = true\n\np1_hp = 400 #左邊玩家血量\np2_hp = 400 #右邊玩家血量\np1_power = 0 #左邊玩家蓄力\np2_power = 0 #右邊玩家蓄力\nvx = 0 #武器水平移動速度\nvy = 0 #武器垂直移動速度\nwind = 0 #風速\nstatus = 0 #遊戲狀態\n\non(\"mousedown\", mousedown) #滑鼠點下時執行 mousedown 函式\non(\"mouseup\", mouseup) #滑鼠放開時執行 mouseup 函式\n\ncreateSound('bgm.mp3')\n\ndef mousedown ():\n if (status == 1) status = 2\n if (status == 4) status = 5\n\n\ndef mouseup ():\n if status == 2:\n status = 3\n vy = -p1_power\n vx = p1_power\n obj.hidden = false\n createSound('throw.wav')\n \n if status == 5:\n status = 6\n vy = -p2_power\n vx = -p2_power\n obj.hidden = false\n createSound('throw.wav')\n \n if status == 0:\n status = 1\n hint.hidden = true\n \n\n\n#遊戲主迴圈\ndef loop ():\n\n if (status == 2): p1.costumeId = 1\n if (status == 3): p1.costumeId = 2\n if (status == 2 \u0026\u0026 p1_power \u003c 40): p1_power += 1\n \n if (status == 5): p2.costumeId = 1\n if (status == 6): p2.costumeId = 2\n if (status == 5 \u0026\u0026 p2_power \u003c 40): p2_power += 1\n\n if (status == 3 || status == 6):\n vy += 1\n obj.x += vx + wind\n obj.y += vy\n \n \n if (obj.y \u003e 1500): reset()\n\n if (status == 3 \u0026\u0026 obj.touched(p2)):\n p2.costumeId = 3\n p2_hp -= 100\n obj.hidden = true\n createSound('hit.wav')\n \n if (status == 6 \u0026\u0026 obj.touched(p1)):\n p1.costumeId = 3\n p1_hp -= 100\n obj.hidden = true\n createSound('hit.wav')\n \n\n\ndef reset ():\n p1_power = 0\n p1.costumeId = 0\n if (status == 3) {\n status = 4\n obj.x = p2.x\n obj.y = p2.y\n obj.costumeId = 1\n \n \n p2_power = 0\n p2.costumeId = 0\n if (status == 6:\n status = 1\n obj.x = p1.x\n obj.y = p1.y\n obj.costumeId = 0\n \n \n obj.hidden = true\n wind = Math.random()*20 - 10\n\n\ndef checkGameOver ():\n if (p1_hp \u003c= 0):\n drawText(\"Koding 獲勝!\", 350, 400, \"white\", 100)\n p2.costumeId = 4\n stop()\n \n if (p2_hp \u003c= 0):\n drawText(\"Otter 獲勝!\", 350, 400, \"white\", 100)\n p1.costumeId = 4\n stop()\n \n\n\ndef drawBars():\n pen.fillColor = \"red\"\n pen.drawRect(500, 40, -p1_hp, 20)\n pen.drawRect(700, 40, +p2_hp, 20)\n pen.fillColor = \"blue\"\n pen.drawRect(580 + wind * 10, 120, 40, 20)\n \n if (status == 1 || status == 2):\n pen.fillColor = \"white\"\n pen.drawRect(50, 600, 40, 200)\n pen.fillColor = \"red\"\n pen.drawRect(50, 800, 40, -p1_power * 5)\n \n if (status == 4 || status == 5):\n pen.fillColor = \"white\"\n pen.drawRect(1110, 600, 40, 200)\n pen.fillColor = \"red\"\n pen.drawRect(1110, 800, 40, -p2_power * 5)\n \n\n\n#重複不斷執行...\ndef loop ():\n loop()\n checkGameOver()\n drawBars()\n\nforever(loop)","created_at":"2021-04-21T14:46:15.599+08:00","updated_at":"2021-04-21T14:51:31.902+08:00","name":"踏踏PY版北","language":"python","screenshot":{"url":"https://cdn7.koding.school/uploads/project/screenshot/245155/d1df25b2738683732bd80fb77933492e.jpg"},"parent_id":4,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":181,"hashid":"4y3sg924g","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":4561263,"file_name":"otter_0.png","project_id":245155,"asset_id":281204,"created_at":"2021-04-21T14:47:31.867+08:00","updated_at":"2021-04-21T14:47:31.867+08:00"},{"id":4561264,"file_name":"otter_1.png","project_id":245155,"asset_id":281203,"created_at":"2021-04-21T14:47:32.376+08:00","updated_at":"2021-04-21T14:47:32.376+08:00"},{"id":4561265,"file_name":"otter_2.png","project_id":245155,"asset_id":281202,"created_at":"2021-04-21T14:47:32.378+08:00","updated_at":"2021-04-21T14:47:32.378+08:00"},{"id":4561254,"file_name":"bgm.mp3","project_id":245155,"asset_id":289603,"created_at":"2021-04-21T14:47:29.029+08:00","updated_at":"2021-04-21T14:47:29.029+08:00"},{"id":4561255,"file_name":"tutorial.jpg","project_id":245155,"asset_id":282592,"created_at":"2021-04-21T14:47:29.032+08:00","updated_at":"2021-04-21T14:47:29.032+08:00"},{"id":4561256,"file_name":"bg.jpg","project_id":245155,"asset_id":282595,"created_at":"2021-04-21T14:47:30.099+08:00","updated_at":"2021-04-21T14:47:30.099+08:00"},{"id":4561257,"file_name":"hit.wav","project_id":245155,"asset_id":268347,"created_at":"2021-04-21T14:47:30.101+08:00","updated_at":"2021-04-21T14:47:30.101+08:00"},{"id":4561258,"file_name":"throw.wav","project_id":245155,"asset_id":268345,"created_at":"2021-04-21T14:47:30.879+08:00","updated_at":"2021-04-21T14:47:30.879+08:00"},{"id":4561259,"file_name":"board.png","project_id":245155,"asset_id":289568,"created_at":"2021-04-21T14:47:30.883+08:00","updated_at":"2021-04-21T14:47:30.883+08:00"},{"id":4561260,"file_name":"pk.png","project_id":245155,"asset_id":282594,"created_at":"2021-04-21T14:47:31.363+08:00","updated_at":"2021-04-21T14:47:31.363+08:00"},{"id":4561261,"file_name":"otter_4.png","project_id":245155,"asset_id":281200,"created_at":"2021-04-21T14:47:31.370+08:00","updated_at":"2021-04-21T14:47:31.370+08:00"},{"id":4561262,"file_name":"otter_3.png","project_id":245155,"asset_id":281201,"created_at":"2021-04-21T14:47:31.861+08:00","updated_at":"2021-04-21T14:47:31.861+08:00"},{"id":4561266,"file_name":"koding_3.png","project_id":245155,"asset_id":281206,"created_at":"2021-04-21T14:47:32.873+08:00","updated_at":"2021-04-21T14:47:32.873+08:00"},{"id":4561267,"file_name":"koding_4.png","project_id":245155,"asset_id":281205,"created_at":"2021-04-21T14:47:32.875+08:00","updated_at":"2021-04-21T14:47:32.875+08:00"},{"id":4561268,"file_name":"koding_0.png","project_id":245155,"asset_id":281209,"created_at":"2021-04-21T14:47:33.363+08:00","updated_at":"2021-04-21T14:47:33.363+08:00"},{"id":4561269,"file_name":"koding_1.png","project_id":245155,"asset_id":281208,"created_at":"2021-04-21T14:47:33.365+08:00","updated_at":"2021-04-21T14:47:33.365+08:00"},{"id":4561270,"file_name":"koding_2.png","project_id":245155,"asset_id":281207,"created_at":"2021-04-21T14:47:33.896+08:00","updated_at":"2021-04-21T14:47:33.896+08:00"},{"id":4561271,"file_name":"shell.png","project_id":245155,"asset_id":282593,"created_at":"2021-04-21T14:47:33.898+08:00","updated_at":"2021-04-21T14:47:33.898+08:00"},{"id":4561272,"file_name":"twig.png","project_id":245155,"asset_id":281199,"created_at":"2021-04-21T14:47:34.434+08:00","updated_at":"2021-04-21T14:47:34.434+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦