{"id":348389,"student_id":10,"content":"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') #成績顯示版\n\n#固定圖片不會隨角度旋轉\nroad.rotation_style = 'fixed'\ncheck1.rotation_style = 'fixed'\ncheck2.rotation_style = 'fixed'\nborder.rotation_style = 'fixed'\n\nresult_board.hidden = True #預設隱藏成績顯示版\n\ncheck1.move_to(600, 400)\ncheck2.move_to(600, -1750)\n\nstart_time = time() #開始時間\nspeed = 5 #車速\nturns = 1 #圈數\ntimer = 0 #計時器\nt1 = 0 #第1圈秒數\nt2 = 0 #第2圈秒數\nt3 = 0 #第3圈秒數\nis_checked = False #是否經過檢查點2\n\n\n#遊戲主迴圈\ndef loop ():\n global speed, start_time, turns, is_checked, timer, t1, t2, t3\n \n if key.left: #按下左鍵向左轉\n car.direction -= 3\n \n if key.right: #按下右鍵向右轉\n car.direction += 3\n \n border.direction = car.direction + 180 #朝向車子方反方向\n border.step_forward(speed) #根據 speed 速度相對移動\n road.direction = car.direction + 180 #朝向車子方反方向\n road.step_forward(speed) #根據 speed 速度相對移動\n check1.direction = car.direction + 180 #朝向車子方反方向\n check1.step_forward(speed) #根據 speed 速度相對移動\n check2.direction = car.direction + 180 #朝向車子方反方向\n check2.step_forward(speed) #根據 speed 速度相對移動\n \n # 碰到檢查點1而且經過檢查點2\n if car.touched(check1) and is_checked:\n turns += 1 #圈數加 1\n is_checked = False #重置紀錄是否經過檢查點2\n \n #碰到檢查點2\n if car.touched(check2):\n is_checked = True #紀錄經過檢查點2\n \n # 如果第 3 圈跑完就結束遊戲\n if turns == 4:\n result_board.hidden = False #顯示計分板\n stop() #停止遊戲\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\nforever(loop) #重複不斷執行遊戲迴圈\n\n\n","created_at":"2022-02-23T23:58:54.544+08:00","updated_at":"2022-02-24T00:02:47.784+08:00","name":"瘋狂賽車(預設版) 副本","language":"python","screenshot":{"url":"https://cdn4.koding.school/uploads/project/screenshot/348389/d5d8d90c50346241ad10934a3bdaf682.jpg"},"parent_id":183415,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":138,"hashid":"meyswmerr","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":7532362,"file_name":"road.png","project_id":348389,"asset_id":251810,"created_at":"2022-02-23T23:58:54.549+08:00","updated_at":"2022-02-23T23:58:54.549+08:00"},{"id":7532363,"file_name":"result.png","project_id":348389,"asset_id":251811,"created_at":"2022-02-23T23:58:54.550+08:00","updated_at":"2022-02-23T23:58:54.550+08:00"},{"id":7532364,"file_name":"engine.mp3","project_id":348389,"asset_id":251812,"created_at":"2022-02-23T23:58:54.551+08:00","updated_at":"2022-02-23T23:58:54.551+08:00"},{"id":7532365,"file_name":"dashboard.png","project_id":348389,"asset_id":251813,"created_at":"2022-02-23T23:58:54.552+08:00","updated_at":"2022-02-23T23:58:54.552+08:00"},{"id":7532366,"file_name":"check.png","project_id":348389,"asset_id":251814,"created_at":"2022-02-23T23:58:54.552+08:00","updated_at":"2022-02-23T23:58:54.552+08:00"},{"id":7532367,"file_name":"car.png","project_id":348389,"asset_id":251815,"created_at":"2022-02-23T23:58:54.553+08:00","updated_at":"2022-02-23T23:58:54.553+08:00"},{"id":7532368,"file_name":"border.png","project_id":348389,"asset_id":251816,"created_at":"2022-02-23T23:58:54.554+08:00","updated_at":"2022-02-23T23:58:54.554+08:00"},{"id":7532369,"file_name":"bgm.mp3","project_id":348389,"asset_id":251817,"created_at":"2022-02-23T23:58:54.555+08:00","updated_at":"2022-02-23T23:58:54.555+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦