{"id":194474,"student_id":2589,"content":"","created_at":"2020-10-06T18:23:12.785+08:00","updated_at":"2023-12-01T16:52:45.819+08:00","name":"排球之王 - 開始後用滑鼠點擊舞台以啟用按鍵,重整畫面即可重新遊戲。","language":"python","screenshot":{"url":"https://cdn2.koding.school/uploads/project/screenshot/194474/cdf4b733a67148368aa0eff96eef289a.jpg"},"parent_id":4,"plugin":"import game #載入遊戲套件\n\ngame.set_backdrop('bg.png') #設定背景圖\nshadow = game.create_sprite('shadow.png') #球的影子\nball = game.create_sprite('ball.png') #球\ninfo = game.create_sprite('info.png') #遊戲說明\n\nvx = 10 #水平速度\nvy = 10 #垂直速度\nscore = 0 #當前得分\nbest = 0 #最佳分數\n\ngame.create_sound('bgm.mp3', True)\n\ndef loop ():\n global vx, vy, score, best\n \n #根據速度改變球的位置\n ball.x = ball.x + vx\n ball.y = ball.y + vy\n vy += 1/3 #模擬引力\n \n #當球超出左邊邊界\n if ball.x \u003c 100 and vx \u003c 0: vx = -vx\n \n #當球超出右邊邊界\n if ball.x \u003e 1100 and vx \u003e 0: vx = -vx\n \n #當球超出上方邊界\n if ball.y \u003c 0 and vy \u003c 0: vy = -vy\n \n #當球超出下方邊界\n if ball.y \u003e 750 and vy \u003e 0:\n vy = -vy * 0.7\n vx = vx * 0.7\n score = 0\n \n #如果球碰撞到滑鼠\n if ball.touched(cursor) == True:\n vx = (ball.x - cursor.x) / 4\n vy = (ball.y - cursor.y) / 4\n score += 1\n if score \u003e best: best = score\n game.create_sound('bounce.mp3')\n \n #如果滑鼠按下就隱藏遊戲說明\n if cursor.is_down == True:\n info.hidden = True\n \n game.draw_text(score, 110, 80, 'white', 50)\n game.draw_text(best, 1050, 80, 'white', 50)\n ball.direction += vx/10 #根據水平速度旋轉球的方向\n \n shadow.x = ball.x #影子在球的正下方\n shadow.y = 850\n shadow.scale = ball.y / 500 #球越下面影子越大\n\ngame.forever(loop) #重複不斷執行\n","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":90,"hashid":"4y3sjjjy","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":3330154,"file_name":"bgm.mp3","project_id":194474,"asset_id":267900,"created_at":"2020-10-06T18:23:31.669+08:00","updated_at":"2020-10-06T18:23:31.669+08:00"},{"id":3330155,"file_name":"bounce.mp3","project_id":194474,"asset_id":267901,"created_at":"2020-10-06T18:23:31.674+08:00","updated_at":"2020-10-06T18:23:31.674+08:00"},{"id":3330156,"file_name":"bg.png","project_id":194474,"asset_id":267902,"created_at":"2020-10-06T18:23:31.679+08:00","updated_at":"2020-10-06T18:23:31.679+08:00"},{"id":3330157,"file_name":"ball.png","project_id":194474,"asset_id":267903,"created_at":"2020-10-06T18:23:31.684+08:00","updated_at":"2020-10-06T18:23:31.684+08:00"},{"id":3330158,"file_name":"shadow.png","project_id":194474,"asset_id":267904,"created_at":"2020-10-06T18:23:31.688+08:00","updated_at":"2020-10-06T18:23:31.688+08:00"},{"id":3330159,"file_name":"info.png","project_id":194474,"asset_id":267905,"created_at":"2020-10-06T18:23:31.693+08:00","updated_at":"2020-10-06T18:23:31.693+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦