{"id":138319,"student_id":10,"content":"// var bg = createSprite('sky_0.png', 'sky_1.png');\nvar build = createSprite('tower_0.png', 'tower_1.png');\nvar ceiling = createSprite('ceiling.png');\nvar player = createSprite('p_0.png', 'p_1.png', 'p_2.png', 'p_3.png', 'p_4.png', 'p_5.png');\n\nsetBackdrop(\"black\")\n\nvar life = 10;\nvar floor = 0;\nvar stairs = [];\nvar vy = 0;\nvar touchOn;\nvar flash = false;\nvar clock = 0;\n\nceiling.y = 20;\nceiling.layer = 1;\n\n\nfor (var i = 0; i \u003c 7; i++) {\n var s = createSprite('s_0.png', 's_1.png', 's_2.png', 's_3.png', 's_4.png', 's_5.png');\n s.y = i*150;\n s.x = 300 + Math.random()*600;\n s.costumeId = Math.floor(Math.random()*6);\n stairs.push(s);\n s.scale *= 1.3;\n}\n\nforever(loop);\nplayer.on('touch', stairs, onTouchStair);\ncreateSound('bgm.mp3', true);\n\n// 遊戲迴圈\nfunction loop () {\n updatePlayer();\n updateStairs();\n updateCostume();\n updateInfo();\n updateBackground();\n gameoverCheck();\n}\n\n// 更新所有階梯\nfunction updateStairs () {\n for (var i = 0; i \u003c stairs.length; i++) {\n var s = stairs[i];\n s.y -= 3;\n if (s.y \u003c -10) {\n s.y += 1050;\n s.x = 300 + Math.random()*600;\n s.costumeId = Math.floor(Math.random()*6);\n s.hidden = false;\n floor += 1;\n }\n }\n}\n\n// 更新玩家角色位置\nfunction updatePlayer () {\n if (key.left) {\n player.x -= 12;\n }\n if (key.right) {\n player.x += 12;\n }\n vy += 0.6;\n player.y += vy;\n}\n\n// 更新玩家角色位置\nfunction onTouchStair (s) {\n vy = 0;\n player.y = s.y - 55;\n\n if (s.costumeId == 0) {\n player.x -= 6;\n }\n if (s.costumeId == 1) {\n player.x += 6;\n }\n if (s.costumeId == 2) {\n vy = -12;\n createSound('jump.mp3');\n }\n if (s.costumeId == 3 \u0026\u0026 s != touchOn) {\n life += 1;\n }\n if (s.costumeId == 4 \u0026\u0026 s != touchOn) {\n life -= 3;\n flash = true;\n createSound('hit.mp3');\n }\n if (s.costumeId == 5 \u0026\u0026 s != touchOn) {\n setTimeout(function() { s.hidden = true; }, 500);\n }\n touchOn = s;\n}\n\n// 顯示遊戲分數與玩家生命\nfunction updateInfo () {\n drawText('分數:' + floor, 10, 10, 'black', 30);\n drawText('生命:' + life, 10, 40, 'black', 30);\n}\n\n// 檢查是否遊戲結束\nfunction gameoverCheck () {\n if (life \u003c= 0 || player.y \u003e 1000 || player.touched(ceiling)) {\n // bg.costumeId = 1;\n stop();\n createSound('gg.mp3');\n }\n}\n\n// 更新背景動畫\nfunction updateBackground () {\n // bg.y -= 0.2;\n // if (bg.y \u003c 0) {\n // bg.y += 2700;\n // }\n build.y -= 3;\n if (build.y \u003c 0) {\n build.y += 2700;\n }\n \n if (flash) {\n // bg.costumeId = 1;\n build.costumeId = 1;\n flash = false;\n } else {\n // bg.costumeId = 0;\n build.costumeId = 0;\n }\n}\n\n// 玩家角色動畫\nfunction updateCostume () {\n clock++;\n if (clock%5 == 0) {\n if (key.right) {\n if (player.costumeId == 1) {\n player.costumeId = 2;\n } else {\n player.costumeId = 1;\n }\n } else if (key.left) {\n if (player.costumeId == 3) {\n player.costumeId = 4;\n } else {\n player.costumeId = 3;\n }\n } else {\n player.costumeId = 0;\n }\n }\n}","created_at":"2020-04-01T14:51:37.672+08:00","updated_at":"2021-01-25T13:50:35.108+08:00","name":"小朋友下樓梯","language":"javascript","screenshot":{"url":"https://cdn7.koding.school/uploads/project/screenshot/138319/03173af630746b29f54b82d4bf658a0e.jpg"},"parent_id":2,"plugin":"Game.set({width:1200, height:900})","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":248,"hashid":"yeysd8kk","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":3036884,"file_name":"ceiling.png","project_id":138319,"asset_id":246919,"created_at":"2020-08-07T17:47:54.695+08:00","updated_at":"2020-08-07T17:47:54.695+08:00"},{"id":3036885,"file_name":"p_0.png","project_id":138319,"asset_id":246920,"created_at":"2020-08-07T17:47:54.697+08:00","updated_at":"2020-08-07T17:47:54.697+08:00"},{"id":3036896,"file_name":"sky_0.png","project_id":138319,"asset_id":246931,"created_at":"2020-08-07T17:47:57.711+08:00","updated_at":"2020-08-07T17:47:57.711+08:00"},{"id":3036897,"file_name":"sky_1.png","project_id":138319,"asset_id":246932,"created_at":"2020-08-07T17:47:57.713+08:00","updated_at":"2020-08-07T17:47:57.713+08:00"},{"id":3036886,"file_name":"p_1.png","project_id":138319,"asset_id":246921,"created_at":"2020-08-07T17:47:55.105+08:00","updated_at":"2020-08-07T17:47:55.105+08:00"},{"id":3036887,"file_name":"p_2.png","project_id":138319,"asset_id":246922,"created_at":"2020-08-07T17:47:55.107+08:00","updated_at":"2020-08-07T17:47:55.107+08:00"},{"id":3036888,"file_name":"p_3.png","project_id":138319,"asset_id":246923,"created_at":"2020-08-07T17:47:55.588+08:00","updated_at":"2020-08-07T17:47:55.588+08:00"},{"id":3036889,"file_name":"p_4.png","project_id":138319,"asset_id":246924,"created_at":"2020-08-07T17:47:55.590+08:00","updated_at":"2020-08-07T17:47:55.590+08:00"},{"id":3036900,"file_name":"gg.mp3","project_id":138319,"asset_id":36479,"created_at":"2020-08-07T18:01:40.849+08:00","updated_at":"2020-08-07T18:01:40.849+08:00"},{"id":3036903,"file_name":"jump.mp3","project_id":138319,"asset_id":36478,"created_at":"2020-08-07T18:01:42.943+08:00","updated_at":"2020-08-07T18:01:42.943+08:00"},{"id":3036892,"file_name":"s_2.png","project_id":138319,"asset_id":246927,"created_at":"2020-08-07T17:47:56.476+08:00","updated_at":"2020-08-07T17:47:56.476+08:00"},{"id":3036893,"file_name":"s_3.png","project_id":138319,"asset_id":246928,"created_at":"2020-08-07T17:47:56.478+08:00","updated_at":"2020-08-07T17:47:56.478+08:00"},{"id":3036898,"file_name":"tower_0.png","project_id":138319,"asset_id":246933,"created_at":"2020-08-07T17:47:58.620+08:00","updated_at":"2020-08-07T17:47:58.620+08:00"},{"id":3036899,"file_name":"tower_1.png","project_id":138319,"asset_id":246934,"created_at":"2020-08-07T17:47:58.622+08:00","updated_at":"2020-08-07T17:47:58.622+08:00"},{"id":3036902,"file_name":"hit.mp3","project_id":138319,"asset_id":36476,"created_at":"2020-08-07T18:01:41.962+08:00","updated_at":"2020-08-07T18:01:41.962+08:00"},{"id":3036894,"file_name":"s_4.png","project_id":138319,"asset_id":246929,"created_at":"2020-08-07T17:47:56.935+08:00","updated_at":"2020-08-07T17:47:56.935+08:00"},{"id":3036895,"file_name":"s_5.png","project_id":138319,"asset_id":246930,"created_at":"2020-08-07T17:47:56.937+08:00","updated_at":"2020-08-07T17:47:56.937+08:00"},{"id":3036901,"file_name":"bgm.mp3","project_id":138319,"asset_id":36477,"created_at":"2020-08-07T18:01:41.164+08:00","updated_at":"2020-08-07T18:01:41.164+08:00"},{"id":3036890,"file_name":"s_0.png","project_id":138319,"asset_id":246925,"created_at":"2020-08-07T17:47:56.033+08:00","updated_at":"2020-08-07T17:47:56.033+08:00"},{"id":3036891,"file_name":"s_1.png","project_id":138319,"asset_id":246926,"created_at":"2020-08-07T17:47:56.034+08:00","updated_at":"2020-08-07T17:47:56.034+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
下載 Android APP (APK)
截圖
1:1:1
1:1
full
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦