{"id":237969,"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\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 items = []; //石頭和紅蘿蔔\nlet pigs = []; //野豬\nlet bulls = []; //野牛\nlet bgm = //createSound('bgm.mp3', true);\n\nplayer.rotationStyle = 'flipped';\nend.hidden = true;\n\nplayer.layer = 1;\ninfo.layer = 2;\nend.layer = 2;\n\nnum1.moveTo(40, 50);\nnum2.moveTo(110, 50);\nnum3.moveTo(180, 50);\nnum4.moveTo(250, 50);\nnum1.layer = num2.layer = num3.layer = num4.layer = 3;\n\n// 創造 9 個石頭(或紅蘿蔔)\nfor (let i = 0; i \u003c 10; i++) {\n let s = createSprite('rock.png', 'carrot.png');\n items.push(s);\n}\n\n// 創造 10 隻野豬\nfor (let i = 0; i \u003c 10; i++) {\n let s = createSprite('pig_0.png', 'pig_1.png');\n pigs.push(s);\n}\n// 創造 5 隻野牛\nfor (let i = 0; i \u003c 5; i++) {\n let s = createSprite('bull_0.png', 'bull_1.png');\n bulls.push(s);\n}\n\n// // 初始化或重新開始\nfunction reset () {\n\n for (let i = 0; i \u003c 10; i++) {\n items[i].x = 150;\n items[i].y = i * 100 + 50 - 1000;\n items[i].x = 150 + Math.floor(Math.random() * 10) * 100;\n items[i].costumeId = Math.floor(Math.random() * 2);\n }\n\n for (let i = 0; i \u003c 10; i++) {\n pigs[i].x = i * 100 + 150;\n pigs[i].y = 100;\n pigs[i].y = Math.random() * 3000 + 1000;\n }\n\n for (let i = 0; i \u003c 5; i++) {\n bulls[i].x = 50;\n bulls[i].x = -Math.random() * 3000 - 1000;\n bulls[i].y = i * 100 + 50;\n }\n\n bg.y = 500;\n water.y = 1750;\n player.moveTo(650, 750);\n score = 0; // 分數歸零\n speed = 2; // 速度設為 2\n}\n\n// 遊戲迴圈\nfunction gameloop () {\n if (end.hidden \u0026\u0026 info.hidden) {\n updateGround(); // 移動背景和河流\n updatePlayer(); // 移動兔子\n items.forEach(updateItem); // 移動石頭與紅蘿蔔\n pigs.forEach(updatePig); // 移動野豬\n bulls.forEach(updateBull); // 移動野牛\n updateScore(); // 更新分數\n speed += 1/3600;\n }\n if (key.enter \u0026\u0026 end.hidden == false) {\n end.hidden = true;\n reset();\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(3); //掉到水裡0\n }\n}\n\n// 更新玩家\nfunction updatePlayer () {\n player.y += speed;\n if (player.y \u003e 950 || player.y \u003c -50) {\n gameover(4); //掉到洞裡\n }\n player.costumeId = player.y % 100 \u003e 50 ? 1: 0;\n}\n\n// 更新石頭和紅蘿蔔\nfunction updateItem (s) {\n s.y += speed;\n if (s.y \u003e 950) {\n s.y -= 1000;\n s.x = 150 + Math.floor(Math.random() * 10) * 100;\n // s.costumeId = Math.floor(Math.random() * 2);\n s.hidden = false;\n }\n if (player.touched(s)) {\n if (s.costumeId == 0) {\n gameover(0); //撞到石頭\n } else {\n s.hidden = true;\n score += 30;\n //createSound('coin.wav');\n }\n }\n}\n\n// 更新野豬\nfunction updatePig (s) {\n s.y -= speed;\n if (s.y \u003c -100) {\n s.y += 1100 + Math.random() * 2000;\n }\n if (player.touched(s) \u0026\u0026 player.y \u003c s.y) {\n gameover(1);\n }\n s.costumeId = s.y % 100 \u003c 50 ? 0: 1;\n}\n\n// 更新野牛\nfunction updateBull (s) {\n s.y += speed;\n s.x += speed * 2;\n if (s.y \u003e 900) s.y -= 4000;\n if (s.x \u003e 1300) s.x -= 1400 + Math.random() * 2000;\n\n if (player.touched(s) \u0026\u0026 player.x \u003e s.x) {\n gameover(2);\n }\n s.costumeId = s.y % 100 \u003c 50 ? 0: 1;\n}\n\n// 遊戲結束\nfunction gameover (type) {\n end.hidden = false;\n end.costumeId = type;\n end.y = -450;\n //createSound('hit.wav');\n}\n\n// 右鍵按下\nfunction moveLeft () {\n if (end.hidden) {\n player.y -= 100;\n if (player.x \u003e 150) player.x -= 100;\n player.direction = 270;\n info.hidden = true;\n //createSound('jump.wav');\n }\n}\n\n// 左鍵按下\nfunction moveRight () {\n if (end.hidden) {\n player.y -= 100;\n if (player.x \u003c 1050) player.x += 100;\n player.direction = 90;\n info.hidden = true;\n //createSound('jump.wav');\n }\n}\n\n// 更新分數角色\nfunction updateScore () {\n score += speed / 100;\n let s = Math.floor(score);\n // drawText(s, 10, 10, 'black', 100);\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-03-23T14:31:19.791+08:00","updated_at":"2021-12-06T11:58:26.467+08:00","name":"小兔子大進擊(完整版)","language":"javascript","screenshot":{"url":"https://cdn8.koding.school/uploads/project/screenshot/237969/b230fa3bcc0fafe3f75ee57f07ce202f.jpg"},"parent_id":2,"plugin":"Game.set({width: 1200, height: 900})","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":316,"hashid":"npms3wv6p","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":4407704,"file_name":"eat.wav","project_id":237969,"asset_id":333646,"created_at":"2021-04-01T16:09:08.145+08:00","updated_at":"2021-04-01T16:09:08.145+08:00"},{"id":4407708,"file_name":"coin.wav","project_id":237969,"asset_id":246652,"created_at":"2021-04-01T16:21:39.929+08:00","updated_at":"2021-04-01T16:21:39.929+08:00"},{"id":4407706,"file_name":"jump.wav","project_id":237969,"asset_id":333648,"created_at":"2021-04-01T16:10:44.824+08:00","updated_at":"2021-04-01T16:10:44.824+08:00"},{"id":4407707,"file_name":"bgm.mp3","project_id":237969,"asset_id":333652,"created_at":"2021-04-01T16:15:48.828+08:00","updated_at":"2021-04-01T16:15:48.828+08:00"},{"id":4407709,"file_name":"hit.wav","project_id":237969,"asset_id":333656,"created_at":"2021-04-01T16:23:33.502+08:00","updated_at":"2021-04-01T16:23:33.502+08:00"},{"id":5179126,"file_name":"7.png","project_id":237969,"asset_id":373198,"created_at":"2021-07-02T18:13:40.693+08:00","updated_at":"2021-07-02T18:20:49.288+08:00"},{"id":5179125,"file_name":"8.png","project_id":237969,"asset_id":373197,"created_at":"2021-07-02T18:13:40.691+08:00","updated_at":"2021-07-02T18:20:52.453+08:00"},{"id":5179137,"file_name":"end_2.png","project_id":237969,"asset_id":373209,"created_at":"2021-07-02T18:13:43.277+08:00","updated_at":"2021-07-02T18:13:43.277+08:00"},{"id":5179138,"file_name":"end_1.png","project_id":237969,"asset_id":373210,"created_at":"2021-07-02T18:13:43.279+08:00","updated_at":"2021-07-02T18:13:43.279+08:00"},{"id":5179139,"file_name":"end_0.png","project_id":237969,"asset_id":373211,"created_at":"2021-07-02T18:13:43.878+08:00","updated_at":"2021-07-02T18:13:43.878+08:00"},{"id":5179132,"file_name":"1.png","project_id":237969,"asset_id":373204,"created_at":"2021-07-02T18:13:41.882+08:00","updated_at":"2021-07-02T18:20:27.875+08:00"},{"id":5179131,"file_name":"2.png","project_id":237969,"asset_id":373203,"created_at":"2021-07-02T18:13:41.881+08:00","updated_at":"2021-07-02T18:20:31.596+08:00"},{"id":5179130,"file_name":"3.png","project_id":237969,"asset_id":373202,"created_at":"2021-07-02T18:13:41.464+08:00","updated_at":"2021-07-02T18:20:35.050+08:00"},{"id":5179129,"file_name":"4.png","project_id":237969,"asset_id":373201,"created_at":"2021-07-02T18:13:41.463+08:00","updated_at":"2021-07-02T18:20:38.426+08:00"},{"id":5179128,"file_name":"5.png","project_id":237969,"asset_id":373200,"created_at":"2021-07-02T18:13:41.095+08:00","updated_at":"2021-07-02T18:20:42.765+08:00"},{"id":5179127,"file_name":"6.png","project_id":237969,"asset_id":373199,"created_at":"2021-07-02T18:13:41.093+08:00","updated_at":"2021-07-02T18:20:46.436+08:00"},{"id":5179140,"file_name":"carrot.png","project_id":237969,"asset_id":373212,"created_at":"2021-07-02T18:13:43.879+08:00","updated_at":"2021-07-02T18:13:43.879+08:00"},{"id":5179117,"file_name":"water.png","project_id":237969,"asset_id":333612,"created_at":"2021-07-02T18:13:39.023+08:00","updated_at":"2021-07-02T18:13:39.023+08:00"},{"id":5179118,"file_name":"rock.png","project_id":237969,"asset_id":333611,"created_at":"2021-07-02T18:13:39.025+08:00","updated_at":"2021-07-02T18:13:39.025+08:00"},{"id":5179135,"file_name":"end_4.png","project_id":237969,"asset_id":373207,"created_at":"2021-07-02T18:13:42.859+08:00","updated_at":"2021-07-02T18:13:42.859+08:00"},{"id":5179136,"file_name":"end_3.png","project_id":237969,"asset_id":373208,"created_at":"2021-07-02T18:13:42.861+08:00","updated_at":"2021-07-02T18:13:42.861+08:00"},{"id":5179119,"file_name":"player.png","project_id":237969,"asset_id":333610,"created_at":"2021-07-02T18:13:39.469+08:00","updated_at":"2021-07-02T18:13:39.469+08:00"},{"id":5179120,"file_name":"player_1.png","project_id":237969,"asset_id":373194,"created_at":"2021-07-02T18:13:39.470+08:00","updated_at":"2021-07-02T18:13:39.470+08:00"},{"id":5179123,"file_name":"pig_0.png","project_id":237969,"asset_id":333608,"created_at":"2021-07-02T18:13:40.308+08:00","updated_at":"2021-07-02T18:13:40.308+08:00"},{"id":5179124,"file_name":"9.png","project_id":237969,"asset_id":373196,"created_at":"2021-07-02T18:13:40.310+08:00","updated_at":"2021-07-02T18:20:55.546+08:00"},{"id":5179121,"file_name":"player_0.png","project_id":237969,"asset_id":373195,"created_at":"2021-07-02T18:13:39.880+08:00","updated_at":"2021-07-02T18:13:39.880+08:00"},{"id":5179122,"file_name":"pig_1.png","project_id":237969,"asset_id":333609,"created_at":"2021-07-02T18:13:39.882+08:00","updated_at":"2021-07-02T18:13:39.882+08:00"},{"id":5179141,"file_name":"bull_1.png","project_id":237969,"asset_id":373213,"created_at":"2021-07-02T18:13:44.243+08:00","updated_at":"2021-07-02T18:13:44.243+08:00"},{"id":5179142,"file_name":"bull_0.png","project_id":237969,"asset_id":373214,"created_at":"2021-07-02T18:13:44.244+08:00","updated_at":"2021-07-02T18:13:44.244+08:00"},{"id":5179133,"file_name":"0.png","project_id":237969,"asset_id":373205,"created_at":"2021-07-02T18:13:42.398+08:00","updated_at":"2021-07-02T18:20:24.138+08:00"},{"id":6569837,"file_name":"bg.png","project_id":237969,"asset_id":441648,"created_at":"2021-11-24T16:12:54.246+08:00","updated_at":"2021-11-24T16:12:54.246+08:00"},{"id":6749623,"file_name":"info.png","project_id":237969,"asset_id":446048,"created_at":"2021-12-06T11:22:30.666+08:00","updated_at":"2021-12-06T11:22:30.666+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
下載 Android APP (APK)
截圖
1:1:1
1:1
full
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦