{"id":134018,"student_id":3469,"content":"setBackdrop('black');\r\n\r\n// 創造天花板\r\nvar ceiling = createSprite(\"ceiling.png\");\r\nceiling.x = 320;\r\nceiling.y = 8;\r\nceiling.layer = 1;\r\n\r\n// 創造左右牆壁\r\nvar left_wall = createSprite(\"wall.png\");\r\nvar right_wall = createSprite(\"wall.png\");\r\nleft_wall.x = 130;\r\nright_wall.x = 510;\r\n\r\n// 創造玩家\r\nvar player = createSprite([\"player_1.png\",\"player_2.png\",\"player_3.png\",\"player_4.png\",\"player_5.png\"]);\r\nplayer.y = 50;\r\n\r\n// 初始化變數\r\nvar life = 10;\r\nvar floor = 0;\r\n\r\n//---------------------------預設程式碼------------------------------------//\r\nvar vy = 0;\r\nvar stairs = [];\r\n\r\n\r\n\r\nfor (var i = 0; i \u003c 8; i++) {\r\n var stair = createSprite(['nails.png', 'trampoline.png', 'normal.png', 'fake.png', 'conveyor_right.png', 'conveyor_left.png']);\r\n stair.costumeId = Math.floor(Math.random() * 6);\r\n stair.x = Math.random() * 250 + 200;\r\n stair.y = i * 80 + 550;\r\n stairs.push(stair);\r\n \r\n}\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\nforever(function() {\r\n\r\n if (life \u003e 0 \u0026\u0026 player.y \u003c 480) {\r\n updatePalyer();\r\n updateStairs();\r\n checkTouchedCeiling();\r\n flashBackground();\r\n } else {\r\n setBackdrop('red');\r\n print('Game Over', 200, 200, 'white', 30)\r\n }\r\n \r\n \r\n print('分數:' + floor, 10, 10, 'white', 20);\r\n print('生命:' + life, 10, 40, 'while', 20);\r\n});\r\n\r\n\r\n\r\nfunction updatePalyer(){\r\n if (key.right \u0026\u0026 !player.touched(right_wall)) {\r\n player.x += 3;\r\n if (player.costumeId == 1 || player.costumeId === 0) {\r\n player.costumeId = 2;\r\n } else {\r\n player.costumeId = 1;\r\n }\r\n }\r\n if (key.left \u0026\u0026 !player.touched(left_wall)) {\r\n player.x -= 3;\r\n if (player.costumeId == 3 || player.costumeId === 0) {\r\n player.costumeId = 4;\r\n } else {\r\n player.costumeId = 3;\r\n }\r\n }\r\n if (!key.right \u0026\u0026 !key.left) {\r\n player.costumeId = 0;\r\n }\r\n vy += 0.1;\r\n player.y += vy;\r\n \r\n \r\n \r\n}\r\n\r\nfunction updateStairs(){\r\n for (var i = 0; i \u003c stairs.length; i++) {\r\n stairs[i].y -= 2;\r\n if (stairs[i].y \u003c -10) {\r\n stairs[i].costumeId = Math.floor(Math.random() * 6);\r\n stairs[i].y += 640;\r\n stairs[i].hidden = false;\r\n floor++;\r\n }\r\n }\r\n}\r\n\r\n\r\nvar time = 0;\r\nvar lastTime = 0;\r\n\r\n\r\nfunction checkTouchedCeiling(){\r\n \r\n time = Date.now();\r\n \r\n if (player.touched(ceiling) \u0026\u0026 time - lastTime \u003e 3000) {\r\n life -= 3;\r\n vy = 0;\r\n hit = true;\r\n lastTime = time;\r\n }\r\n}\r\n\r\n\r\nvar hit;\r\n\r\n\r\nfunction flashBackground(){\r\n if (hit) {\r\n setBackdrop('red');\r\n hit = false;\r\n setTimeout(function() {\r\n setBackdrop('black'); \r\n }, 50);\r\n }\r\n}\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\nvar touchOn;\r\nplayer.when(\"touch\", stairs, function(s){\r\n vy = 0;\r\n player.y = s.y - 20;\r\n \r\n if (s.costumeId == 5) {\r\n player.x -= 2;\r\n }\r\n \r\n if (s.costumeId == 4) {\r\n player.x += 2;\r\n }\r\n \r\n if (s.costumeId == 1) {\r\n vy -= 6;\r\n }\r\n \r\n if (s.costumeId == 2 \u0026\u0026 s != touchOn) {\r\n life += 1;\r\n }\r\n \r\n if (s.costumeId === 0 \u0026\u0026 s != touchOn) {\r\n life -= 3;\r\n hit = true;\r\n }\r\n \r\n if (s.costumeId == 3) {\r\n setTimeout(function() {\r\n s.hidden = true;\r\n }, 300);\r\n }\r\n \r\n touchOn = s;\r\n \r\n \r\n \r\n \r\n});\r\n\r\n\r\n\r\n\r\n\r\n\r\n","created_at":"2020-03-15T13:41:02.943+08:00","updated_at":"2022-01-28T21:21:05.313+08:00","name":"小朋友下樓梯 副本","language":"javascript","screenshot":{"url":"https://cdn5.koding.school/uploads/project/screenshot/134018/b230fa3bcc0fafe3f75ee57f07ce202f.jpg"},"parent_id":61784,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":105,"hashid":"yeysdm69","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":2303312,"file_name":"conveyor_left.png","project_id":134018,"asset_id":114034,"created_at":"2020-03-15T13:41:02.950+08:00","updated_at":"2020-03-15T13:41:02.950+08:00"},{"id":2303313,"file_name":"conveyor_right.png","project_id":134018,"asset_id":114033,"created_at":"2020-03-15T13:41:02.952+08:00","updated_at":"2020-03-15T13:41:02.952+08:00"},{"id":2303314,"file_name":"fake.png","project_id":134018,"asset_id":114032,"created_at":"2020-03-15T13:41:02.954+08:00","updated_at":"2020-03-15T13:41:02.954+08:00"},{"id":2303315,"file_name":"normal.png","project_id":134018,"asset_id":114031,"created_at":"2020-03-15T13:41:02.955+08:00","updated_at":"2020-03-15T13:41:02.955+08:00"},{"id":2303316,"file_name":"trampoline.png","project_id":134018,"asset_id":114030,"created_at":"2020-03-15T13:41:02.956+08:00","updated_at":"2020-03-15T13:41:02.956+08:00"},{"id":2303317,"file_name":"nails.png","project_id":134018,"asset_id":114029,"created_at":"2020-03-15T13:41:02.957+08:00","updated_at":"2020-03-15T13:41:02.957+08:00"},{"id":2303318,"file_name":"ceiling.png","project_id":134018,"asset_id":114028,"created_at":"2020-03-15T13:41:02.959+08:00","updated_at":"2020-03-15T13:41:02.959+08:00"},{"id":2303319,"file_name":"wall.png","project_id":134018,"asset_id":114027,"created_at":"2020-03-15T13:41:02.960+08:00","updated_at":"2020-03-15T13:41:02.960+08:00"},{"id":2303320,"file_name":"player_3.png","project_id":134018,"asset_id":114026,"created_at":"2020-03-15T13:41:02.961+08:00","updated_at":"2020-03-15T13:41:02.961+08:00"},{"id":2303321,"file_name":"player_4.png","project_id":134018,"asset_id":114025,"created_at":"2020-03-15T13:41:02.962+08:00","updated_at":"2020-03-15T13:41:02.962+08:00"},{"id":2303322,"file_name":"player_2.png","project_id":134018,"asset_id":114024,"created_at":"2020-03-15T13:41:02.963+08:00","updated_at":"2020-03-15T13:41:02.963+08:00"},{"id":2303323,"file_name":"player_5.png","project_id":134018,"asset_id":114023,"created_at":"2020-03-15T13:41:02.965+08:00","updated_at":"2020-03-15T13:41:02.965+08:00"},{"id":2303324,"file_name":"player_1.png","project_id":134018,"asset_id":114022,"created_at":"2020-03-15T13:41:02.966+08:00","updated_at":"2020-03-15T13:41:02.966+08:00"},{"id":2303325,"file_name":"bg.mp3","project_id":134018,"asset_id":114021,"created_at":"2020-03-15T13:41:02.967+08:00","updated_at":"2020-03-15T13:41:02.967+08:00"},{"id":2303326,"file_name":"flash.mp3","project_id":134018,"asset_id":114020,"created_at":"2020-03-15T13:41:02.968+08:00","updated_at":"2020-03-15T13:41:02.968+08:00"},{"id":2303327,"file_name":"gg.mp3","project_id":134018,"asset_id":114019,"created_at":"2020-03-15T13:41:02.970+08:00","updated_at":"2020-03-15T13:41:02.970+08:00"},{"id":2303328,"file_name":"jump.mp3","project_id":134018,"asset_id":114018,"created_at":"2020-03-15T13:41:02.971+08:00","updated_at":"2020-03-15T13:41:02.971+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
下載 Android APP (APK)
截圖
1:1:1
1:1
full
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦