{"id":196924,"student_id":10,"content":"from game import *\n\nset_backdrop('bg.jpg')\np1 = create_sprite('p1_0.png','p1_1.png','p1_2.png','p1_3.png')\np2 = create_sprite('p2_0.png','p2_1.png','p2_2.png','p2_3.png')\n\np1.rotation_style = 'flipped'\np2.rotation_style = 'flipped'\np1.direction = 90\np2.direction = 270\np1.move_to(300, 600)\np2.move_to(900, 600)\n\np1_life = 600\np1_power = 600\np2_life = 600\np2_power = 600\n\ndef loop ():\n global p1_power, p2_power, p1_life, p2_life\n \n pen.fillColor = 'red'\n pen.draw_rect(0, 0, p1_life, 25)\n pen.draw_rect(600, 0, p2_life, 25)\n pen.fillColor = 'blue'\n pen.draw_rect(0, 25, p1_power, 25)\n pen.draw_rect(600, 25, p2_power, 25)\n \n p2.costume_id = 0\n if key.up and p2_power \u003e 200:\n p2.costume_id = 1\n if key.down and p2_power \u003e 0:\n p2.costume_id = 2\n p2_power -= 1\n if key.right:\n p2.x += 6\n p2.direction = 90\n if key.left:\n p2.x -= 6\n p2.direction = 270\n \n p1.costume_id = 0\n if key.w and p1_power \u003e 200:\n p1.costume_id = 1\n if key.s and p1_power \u003e 0:\n p1.costume_id = 2\n p1_power -= 1\n if key.d:\n p1.x += 6\n p1.direction = 90\n if key.a:\n p1.x -= 6\n p1.direction = 270\n\n # 待命狀態可以恢復能量\n if p1.costume_id == 0 and p1_power \u003c 600:\n p1_power += 1\n if p2.costume_id == 0 and p2_power \u003c 600:\n p2_power += 1\n \n if p1_life \u003c= 0:\n p1.costume_id = 3\n stop()\n \n if p2_life \u003c= 0:\n p2.costume_id = 3\n stop()\n\ndef p1_punch ():\n global p1_power, p2_power, p1_life, p2_life\n if p1_power \u003e 100:\n p1_power -= 100 #每次攻擊消耗 200 點能量\n if p1.touched(p2):\n if p2.costume_id == 2:\n p2_power += 60\n else:\n p2_life -= 60\n\ndef p2_punch ():\n global p1_power, p2_power, p1_life, p2_life\n if p2_power \u003e 100:\n p2_power -= 100 #每次攻擊消耗 200 點能量\n if p1.touched(p2):\n if p1.costume_id == 2:\n p1_power += 60\n else:\n p1_life -= 60\n\nforever(loop) #重複不斷執行遊戲迴圈\non('keyup', 'w', p1_punch)\non('keyup', 'up', p2_punch)\n\n","created_at":"2020-10-19T13:55:56.915+08:00","updated_at":"2020-12-01T15:47:23.273+08:00","name":"運動會系列 - 拳擊競賽","language":"python","screenshot":{"url":"https://cdn2.koding.school/uploads/project/screenshot/196924/0b3775ed106669e67fc30228b9b16be8.jpg"},"parent_id":4,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":217,"hashid":"d5msvwqkg","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":3592154,"file_name":"bg.jpg","project_id":196924,"asset_id":285057,"created_at":"2020-11-26T19:02:07.339+08:00","updated_at":"2020-11-26T19:02:07.339+08:00"},{"id":3592319,"file_name":"p2_2.png","project_id":196924,"asset_id":285084,"created_at":"2020-11-26T23:25:43.527+08:00","updated_at":"2020-11-26T23:25:43.527+08:00"},{"id":3592320,"file_name":"p2_3.png","project_id":196924,"asset_id":285085,"created_at":"2020-11-26T23:25:43.529+08:00","updated_at":"2020-11-26T23:25:43.529+08:00"},{"id":3592317,"file_name":"p2_0.png","project_id":196924,"asset_id":285082,"created_at":"2020-11-26T23:25:43.233+08:00","updated_at":"2020-11-26T23:25:43.233+08:00"},{"id":3592318,"file_name":"p2_1.png","project_id":196924,"asset_id":285083,"created_at":"2020-11-26T23:25:43.235+08:00","updated_at":"2020-11-26T23:25:43.235+08:00"},{"id":3592152,"file_name":"p1_2.png","project_id":196924,"asset_id":285055,"created_at":"2020-11-26T19:02:06.104+08:00","updated_at":"2020-11-26T19:02:06.104+08:00"},{"id":3592153,"file_name":"p1_3.png","project_id":196924,"asset_id":285056,"created_at":"2020-11-26T19:02:06.105+08:00","updated_at":"2020-11-26T19:02:06.105+08:00"},{"id":3592150,"file_name":"p1_0.png","project_id":196924,"asset_id":285053,"created_at":"2020-11-26T19:02:05.609+08:00","updated_at":"2020-11-26T19:02:05.609+08:00"},{"id":3592151,"file_name":"p1_1.png","project_id":196924,"asset_id":285054,"created_at":"2020-11-26T19:02:05.611+08:00","updated_at":"2020-11-26T19:02:05.611+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦