{"id":222680,"student_id":16,"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'); //玩家\n\nsetBackdrop(\"black\");\n\nvar life = 10; //玩家血量\nvar floor = 0; //階梯數\nvar stairs = []; //存放階梯角色\nvar vy = 0; //玩家墜落的速度\nvar touchOn; //當前碰撞到的階梯\nvar clock = 0; //計時器\nvar flash = false //是否閃爍\n\n// 初始化角色位置\u0026圖層\nceiling.y = 20;\nceiling.layer = 1;\n\nforever(loop); //重複不斷執行遊戲迴圈\nplayer.on('touch', stairs, onTouchStair);\ncreateSound('bgm.mp3', true);\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.costumeId = Math.floor(Math.random() * 6);\n s.x = 300 + Math.random() * 600;\n s.y = i * 150;\n stairs.push(s);\n}\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.x = 300 + Math.random()*600;\n s.y += 1050;\n s.costumeId = Math.floor(Math.random()*6);\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 = -9;\n sound.play('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 sound.play('hit.mp3');\n }\n if (s.costumeId == 5 \u0026\u0026 s != touchOn) {\n setTimeout(function() {\n s.hidden = true\n }, 300);\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 build.costumeId = 1;\n stop();\n sound.play('gg.mp3');\n }\n}\n\n// 更新背景動畫\nfunction updateBackground () {\n bg.y -= 0.2;\n if (bg.y \u003c -900) {\n bg.y += 1800;\n }\n \n build.y -= 3;\n if (build.y \u003c -1800) {\n build.y += 2700;\n }\n \n if (flash) {\n bg.costumeId = 1;\n build.costumeId = 1;\n setTimeout(function() {\n flash = false;\n }, 200);\n } else {\n bg.costumeId = 0;\n build.costumeId = 0;\n }\n}\n\n//玩家走路動畫\nfunction updateCostume () {\n clock++;\n if (clock % 4 == 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":"2021-01-25T21:12:59.522+08:00","updated_at":"2021-01-26T15:06:09.187+08:00","name":"小朋友下樓梯完整版","language":"javascript","screenshot":{"url":"https://cdn1.koding.school/uploads/project/screenshot/222680/ac6e86ac03240e91679619ffaa1b6346.jpg"},"parent_id":138319,"plugin":"Game.set({width:1200, height:900})","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":67,"hashid":"npms34d2j","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":3967083,"file_name":"ceiling.png","project_id":222680,"asset_id":246919,"created_at":"2021-01-25T21:12:59.529+08:00","updated_at":"2021-01-25T21:12:59.529+08:00"},{"id":3967084,"file_name":"p_0.png","project_id":222680,"asset_id":246920,"created_at":"2021-01-25T21:12:59.530+08:00","updated_at":"2021-01-25T21:12:59.530+08:00"},{"id":3967085,"file_name":"sky_0.png","project_id":222680,"asset_id":246931,"created_at":"2021-01-25T21:12:59.531+08:00","updated_at":"2021-01-25T21:12:59.531+08:00"},{"id":3967086,"file_name":"sky_1.png","project_id":222680,"asset_id":246932,"created_at":"2021-01-25T21:12:59.532+08:00","updated_at":"2021-01-25T21:12:59.532+08:00"},{"id":3967087,"file_name":"p_1.png","project_id":222680,"asset_id":246921,"created_at":"2021-01-25T21:12:59.533+08:00","updated_at":"2021-01-25T21:12:59.533+08:00"},{"id":3967088,"file_name":"p_2.png","project_id":222680,"asset_id":246922,"created_at":"2021-01-25T21:12:59.534+08:00","updated_at":"2021-01-25T21:12:59.534+08:00"},{"id":3967089,"file_name":"p_3.png","project_id":222680,"asset_id":246923,"created_at":"2021-01-25T21:12:59.535+08:00","updated_at":"2021-01-25T21:12:59.535+08:00"},{"id":3967090,"file_name":"p_4.png","project_id":222680,"asset_id":246924,"created_at":"2021-01-25T21:12:59.536+08:00","updated_at":"2021-01-25T21:12:59.536+08:00"},{"id":3967091,"file_name":"gg.mp3","project_id":222680,"asset_id":36479,"created_at":"2021-01-25T21:12:59.537+08:00","updated_at":"2021-01-25T21:12:59.537+08:00"},{"id":3967092,"file_name":"jump.mp3","project_id":222680,"asset_id":36478,"created_at":"2021-01-25T21:12:59.554+08:00","updated_at":"2021-01-25T21:12:59.554+08:00"},{"id":3967093,"file_name":"s_2.png","project_id":222680,"asset_id":246927,"created_at":"2021-01-25T21:12:59.555+08:00","updated_at":"2021-01-25T21:12:59.555+08:00"},{"id":3967094,"file_name":"s_3.png","project_id":222680,"asset_id":246928,"created_at":"2021-01-25T21:12:59.556+08:00","updated_at":"2021-01-25T21:12:59.556+08:00"},{"id":3967095,"file_name":"tower_0.png","project_id":222680,"asset_id":246933,"created_at":"2021-01-25T21:12:59.557+08:00","updated_at":"2021-01-25T21:12:59.557+08:00"},{"id":3967096,"file_name":"tower_1.png","project_id":222680,"asset_id":246934,"created_at":"2021-01-25T21:12:59.558+08:00","updated_at":"2021-01-25T21:12:59.558+08:00"},{"id":3967097,"file_name":"hit.mp3","project_id":222680,"asset_id":36476,"created_at":"2021-01-25T21:12:59.559+08:00","updated_at":"2021-01-25T21:12:59.559+08:00"},{"id":3967098,"file_name":"s_4.png","project_id":222680,"asset_id":246929,"created_at":"2021-01-25T21:12:59.560+08:00","updated_at":"2021-01-25T21:12:59.560+08:00"},{"id":3967099,"file_name":"s_5.png","project_id":222680,"asset_id":246930,"created_at":"2021-01-25T21:12:59.561+08:00","updated_at":"2021-01-25T21:12:59.561+08:00"},{"id":3967100,"file_name":"bgm.mp3","project_id":222680,"asset_id":36477,"created_at":"2021-01-25T21:12:59.562+08:00","updated_at":"2021-01-25T21:12:59.562+08:00"},{"id":3967101,"file_name":"s_0.png","project_id":222680,"asset_id":246925,"created_at":"2021-01-25T21:12:59.563+08:00","updated_at":"2021-01-25T21:12:59.563+08:00"},{"id":3967102,"file_name":"s_1.png","project_id":222680,"asset_id":246926,"created_at":"2021-01-25T21:12:59.564+08:00","updated_at":"2021-01-25T21:12:59.564+08:00"}]
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
下載 Android APP (APK)
截圖
繁中
简中
English
日本語
1:1:1
1:1
全寬
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦