{"id":320677,"student_id":10,"content":"let bg = createSprite('bg.png'); //背景角色\nlet water = createSprite('water.png'); //水角色\nlet player = createSprite('player_0.png', 'player_1.png'); //兔子\nlet info = createSprite('info.png'); //遊戲說明\nlet end = createSprite('end_0.png', 'end_1.png', 'end_2.png', 'end_3.png', 'end_4.png'); //遊戲失敗圖\n\nlet numbers = ['0.png', '1.png', '2.png', '3.png', '4.png', '5.png', '6.png', '7.png', '8.png', '9.png'];\nlet num1 = createSprite(numbers); //千位\nlet num2 = createSprite(numbers); //百位\nlet num3 = createSprite(numbers); //個位\nlet num4 = createSprite(numbers); //十位\n\nlet score = 0; //分數\nlet speed = 0; //速度\nlet rocks = []; //石頭和紅蘿蔔\nlet pigs = []; //野豬\nlet bulls = []; //野牛\n\nnum1.moveTo(50, 70);\nnum2.moveTo(120, 70);\nnum3.moveTo(190, 70);\nnum4.moveTo(260, 70);\n\nplayer.rotationStyle = 'flipped';\nplayer.layer = 1;\ninfo.layer = 2;\nend.layer = 2;\nend.hidden = true; //預設隱藏結束圖\n\ncreateSound('bgm.mp3', true);\n\n//創造 10 個石頭(或紅蘿蔔)\nfor (let i = 0; i \u003c 10; i++) {\n rocks[i] = createSprite('rock.png', 'carrot.png');\n}\n\n//創造 10 隻野豬\nfor (let i = 0; i \u003c 10; i++) {\n pigs[i] = createSprite('pig_0.png', 'pig_1.png');\n}\n\n//創造 5 隻野牛\nfor (let i = 0; i \u003c 5; i++) {\n bulls[i] = createSprite('bull_0.png', 'bull_1.png');\n}\n\n//初始化或重新開始\nfunction reset () {\n\n //重置石頭的位置\n for (let i = 0; i \u003c 10; i++) {\n rocks[i].x = 150 + Math.floor(Math.random() * 10) * 100;\n rocks[i].y = i * 100 + 50 - 1000;\n rocks[i].costumeId = Math.floor(Math.random() * 2);\n }\n\n //重置野豬的位置\n for (let i = 0; i \u003c 10; i++) {\n pigs[i].x = i * 100 + 150;\n pigs[i].y = 50 + 1000 + Math.random() * 3000;\n }\n\n //重置野牛的位置\n for (let i = 0; i \u003c 5; i++) {\n bulls[i].x = 50 - 100 - Math.random() * 3000;\n bulls[i].y = i * 100 + 50;\n }\n\n score = 0; //重置分數\n speed = 2; //重置速度\n bg.y = 500; //重置背景位置\n water.y = 2250; //重置河流位置\n player.moveTo(650, 750); //重置玩家位置\n}\n\n//遊戲迴圈\nfunction gameloop () {\n if (info.hidden \u0026\u0026 end.hidden) {\n updateGround(); //移動背景和河流\n updatePlayer(); //移動兔子\n rocks.forEach(updateRock); //移動石頭與紅蘿蔔\n pigs.forEach(updatePig); //移動野豬\n bulls.forEach(updateBull); //移動野牛\n updateScore(); //更新分數\n speed += 1 / 3600;\n }\n\n //按下 enter 且遊戲說明圖未隱藏\n if (key.enter \u0026\u0026 end.hidden == false) {\n end.hidden = true; //隱藏說明\n reset(); //重置所有角色位置\n }\n\n if (end.y \u003c 450) end.y += 30; //結束圖向下滑至中央\n}\n\n//更新背景圖\nfunction updateGround () {\n bg.y += speed; //背景向下捲動\n water.y += speed; //池塘向下捲動\n if (bg.y \u003e 1200) bg.y -= 4000; //重置背景\n if (water.y \u003e 1200) water.y -= 4000; //重置池塘\n // 如果碰到池塘時\n if (player.touched(water)) {\n gameover(4);\n }\n}\n\n//更新玩家\nfunction updatePlayer () {\n player.y += speed; //根據速度向下移動\n // 如果超出下面或上面邊界時\n if (player.y \u003e 950 || player.y \u003c -50) {\n gameover(3);\n }\n player.costumeId = player.y % 100 \u003c 50 ? 0 : 1; //走路動畫\n}\n\n//更新石頭(或紅蘿蔔)\nfunction updateRock (s) {\n s.y += speed;\n // 當移動超出下面邊界\n if (s.y \u003e 950) {\n s.y -= 1000;\n s.x = 150 + Math.floor(Math.random() * 10) * 100;\n s.hidden = false;\n }\n if (player.touched(s)) {\n if (s.costumeId == 1) { //紅蘿蔔造型\n score += 30;\n s.hidden = true;\n createSound('eat.mp3');\n } else { //撞到石頭時\n gameover(0);\n }\n }\n}\n\n//更新野豬\nfunction updatePig (s) {\n s.y -= speed; // 不斷向上移動\n // 當移動超出上面邊界\n if (s.y \u003c -100) {\n s.y += 1100 + Math.random() * 3000;\n }\n // 如果豬牛從下面撞到玩家\n if (player.touched(s) \u0026\u0026 player.y \u003c s.y) {\n gameover(1);\n }\n s.costumeId = player.y % 100 \u003c 50 ? 0 : 1;\n}\n\n//更新野牛\nfunction updateBull (s) {\n s.y += speed; // 不斷向下移動\n s.x += speed * 2; // 不斷向右移動\n // 當移動超出右邊邊界\n if (s.x \u003e 1300) {\n s.x -= 1400 + Math.random() * 3000;\n }\n // 當移動超出左邊邊界\n if (s.y \u003e 900) {\n s.y -= 4000;\n }\n // 如果野牛從左邊撞到玩家\n if (player.touched(s) \u0026\u0026 player.x \u003e s.x) {\n gameover(2);\n }\n s.costumeId = player.y % 100 \u003c 50 ? 0 : 1; //走路動畫\n}\n\n//遊戲結束\nfunction gameover (type) {\n end.costumeId = type;\n end.hidden = false;\n end.y = -450;\n createSound('fail.mp3');\n}\n\n//左鍵按下\nfunction moveLeft () {\n if (end.hidden) {\n player.y -= 100; //向上一格\n if (player.x \u003e 200) player.x -= 100; //向左一格\n player.direction = 270; //面向左邊\n info.hidden = true; //隱藏說明圖\n createSound('jump.mp3'); //播放音效\n }\n}\n\n//右鍵按下\nfunction moveRight () {\n if (end.hidden) {\n player.y -= 100; //向上一格\n if (player.x \u003c 1000) player.x += 100; //向右一格\n player.direction = 90; //面向右邊\n info.hidden = true; //隱藏說明圖\n createSound('jump.mp3'); //播放音效\n }\n}\n\n//更新分數角色\nfunction updateScore () {\n score += speed / 100; // 每移動 1 格分數加 1\n let s = Math.floor(score); // 去除分數小數點後\n num1.costumeId = Math.floor(s / 1000) % 10;\n num2.costumeId = Math.floor(s / 100) % 10;\n num3.costumeId = Math.floor(s / 10) % 10;\n num4.costumeId = Math.floor(s / 1) % 10;\n}\n\nforever(gameloop); //不斷執行遊戲迴圈\non('keydown', 'left', moveLeft); //當左按按下時\non('keydown', 'right', moveRight); //當右按按下時\nreset(); //初始化遊戲角色","created_at":"2021-12-03T16:59:01.687+08:00","updated_at":"2022-09-30T11:05:44.324+08:00","name":"小兔子大進擊(預設版)接著錄製","language":"javascript","screenshot":{"url":"https://cdn7.koding.school/uploads/project/screenshot/320677/36428f5cfda7172b4a46bc5a55a27c58.jpg"},"parent_id":237969,"plugin":"Game.set({width: 1200, height: 900})","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":170,"hashid":"wdks4jjw9","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":6749800,"file_name":"pig_0.png","project_id":320677,"asset_id":446069,"created_at":"2021-12-06T17:34:05.196+08:00","updated_at":"2021-12-06T17:34:05.196+08:00"},{"id":6749801,"file_name":"9.png","project_id":320677,"asset_id":446070,"created_at":"2021-12-06T17:34:05.200+08:00","updated_at":"2021-12-06T17:34:05.200+08:00"},{"id":6749802,"file_name":"8.png","project_id":320677,"asset_id":446071,"created_at":"2021-12-06T17:34:05.204+08:00","updated_at":"2021-12-06T17:34:05.204+08:00"},{"id":6749803,"file_name":"7.png","project_id":320677,"asset_id":446072,"created_at":"2021-12-06T17:34:05.207+08:00","updated_at":"2021-12-06T17:34:05.207+08:00"},{"id":6749804,"file_name":"6.png","project_id":320677,"asset_id":446073,"created_at":"2021-12-06T17:34:05.211+08:00","updated_at":"2021-12-06T17:34:05.211+08:00"},{"id":6749805,"file_name":"5.png","project_id":320677,"asset_id":446074,"created_at":"2021-12-06T17:34:05.215+08:00","updated_at":"2021-12-06T17:34:05.215+08:00"},{"id":6749806,"file_name":"4.png","project_id":320677,"asset_id":446075,"created_at":"2021-12-06T17:34:05.218+08:00","updated_at":"2021-12-06T17:34:05.218+08:00"},{"id":6749807,"file_name":"3.png","project_id":320677,"asset_id":446076,"created_at":"2021-12-06T17:34:05.222+08:00","updated_at":"2021-12-06T17:34:05.222+08:00"},{"id":6749808,"file_name":"2.png","project_id":320677,"asset_id":446077,"created_at":"2021-12-06T17:34:05.226+08:00","updated_at":"2021-12-06T17:34:05.226+08:00"},{"id":6749809,"file_name":"1.png","project_id":320677,"asset_id":446078,"created_at":"2021-12-06T17:34:05.229+08:00","updated_at":"2021-12-06T17:34:05.229+08:00"},{"id":6749812,"file_name":"end_2.png","project_id":320677,"asset_id":446081,"created_at":"2021-12-06T17:34:05.257+08:00","updated_at":"2021-12-06T17:34:05.257+08:00"},{"id":6749813,"file_name":"end_1.png","project_id":320677,"asset_id":446082,"created_at":"2021-12-06T17:34:05.261+08:00","updated_at":"2021-12-06T17:34:05.261+08:00"},{"id":6749814,"file_name":"end_0.png","project_id":320677,"asset_id":446083,"created_at":"2021-12-06T17:34:05.265+08:00","updated_at":"2021-12-06T17:34:05.265+08:00"},{"id":6749815,"file_name":"carrot.png","project_id":320677,"asset_id":446084,"created_at":"2021-12-06T17:34:05.268+08:00","updated_at":"2021-12-06T17:34:05.268+08:00"},{"id":6749816,"file_name":"bull_1.png","project_id":320677,"asset_id":446085,"created_at":"2021-12-06T17:34:05.272+08:00","updated_at":"2021-12-06T17:34:05.272+08:00"},{"id":6749817,"file_name":"bull_0.png","project_id":320677,"asset_id":446086,"created_at":"2021-12-06T17:34:05.276+08:00","updated_at":"2021-12-06T17:34:05.276+08:00"},{"id":6749818,"file_name":"0.png","project_id":320677,"asset_id":446087,"created_at":"2021-12-06T17:34:05.280+08:00","updated_at":"2021-12-06T17:34:05.280+08:00"},{"id":6749819,"file_name":"bg.png","project_id":320677,"asset_id":446088,"created_at":"2021-12-06T17:34:05.405+08:00","updated_at":"2021-12-06T17:34:05.405+08:00"},{"id":6749810,"file_name":"end_3.png","project_id":320677,"asset_id":446079,"created_at":"2021-12-06T17:34:05.233+08:00","updated_at":"2021-12-06T17:35:26.106+08:00"},{"id":6749811,"file_name":"end_4.png","project_id":320677,"asset_id":446080,"created_at":"2021-12-06T17:34:05.253+08:00","updated_at":"2021-12-06T17:35:29.259+08:00"},{"id":6749789,"file_name":"jump.mp3","project_id":320677,"asset_id":446058,"created_at":"2021-12-06T17:34:05.119+08:00","updated_at":"2021-12-06T17:34:05.119+08:00"},{"id":6749790,"file_name":"fail.mp3","project_id":320677,"asset_id":446059,"created_at":"2021-12-06T17:34:05.128+08:00","updated_at":"2021-12-06T17:34:05.128+08:00"},{"id":6749791,"file_name":"eat.mp3","project_id":320677,"asset_id":446060,"created_at":"2021-12-06T17:34:05.132+08:00","updated_at":"2021-12-06T17:34:05.132+08:00"},{"id":6749792,"file_name":"info.png","project_id":320677,"asset_id":446061,"created_at":"2021-12-06T17:34:05.136+08:00","updated_at":"2021-12-06T17:34:05.136+08:00"},{"id":6749793,"file_name":"bgm.mp3","project_id":320677,"asset_id":446062,"created_at":"2021-12-06T17:34:05.169+08:00","updated_at":"2021-12-06T17:34:05.169+08:00"},{"id":6749794,"file_name":"water.png","project_id":320677,"asset_id":446063,"created_at":"2021-12-06T17:34:05.174+08:00","updated_at":"2021-12-06T17:34:05.174+08:00"},{"id":6749795,"file_name":"rock.png","project_id":320677,"asset_id":446064,"created_at":"2021-12-06T17:34:05.178+08:00","updated_at":"2021-12-06T17:34:05.178+08:00"},{"id":6749796,"file_name":"player.png","project_id":320677,"asset_id":446065,"created_at":"2021-12-06T17:34:05.181+08:00","updated_at":"2021-12-06T17:34:05.181+08:00"},{"id":6749797,"file_name":"player_1.png","project_id":320677,"asset_id":446066,"created_at":"2021-12-06T17:34:05.185+08:00","updated_at":"2021-12-06T17:34:05.185+08:00"},{"id":6749798,"file_name":"player_0.png","project_id":320677,"asset_id":446067,"created_at":"2021-12-06T17:34:05.188+08:00","updated_at":"2021-12-06T17:34:05.188+08:00"},{"id":6749799,"file_name":"pig_1.png","project_id":320677,"asset_id":446068,"created_at":"2021-12-06T17:34:05.192+08:00","updated_at":"2021-12-06T17:34:05.192+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
下載 Android APP (APK)
截圖
1:1:1
1:1
full
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦