{"id":271187,"student_id":34,"content":"import game #載入遊戲套件\nimport random #載入產生隨機數的模組\n\ngame.set_backdrop('bg.jpg') #設定背景圖\nball = game.create_sprite('ball_0.png') #球\nball2 = game.create_sprite(\"ball_1.png\") #創造角色\nball3 = game.create_sprite(\"ball_2.png\") #創造角色\np1 = game.create_sprite('p1.png') #左邊玩家擋板\np2 = game.create_sprite('p2.png') #右邊玩家擋板\ninfo = game.create_sprite('INFO2.png', 'bg_1.jpg', 'bg_2.jpg') #遊戲開始、結束提示圖\ngame.create_sound('bgm.mp3',True)\n\np1.x = 30\np2.x = 1170\n\nspeed = 10 #球的速度\np1_score = 0 #左邊玩家分數\np2_score = 0 #右邊玩家分數\np1_sp = False\np2_sp = False\np1_wait = 10 \np2_wait = 10\n\nball2.hidden = True\nball3.hidden = True\n\n#遊戲主迴圈\ndef loop ():\n global p1_score, p2_score, speed, p1_sp, p2_sp, p1_wait, p2_wait\n \n if p1_score == 5:\n info.hidden = False\n info.costume_id = 2\n game.stop()\n \n if p2_score == 5:\n info.hidden = False\n info.costume_id = 1\n game.stop()\n \n if game.key.d and game.key.k:\n info.hidden = True\n \n\n if info.hidden == True:\n if game.key.w and p1.y \u003e 0:p1.y -= 20\n if game.key.s and p1.y \u003c 900:p1.y += 20\n if game.key.o and p2.y \u003e 0:p2.y -= 20\n if game.key.l and p2.y \u003c 900:p2.y += 20\n \n if info.hidden == True:\n ball.step_forward(speed)\n ball2.step_forward(speed)\n ball3.step_forward(speed)\n \n \n if p1_sp == True:\n if ball.touched(p1):\n ball.direction = ball.direction * -1 + random.randrange(0,15)\n speed += 1\n game.create_sound('hit.mp3')\n \n elif ball.touched(p1) and ball.direction \u003e 180:\n ball.direction = ball.direction * -1 + random.randrange(0,15)\n speed += 1\n game.create_sound('hit.mp3')\n \n if ball.touched(p2) and ball.direction \u003c 180:\n ball.direction = ball.direction * -1 + random.randrange(0,15)\n speed += 1\n game.create_sound('hit.mp3')\n if p2_sp == True:\n ball2.move_to( ball.x, ball.y)\n ball3.move_to( ball.x, ball.y)\n ball2.direction = random.randrange(180,360)\n ball3.direction = random.randrange(180,360)\n \n if ball.y \u003e 900 or ball.y \u003c 0:\n ball.direction = ball.direction * -1 + 180\n \n if ball2.y \u003e 900 or ball2.y \u003c 0:\n ball2.direction = ball2.direction * -1 + 180 \n \n if ball3.y \u003e 900 or ball3.y \u003c 0:\n ball3.direction = ball3.direction * -1 + 180\n \n if ball.x \u003c 0:\n ball.move_to( 600,450 )\n ball.direction = 270\n speed = 10\n p2_score += 1\n game.create_sound('lose.ogg')\n \n if ball.x \u003e 1200:\n ball.move_to( 600,450 )\n ball.direction = 90\n speed = 10\n p1_score += 1\n game.create_sound('lose.ogg')\n \n game.draw_text(p1_score, 30, 20, '#F46F25', 80) #印出 p1 分數\n game.draw_text(p2_score, 1140, 20, '#23B0DB', 80) #印出 p2 分數\n \n if p1_sp == False:p1_wait = p1_wait + 1/60\n else:p1_wait = p1_wait - 1/60\n if p2_sp == False:p2_wait = p2_wait + 1/60\n else:p2_wait = p2_wait - 1/60\n if p1_wait \u003c 0:p1_sp = False\n if p2_wait \u003c 0:\n p2_sp = False\n ball2.hidden = True\n ball3.hidden = True\n if game.key.q and p1_wait \u003e 10 and p1_sp == False:\n p1_sp = True\n p1_wait = 10\n if game.key.p and p2_wait \u003e 10 and p2_sp == False:\n p2_sp = True\n p2_wait = 10\n ball3.hidden = False\n ball2.hidden = False\n \n \n\nforever(loop) #重複不斷執行遊戲迴圈","created_at":"2021-07-08T19:11:00.624+08:00","updated_at":"2021-07-14T13:11:48.533+08:00","name":"彈力球大賽(預設版) 副本","language":"python","screenshot":{"url":"https://cdn7.koding.school/uploads/project/screenshot/271187/b0b31bd538a6032bf90ce7671c54fe2e.jpg"},"parent_id":183420,"plugin":"game.set({'width': 1200, 'height': 900})","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":101,"hashid":"wdks4zpd6","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":5259346,"file_name":"p2.png","project_id":271187,"asset_id":251890,"created_at":"2021-07-08T19:11:00.629+08:00","updated_at":"2021-07-08T19:11:00.629+08:00"},{"id":5259347,"file_name":"ball_1.png","project_id":271187,"asset_id":251891,"created_at":"2021-07-08T19:11:00.630+08:00","updated_at":"2021-07-08T19:11:00.630+08:00"},{"id":5259348,"file_name":"bg.jpg","project_id":271187,"asset_id":251892,"created_at":"2021-07-08T19:11:00.631+08:00","updated_at":"2021-07-08T19:11:00.631+08:00"},{"id":5259349,"file_name":"hit.mp3","project_id":271187,"asset_id":251893,"created_at":"2021-07-08T19:11:00.632+08:00","updated_at":"2021-07-08T19:11:00.632+08:00"},{"id":5259350,"file_name":"lose.ogg","project_id":271187,"asset_id":251894,"created_at":"2021-07-08T19:11:00.633+08:00","updated_at":"2021-07-08T19:11:00.633+08:00"},{"id":5259351,"file_name":"bg_1.jpg","project_id":271187,"asset_id":251895,"created_at":"2021-07-08T19:11:00.634+08:00","updated_at":"2021-07-08T19:11:00.634+08:00"},{"id":5259352,"file_name":"p1.png","project_id":271187,"asset_id":251896,"created_at":"2021-07-08T19:11:00.635+08:00","updated_at":"2021-07-08T19:11:00.635+08:00"},{"id":5259353,"file_name":"info.png","project_id":271187,"asset_id":251897,"created_at":"2021-07-08T19:11:00.636+08:00","updated_at":"2021-07-08T19:11:00.636+08:00"},{"id":5259354,"file_name":"bgm.mp3","project_id":271187,"asset_id":251898,"created_at":"2021-07-08T19:11:00.637+08:00","updated_at":"2021-07-08T19:11:00.637+08:00"},{"id":5259355,"file_name":"bg_2.jpg","project_id":271187,"asset_id":251899,"created_at":"2021-07-08T19:11:00.638+08:00","updated_at":"2021-07-08T19:11:00.638+08:00"},{"id":5259357,"file_name":"ball_0.png","project_id":271187,"asset_id":251901,"created_at":"2021-07-08T19:11:00.639+08:00","updated_at":"2021-07-08T19:11:00.639+08:00"},{"id":5259356,"file_name":"ball_2.png","project_id":271187,"asset_id":251900,"created_at":"2021-07-08T19:11:00.638+08:00","updated_at":"2021-07-10T21:30:54.690+08:00"},{"id":5306950,"file_name":"INFO2.png","project_id":271187,"asset_id":379193,"created_at":"2021-07-10T20:05:31.676+08:00","updated_at":"2021-07-10T20:05:45.890+08:00"}]
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
繁中
简中
English
日本語
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦