{"id":183191,"student_id":2589,"content":"","created_at":"2020-08-20T11:31:05.269+08:00","updated_at":"2020-08-20T11:31:30.167+08:00","name":"瘋狂賽車(完整版)","language":"javascript","screenshot":{"url":null},"parent_id":2,"plugin":"Game.set({\n width: 1200, height: 900,\n})\n\nvar road = createSprite('road.png'); //柏油路背景\nvar check1 = createSprite('check.png'); //檢查點1\nvar check2 = createSprite('check.png'); //檢查點2\nvar border = createSprite('border.png'); //道路邊界\nvar car = createSprite('car.png'); //車子\nvar dashboard = createSprite('dashboard.png'); //儀表板\nvar resultBoard = createSprite('result.png'); //成績顯示版\nvar miniRoad = createSprite('road.png'); //迷你地圖\nvar miniCar = createSprite('car.png'); //迷你車\n\ncheck1.moveTo(600, 400);\ncheck2.moveTo(600, -1750);\nminiRoad.moveTo(1000, 700);\nminiCar.moveTo(1000, 700);\n\nminiCar.scale = 1/2; //縮小車子\nminiRoad.scale = 1/15; //縮小地圖\nminiRoad.opacity = 0.6; //迷你地圖半透明\n\nresultBoard.hidden = true; //預設隱藏成績顯示版\n\nvar speed = 0; //車速\nvar startTime = Date.now(); //開始時間\nvar round = 1; //圈數\nvar isChecked = false; //是否經過檢查點2\nvar timer = 0; //計時器\nvar t1; //第1圈秒數\nvar t2; //第2圈秒數\nvar t3; //第3圈秒數\n\n//固定圖片不會隨角度旋轉\nroad.rotationStyle = 'fixed';\ncheck1.rotationStyle = 'fixed';\ncheck2.rotationStyle = 'fixed';\nborder.rotationStyle = 'fixed';\n\ncreateSound('bgm.mp3', true);\nvar engineSound = createSound('engine.mp3', true);\n\nforever(loop); //重複不斷執行遊戲迴圈\n\n//遊戲主迴圈\nfunction loop () {\n \n timer = (Date.now() - startTime)/1000;\n\n print(Math.floor(speed*10) + ' km/h', 80, 80, 'white', 40);\n print(round + '/3', 350, 80, 'black', 40);\n print(timer + 's', 1000, 80, 'white', 40);\n\n engineSound.setVolume(speed/10); //根據速度調整引擎聲音\n\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.2;\n }\n if (key.left) {\n car.direction -= 2;\n speed -= 0.2;\n }\n if (speed \u003c 12) {\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) \u0026\u0026 isChecked) {\n startTime = Date.now();\n if (round == 1) {\n t1 = timer;\n }\n if (round == 2) {\n t2 = timer;\n }\n if (round == 3) {\n t3 = timer;\n }\n round += 1;\n isChecked = false;\n }\n if (car.touched(check2)) {\n isChecked = true;\n }\n if (round == 4) {\n resultBoard.hidden = false;\n var avg = (t1 + t2 + t3) / 3;\n drawText(t1 + 's', 550, 340, 'white', 30);\n drawText(t2 + 's', 550, 410, 'white', 30);\n drawText(t3 + 's', 550, 495, 'white', 30);\n drawText(avg.toFixed(3) + 's', 550, 560, 'white', 30);\n stop();\n }\n \n miniCar.direction = car.direction;\n miniCar.stepForward(speed/15);\n\n}","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":84,"hashid":"36ysvgzz","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":3115515,"file_name":"border.png","project_id":183191,"asset_id":251278,"created_at":"2020-08-20T11:31:19.355+08:00","updated_at":"2020-08-20T11:31:19.355+08:00"},{"id":3115516,"file_name":"road.png","project_id":183191,"asset_id":251279,"created_at":"2020-08-20T11:31:19.382+08:00","updated_at":"2020-08-20T11:31:19.382+08:00"},{"id":3115517,"file_name":"result.png","project_id":183191,"asset_id":251280,"created_at":"2020-08-20T11:31:19.391+08:00","updated_at":"2020-08-20T11:31:19.391+08:00"},{"id":3115518,"file_name":"dashboard.png","project_id":183191,"asset_id":251281,"created_at":"2020-08-20T11:31:19.395+08:00","updated_at":"2020-08-20T11:31:19.395+08:00"},{"id":3115519,"file_name":"check.png","project_id":183191,"asset_id":251282,"created_at":"2020-08-20T11:31:19.399+08:00","updated_at":"2020-08-20T11:31:19.399+08:00"},{"id":3115520,"file_name":"car.png","project_id":183191,"asset_id":251283,"created_at":"2020-08-20T11:31:19.403+08:00","updated_at":"2020-08-20T11:31:19.403+08:00"},{"id":3115521,"file_name":"bgm.mp3","project_id":183191,"asset_id":251284,"created_at":"2020-08-20T11:31:19.459+08:00","updated_at":"2020-08-20T11:31:19.459+08:00"},{"id":3115522,"file_name":"engine.mp3","project_id":183191,"asset_id":251285,"created_at":"2020-08-20T11:31:19.468+08:00","updated_at":"2020-08-20T11:31:19.468+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
下載 Android APP (APK)
截圖
1:1:1
1:1
full
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦