{"id":196932,"student_id":2589,"content":"","created_at":"2020-10-19T17:01:39.581+08:00","updated_at":"2023-03-14T14:40:55.113+08:00","name":"瘋狂賽車 - 開始後用滑鼠點擊舞台以啟用按鍵,重整畫面即可重新遊戲。","language":"python","screenshot":{"url":"https://cdn3.koding.school/uploads/project/screenshot/196932/d0a81ce81195fd74f12f722f13ecb19c.jpg"},"parent_id":4,"plugin":"from time import time #載入時間模組\nfrom game import (\n create_sprite, #創造角色\n create_sound, #創造音效\n draw_text, #繪製文字\n forever, #重複不斷執行\n stop, #遊戲結束\n)\n\nroad = create_sprite('road.png') #柏油路背景\ncheck1 = create_sprite('check.png') #檢查點1\ncheck2 = create_sprite('check.png') #檢查點2\nborder = create_sprite('border.png') #道路邊界\ncar = create_sprite('car.png') #車子\ndashboard = create_sprite('dashboard.png') #儀表板\nresult_board = create_sprite('result.png') #成績顯示版\nmini_road = create_sprite('road.png') #迷你地圖\nmini_car = create_sprite('car.png') #迷你車\n\n#固定圖片不會隨角度旋轉\nroad.rotation_style = 'fixed'\ncheck1.rotation_style = 'fixed'\ncheck2.rotation_style = 'fixed'\nborder.rotation_style = 'fixed'\n\nmini_car.scale = 1/2 #縮小車子\nmini_road.scale = 1/15 #縮小地圖\nmini_road.opacity = 0.6 #迷你地圖半透明\nresult_board.hidden = True #預設隱藏成績顯示版\n\ncheck1.move_to(600, 400)\ncheck2.move_to(600, -1750)\nmini_road.move_to(1000, 700)\nmini_car.move_to(1000, 700)\n\nstart_time = time() #開始時間\nspeed = 0 #車速\nturns = 1 #圈數\ntimer = 0 #計時器\nt1 = 0 #第1圈秒數\nt2 = 0 #第2圈秒數\nt3 = 0 #第3圈秒數\nis_checked = False #是否經過檢查點2\n\ncreate_sound('bgm.mp3', True)\nengine_sound = create_sound('engine.mp3', True)\n\n#遊戲主迴圈\ndef loop ():\n global speed, start_time, turns, is_checked, timer, t1, t2, t3\n \n timer = time() - start_time\n \n draw_text(str(turns) + '/3', 350, 80, 'black', 40) #圈數\n draw_text(str(round(timer,3)) + 's', 1000, 80, 'white', 40) #時間\n draw_text(str(round(speed*10)) + ' km/h', 80, 80, 'white', 40) #車速\n\n engine_sound.set_volume(speed/10)\n\n border.direction = car.direction + 180\n border.stepForward(speed)\n road.direction = car.direction + 180\n road.stepForward(speed)\n check1.direction = car.direction + 180\n check1.stepForward(speed)\n check2.direction = car.direction + 180\n check2.stepForward(speed)\n\n if key.right:\n car.direction += 2\n speed -= 0.25\n \n if key.left:\n car.direction -= 2\n speed -= 0.25\n \n if speed \u003c 14:\n speed += 0.15\n \n if car.touched(border):\n speed -= 0.3\n \n if speed \u003c 0.6:\n speed = 0.6\n \n if car.touched(check1) and is_checked:\n if turns == 1:\n t1 = timer\n \n if turns == 2:\n t2 = timer\n \n if turns == 3:\n t3 = timer\n\n start_time = time() \n turns += 1\n is_checked = False\n \n if car.touched(check2):\n is_checked = True\n \n if turns == 4:\n result_board.hidden = False\n avg = (t1 + t2 + t3) / 3\n draw_text(str(round(t1,3)) + 's', 550, 340, 'white', 30)\n draw_text(str(round(t2,3)) + 's', 550, 410, 'white', 30)\n draw_text(str(round(t3,3)) + 's', 550, 495, 'white', 30)\n draw_text(str(round(avg,3)) + 's', 550, 560, 'white', 30)\n stop()\n \n mini_car.direction = car.direction\n mini_car.stepForward(speed/15)\n\nforever(loop) #重複不斷執行遊戲迴圈\n\n\n","description":null,"note":null,"status":"public","like_student_ids":[12215,12971,23092,13078,26663,18335,27631,21138,26954,12466,12126,16672,22391,22240,22072,40597,17110,5135,36125,17411,23460,23147,26415,28443,21222,31223,34482,32757,24276,26650,28540,26493,12003,17883,27966,47495,23594,16514,38763,26704,43026,41370,37164,37772,22510,38994,49847,37770,46637,42279,42070,41701,40009,33044,46946],"is_featured":false,"views":2556,"hashid":"kdms6zw4n","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":3377991,"file_name":"road.png","project_id":196932,"asset_id":270890,"created_at":"2020-10-19T17:02:00.305+08:00","updated_at":"2020-10-19T17:02:00.305+08:00"},{"id":3377992,"file_name":"result.png","project_id":196932,"asset_id":270891,"created_at":"2020-10-19T17:02:00.310+08:00","updated_at":"2020-10-19T17:02:00.310+08:00"},{"id":3377993,"file_name":"engine.mp3","project_id":196932,"asset_id":270892,"created_at":"2020-10-19T17:02:00.318+08:00","updated_at":"2020-10-19T17:02:00.318+08:00"},{"id":3377994,"file_name":"dashboard.png","project_id":196932,"asset_id":270893,"created_at":"2020-10-19T17:02:00.323+08:00","updated_at":"2020-10-19T17:02:00.323+08:00"},{"id":3377995,"file_name":"check.png","project_id":196932,"asset_id":270894,"created_at":"2020-10-19T17:02:00.327+08:00","updated_at":"2020-10-19T17:02:00.327+08:00"},{"id":3377996,"file_name":"car.png","project_id":196932,"asset_id":270895,"created_at":"2020-10-19T17:02:00.331+08:00","updated_at":"2020-10-19T17:02:00.331+08:00"},{"id":3377997,"file_name":"border.png","project_id":196932,"asset_id":270896,"created_at":"2020-10-19T17:02:00.418+08:00","updated_at":"2020-10-19T17:02:00.418+08:00"},{"id":3377998,"file_name":"bgm.mp3","project_id":196932,"asset_id":270897,"created_at":"2020-10-19T17:02:00.470+08:00","updated_at":"2020-10-19T17:02:00.470+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦