{"id":2827,"student_id":10,"content":"var speed = 0; // 車子當前速度\nvar power = 2; // 加速度\nvar maxSpeed = 180; // 最高速\nvar slow = 3; // 過彎減速\nvar friction = 3; // 草皮摩擦力\nvar round = 0; // 當前圈數\nvar target = 3; // 目標圈數\nvar pass = 0; // 紀錄總圈數時間\nvar oneRoundTime = 0; // 紀錄單趟時間\nvar startTime = new Date().getTime();\n\nsetBackdrop(\"#777\");\n\nvar checkPoint = Game.createSprite({\n\tx: 310,\n y: 120,\n scale: .6,\n costumes: \"indy_winner.jpg\"\n});\n\nvar road = Game.createSprite({\n \tx: 1600,\n \ty: -100,\n scale: 1,\n\tcostumes: \"秋名山賽道.png\"\n});\n\nvar dash = Game.createSprite({\n \tx: 1600,\n \ty: -100,\n scale: 1,\n\tcostumes: \"秋名山賽道_中線.png\"\n});\n\nvar car = Game.createSprite({\n\tx: 320,\n y: 240,\n scale: .2,\n direction: -90,\n costumes: \"86.png\"\n});\n\ncar.on('touch',[road], function() {\n var base = 3;\n if(speed \u003e= friction + base) {\n speed -= friction;\n } else {\n speed = base;\n }\n});\n\nvar lastCheckTime = 0;\ncar.on('touch', [checkPoint], function() {\n\tvar now = new Date().getTime();\n if(now \u003e lastCheckTime + 20000) {\n \tlastCheckTime = now;\n if(round \u003e= 1) {\n console.log('第' + round + '圈花費時間:' + (pass - oneRoundTime) + 's');\n oneRoundTime = pass;\n }\n if(round == target) {\n console.log('總圈數花費:' + pass + '秒')\n \talert('花費:' + pass + '秒');\n }\n round += 1;\n }\n})\n\nGame.on('holding','left', function() {\n\tcar.direction -= 3;\n speed -= slow;\n});\n\nGame.on('holding','right', function() {\n\tcar.direction += 3;\n speed -= slow;\n});\n\nGame.on('holding','space', function() {\n\tspeed -= slow;\n});\n\nGame.forever(function() {\n \n if(round \u003e= target + 1) {\n \t\tGame.stop();\n }\n \n pass = (new Date().getTime() - startTime )/1000;\n pass = pass.toFixed(1);\n \n if(speed \u003c maxSpeed) speed += power;\n \n\tvar rad = car.direction/180*Math.PI;\n var move_x = Math.cos(rad) * speed / 20;\n var move_y = Math.sin(rad) * speed / 20;\n \n road.x -= move_x;\n road.y -= move_y;\n \n dash.x -= move_x;\n dash.y -= move_y;\n \n checkPoint.x -= move_x;\n checkPoint.y -= move_y;\n \n Game.print(speed + ' km/h', 0, 0, 'red', 30);\n Game.print(round + '/' + target + 'rounds', 500, 0, 'red', 30);\n Game.print(pass + 's', 0, 100, 'red', 30);\n})\n\n","created_at":"2017-03-01T20:52:04.729+08:00","updated_at":"2019-11-01T19:29:43.101+08:00","name":"秋名山道練習.jsa","language":"javascript","screenshot":{"url":"https://cdn1.koding.school/uploads/project/screenshot/2827/cc8c02b9e8aa59fc1925120e4fc52dd1.jpg"},"parent_id":2826,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":453,"hashid":"6rpsenj","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":81185,"file_name":"car_yellow.png","project_id":2827,"asset_id":11567,"created_at":"2017-04-26T18:14:24.355+08:00","updated_at":"2017-04-26T18:14:24.355+08:00"},{"id":81186,"file_name":"car_red.png","project_id":2827,"asset_id":11568,"created_at":"2017-04-26T18:14:24.357+08:00","updated_at":"2017-04-26T18:14:24.357+08:00"},{"id":81187,"file_name":"car_black.png","project_id":2827,"asset_id":11569,"created_at":"2017-04-26T18:14:24.362+08:00","updated_at":"2017-04-26T18:14:24.362+08:00"},{"id":81188,"file_name":"car_3_blue.png","project_id":2827,"asset_id":11570,"created_at":"2017-04-26T18:14:24.365+08:00","updated_at":"2017-04-26T18:14:24.365+08:00"},{"id":81189,"file_name":"indy_winner.jpg","project_id":2827,"asset_id":11571,"created_at":"2017-04-26T18:14:24.366+08:00","updated_at":"2017-04-26T18:14:24.366+08:00"},{"id":81190,"file_name":"86.png","project_id":2827,"asset_id":11572,"created_at":"2017-04-26T18:14:24.367+08:00","updated_at":"2017-04-26T18:14:24.367+08:00"},{"id":81191,"file_name":"秋名山賽道_中線.png","project_id":2827,"asset_id":11573,"created_at":"2017-04-26T18:14:24.368+08:00","updated_at":"2017-04-26T18:14:24.368+08:00"},{"id":81192,"file_name":"秋名山賽道.png","project_id":2827,"asset_id":11574,"created_at":"2017-04-26T18:14:24.369+08:00","updated_at":"2017-04-26T18:14:24.369+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
下載 Android APP (APK)
截圖
1:1:1
1:1
full
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦