{"id":151925,"student_id":10,"content":"var bg = createSprite('bg_0.jpg', 'bg_1.jpg'); //背景圖\nvar ceiling = createSprite('w.png'); //天花板的針刺\nvar left_wall = createSprite('wall.png'); //左邊牆壁\nvar right_wall = createSprite('wall.png'); //右邊牆壁\nvar player = createSprite('p1.png', 'p2.png', 'p3.png', 'p4.png', 'p5.png'); //玩家\n\n// 初始化角色位置\u0026圖層\nplayer.y = 100;\nleft_wall.x -= 450;\nright_wall.x += 450;\nceiling.moveTo(600, 18);\nceiling.layer = 1;\n\nvar life = 10; //玩家血量\nvar floor = 0; //階梯數\nvar stairs = []; //存放階梯角色\nvar vy = 0; //玩家墜落的速度\nvar touchOn; //當前碰撞到的階梯\nvar hit = false; //是否閃爍背景\nvar clock = 0; //計時器\n\nplayer.on('touch', stairs, onTouchStair);\nforever(loop); //重複不斷執行遊戲迴圈\n\n//初始化階梯\nfor (var i = 0; i \u003c 9; i++) {\n var s = createSprite('s1.png', 's2.png', 's3.png', 's4.png', 's5.png', 's6.png');\n s.costumeId = Math.floor(Math.random()*6);\n s.x = 600 + Math.random()*500 - 250;\n s.y = i*150 + 550;\n stairs.push(s);\n}\n\nsound.play('bgm.mp3', true);\n\n//遊戲主迴圈\nfunction loop () {\n updatePlayer(); //偵測玩家操控並更新角色位置\n updateStairs(); //讓所有階梯向上捲動\n updateCostume(); //玩家走路動畫\n updateInfo(); //捲動更新背景圖\n updateBackground(); //捲動更新背景圖\n gameoverCheck(); //判斷遊戲是否結束\n}\n\n//偵測玩家操控並更新角色位置\nfunction updatePlayer () {\n if (key.left \u0026\u0026 !player.touched(left_wall)) {\n player.x -= 12;\n }\n if (key.right \u0026\u0026 !player.touched(right_wall)) {\n player.x += 12;\n }\n vy += 0.6;\n player.y += vy;\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 -30) {\n s.x = 600 + Math.random()*500 - 250;\n s.y += 1350;\n s.costumeId = Math.floor(Math.random()*6);\n s.hidden = false;\n floor += 1;\n }\n }\n}\n\n//玩家踩到階梯時執行階梯對應的功能\nfunction onTouchStair (s) {\n vy = 0;\n player.y = s.y - 50;\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 = -16;\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 hit = 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 print('分數:' + floor, 10, 10, 'white', 30);\n print('生命:' + life, 10, 40, 'while', 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 sound.play('gg.mp3');\n }\n}\n\n//捲動更新背景圖\nfunction updateBackground () {\n bg.y -= 1;\n if (bg.y \u003c 400) {\n bg.y += 100;\n }\n if (hit) {\n bg.costumeId = 1;\n hit = false;\n } else {\n bg.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":"2020-05-25T14:59:08.878+08:00","updated_at":"2020-07-03T17:04:07.903+08:00","name":"小朋友下樓梯","language":"javascript","screenshot":{"url":"https://cdn4.koding.school/uploads/project/screenshot/151925/2ea946b063fa82eb46074aaf44c7c330.jpg"},"parent_id":2,"plugin":"Game.set({width: 1200, height: 900})","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":239,"hashid":"jzms8w4p","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":2642316,"file_name":"w.png","project_id":151925,"asset_id":218294,"created_at":"2020-05-25T15:23:02.694+08:00","updated_at":"2020-05-25T15:25:18.417+08:00"},{"id":2642319,"file_name":"p1.png","project_id":151925,"asset_id":218309,"created_at":"2020-05-25T15:34:38.174+08:00","updated_at":"2020-05-25T15:34:38.174+08:00"},{"id":2642320,"file_name":"p2.png","project_id":151925,"asset_id":218310,"created_at":"2020-05-25T15:34:38.175+08:00","updated_at":"2020-05-25T15:34:38.175+08:00"},{"id":2642321,"file_name":"p3.png","project_id":151925,"asset_id":218311,"created_at":"2020-05-25T15:34:38.384+08:00","updated_at":"2020-05-25T15:34:38.384+08:00"},{"id":2642322,"file_name":"p4.png","project_id":151925,"asset_id":218312,"created_at":"2020-05-25T15:34:38.386+08:00","updated_at":"2020-05-25T15:34:38.386+08:00"},{"id":2642323,"file_name":"p5.png","project_id":151925,"asset_id":218313,"created_at":"2020-05-25T15:34:38.593+08:00","updated_at":"2020-05-25T15:34:38.593+08:00"},{"id":2642315,"file_name":"wall.png","project_id":151925,"asset_id":218306,"created_at":"2020-05-25T15:16:36.056+08:00","updated_at":"2020-05-25T15:16:36.056+08:00"},{"id":2642317,"file_name":"bg_0.jpg","project_id":151925,"asset_id":218307,"created_at":"2020-05-25T15:25:16.034+08:00","updated_at":"2020-05-25T15:25:16.034+08:00"},{"id":2642318,"file_name":"bg_1.jpg","project_id":151925,"asset_id":218308,"created_at":"2020-05-25T15:25:16.035+08:00","updated_at":"2020-05-25T15:25:16.035+08:00"},{"id":2642309,"file_name":"s1.png","project_id":151925,"asset_id":218300,"created_at":"2020-05-25T15:16:35.250+08:00","updated_at":"2020-05-25T15:16:35.250+08:00"},{"id":2642310,"file_name":"s2.png","project_id":151925,"asset_id":218301,"created_at":"2020-05-25T15:16:35.252+08:00","updated_at":"2020-05-25T15:16:35.252+08:00"},{"id":2642311,"file_name":"s3.png","project_id":151925,"asset_id":218302,"created_at":"2020-05-25T15:16:35.487+08:00","updated_at":"2020-05-25T15:16:35.487+08:00"},{"id":2642312,"file_name":"s4.png","project_id":151925,"asset_id":218303,"created_at":"2020-05-25T15:16:35.489+08:00","updated_at":"2020-05-25T15:16:35.489+08:00"},{"id":2642313,"file_name":"s5.png","project_id":151925,"asset_id":218304,"created_at":"2020-05-25T15:16:35.752+08:00","updated_at":"2020-05-25T15:16:35.752+08:00"},{"id":2642314,"file_name":"s6.png","project_id":151925,"asset_id":218305,"created_at":"2020-05-25T15:16:35.754+08:00","updated_at":"2020-05-25T15:16:35.754+08:00"},{"id":2642290,"file_name":"jump.mp3","project_id":151925,"asset_id":218281,"created_at":"2020-05-25T14:59:21.349+08:00","updated_at":"2020-05-25T14:59:21.349+08:00"},{"id":2642291,"file_name":"hit.mp3","project_id":151925,"asset_id":218282,"created_at":"2020-05-25T14:59:21.353+08:00","updated_at":"2020-05-25T14:59:21.353+08:00"},{"id":2642292,"file_name":"gg.mp3","project_id":151925,"asset_id":218283,"created_at":"2020-05-25T14:59:21.357+08:00","updated_at":"2020-05-25T14:59:21.357+08:00"},{"id":2642293,"file_name":"bgm.mp3","project_id":151925,"asset_id":218284,"created_at":"2020-05-25T14:59:21.374+08:00","updated_at":"2020-05-25T14:59:21.374+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
下載 Android APP (APK)
截圖
1:1:1
1:1
full
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦