{"id":238179,"student_id":10,"content":"let bg = createSprite('bg.png')\nlet monster = createSprite('monster_0.png', 'monster_1.png', 'monster_2.png');\nlet ball = createSprite('bubble.png');\nlet player = createSprite('p_0.png', 'p_1.png', 'p_2.png', 'p_3.png');\nlet item = createSprite('item_0.png', 'item_1.png', 'item_2.png');\nlet gameover = createSprite('gameover.png');\nlet blocks = [];\nlet vy = -10;\nlet score = 0;\nlet timer = 0;\nlet isProtect = false;\nmonster.y -= 3000;\nitem.y -= 1000;\nbg.layer = -2;\ngameover.hidden = true;\nplayer.rotationStyle = 'flipped';\n\n\nfor (let i=0; i\u003c20; i++) {\n let b = createSprite(\"b_0.png\", \"b_1.png\", \"b_2.png\", \"b_3.png\");\n b.x = Math.random()*1000 + 100;\n b.y = i * 50;\n b.layer = -1;\n b.scale = 1.2\n blocks.push(b);\n}\n\n//遊戲主回圈\nfunction gameloop () {\n updatePlayer() //更新使用者\n blocks.forEach(updateBlock) //更新階梯\n blocks.forEach(touchedDetect) //階梯碰撞偵測\n updateItem() //更新道具\n updateMonster() //更新怪物\n renderScore() //更新分數\n updateBackground() //捲動背景圖\n \n ball.hidden = !isProtect;\n ball.moveTo(player)\n if (cursor.isDown) restart();\n \n \n}\n\nfunction updateBackground () {\n if (vy \u003c 0 \u0026\u0026 player.y \u003c= 450) {\n bg.y -= vy;\n }\n if (bg.y \u003e 900) bg.y -= 1800;\n}\n\n//更新玩家\nfunction updatePlayer () {\n if (key.right) {\n player.x += 13;\n player.direction = 90;\n }\n if (key.left) {\n player.x -= 13;\n player.direction = 270;\n }\n if (player.x \u003c 0) player.x += 1200;\n if (player.x \u003e 1200) player.x -= 1200;\n if (vy \u003e 0 || player.y \u003e 450) player.y += vy;\n \n if (timer \u003e 0) {\n timer -= 1;\n vy = - 40;\n if (timer == 0) player.costumeId = 0;\n }\n vy += 0.6;\n \n if (player.y \u003e 1000) {\n gameover.hidden = false;\n }\n}\n\n//更新階梯\nfunction updateBlock(block) {\n if (vy \u003c 0 \u0026\u0026 player.y \u003c= 450) {\n block.y -= vy;\n }\n if (block.costumeId == 2) {\n block.x += 3;\n if (block.x \u003e 1200) block.x -= 1200;\n }\n if (block.y \u003e 900) {\n block.x = Math.random()*1000 + 100;\n block.y -= (50 + score * 1) * 20;\n block.hidden = false;\n score += 1;\n \n let rand = Math.random();\n if (rand \u003c 0.8) block.costumeId = 0;\n else if (rand \u003c 0.9) block.costumeId = 1;\n else if (rand \u003c 0.95) block.costumeId = 2;\n else block.costumeId = 3;\n }\n if (block.scale \u003e 1.2) {\n block.scale -= 0.05;\n }\n}\n\n//碰撞偵測\nfunction touchedDetect(block) {\n if (player.touched(block) \u0026\u0026 vy \u003e 0 \u0026\u0026 player.costumeId != 3) {\n vy = -20;\n if (block.costumeId == 1) vy = -40;\n if (block.costumeId == 3) {\n block.hidden = true;\n }\n block.scale = 1.5;\n }\n}\n\n//更新道具\nfunction updateItem() {\n if (vy \u003c 0 \u0026\u0026 player.y \u003c= 450) {\n item.y -= vy;\n }\n if (item.y \u003e 900) {\n item.y -= 3000 + Math.random()*1000;\n item.x = Math.random()*1000 + 100;\n item.costumeId = Math.floor(Math.random() * 3);\n item.hidden = false;\n }\n if (item.touched(player)) {\n if (item.costumeId == 0) { //竹蜻蜓\n timer = 60;\n player.costumeId = 1;\n }\n if (item.costumeId == 1) { //火箭背包\n timer = 180;\n player.costumeId = 2;\n }\n if (item.costumeId == 2) { //防護泡\n isProtect = true;\n }\n item.hidden = true;\n }\n}\n\n//更新怪物\nfunction updateMonster () {\n monster.x += 5;\n if (monster.x \u003e 1200) {\n monster.x -= 1200;\n }\n if (vy \u003c 0 \u0026\u0026 player.y \u003c= 450) {\n monster.y -= vy;\n }\n if (monster.y \u003e 900) {\n monster.y -= 4000;\n monster.x = Math.random()*1000 + 100;\n monster.costumeId = Math.floor(Math.random() * 3);\n }\n if (player.touched(monster) \u0026\u0026 vy \u003e -20) {\n if (isProtect) {\n player.costumeId = 0;\n } else {\n player.costumeId = 3;\n }\n }\n}\n\n//繪製分數\nfunction renderScore () {\n print(score, 10, 10, 'white', 30);\n}\n\nfunction restart() {\n for (let i=0; i\u003c20; i++) {\n blocks[i].y = i * 50;\n }\n vy = 0;\n score = 0;\n player.costumeId = 0;\n player.moveTo(600, 450);\n monster.y -= 3000;\n item.y -= 1000;\n gameover.hidden = true;\n}\n\ngameover.on('click', restart);\nforever(gameloop)","created_at":"2021-03-25T10:58:14.391+08:00","updated_at":"2022-11-30T19:33:55.640+08:00","name":"叩叮登頂","language":"javascript","screenshot":{"url":"/uploads/project/screenshot/238179/2b4d857736515e08aab268a25577ae18.jpg"},"parent_id":2,"plugin":"Game.set({ width: 1200, height: 900 })","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":370,"hashid":"jzmsezve2","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":6431094,"file_name":"p_3.png","project_id":238179,"asset_id":435226,"created_at":"2021-11-11T11:34:53.940+08:00","updated_at":"2021-11-11T11:34:53.940+08:00"},{"id":6431095,"file_name":"b_3.png","project_id":238179,"asset_id":435227,"created_at":"2021-11-11T11:34:53.942+08:00","updated_at":"2021-11-11T11:34:53.942+08:00"},{"id":6431100,"file_name":"item_1.png","project_id":238179,"asset_id":435229,"created_at":"2021-11-11T11:34:55.564+08:00","updated_at":"2021-11-11T11:34:55.564+08:00"},{"id":6431101,"file_name":"monster_1.png","project_id":238179,"asset_id":348796,"created_at":"2021-11-11T11:34:55.566+08:00","updated_at":"2021-11-11T11:34:55.566+08:00"},{"id":6431089,"file_name":"item_2.png","project_id":238179,"asset_id":435221,"created_at":"2021-11-11T11:34:52.229+08:00","updated_at":"2021-11-11T11:34:52.229+08:00"},{"id":6431102,"file_name":"p_0.png","project_id":238179,"asset_id":435230,"created_at":"2021-11-11T11:34:56.205+08:00","updated_at":"2021-11-11T11:34:56.205+08:00"},{"id":6431103,"file_name":"item_0.png","project_id":238179,"asset_id":435231,"created_at":"2021-11-11T11:34:56.207+08:00","updated_at":"2021-11-11T11:34:56.207+08:00"},{"id":6431088,"file_name":"bg.png","project_id":238179,"asset_id":348790,"created_at":"2021-11-11T11:34:52.227+08:00","updated_at":"2021-11-11T11:34:52.227+08:00"},{"id":6431096,"file_name":"monster_2.png","project_id":238179,"asset_id":348797,"created_at":"2021-11-11T11:34:54.478+08:00","updated_at":"2021-11-11T11:34:54.478+08:00"},{"id":6431097,"file_name":"monster_0.png","project_id":238179,"asset_id":348795,"created_at":"2021-11-11T11:34:54.480+08:00","updated_at":"2021-11-11T11:34:54.480+08:00"},{"id":6431098,"file_name":"b_2.png","project_id":238179,"asset_id":435228,"created_at":"2021-11-11T11:34:55.055+08:00","updated_at":"2021-11-11T11:34:55.055+08:00"},{"id":6431099,"file_name":"gameover.png","project_id":238179,"asset_id":348791,"created_at":"2021-11-11T11:34:55.057+08:00","updated_at":"2021-11-11T11:34:55.057+08:00"},{"id":6431090,"file_name":"b_0.png","project_id":238179,"asset_id":435222,"created_at":"2021-11-11T11:34:52.777+08:00","updated_at":"2021-11-11T11:34:52.777+08:00"},{"id":6431091,"file_name":"p_1.png","project_id":238179,"asset_id":435223,"created_at":"2021-11-11T11:34:52.779+08:00","updated_at":"2021-11-11T11:34:52.779+08:00"},{"id":6431092,"file_name":"b_1.png","project_id":238179,"asset_id":435224,"created_at":"2021-11-11T11:34:53.355+08:00","updated_at":"2021-11-11T11:34:53.355+08:00"},{"id":6431093,"file_name":"p_2.png","project_id":238179,"asset_id":435225,"created_at":"2021-11-11T11:34:53.357+08:00","updated_at":"2021-11-11T11:34:53.357+08:00"}]
Orange Apple Learning Platform
My Projects
View Project Page
Export
Remix
Import
Delete
Download Android APP (APK)
Screenshot
繁中
简中
English
日本語
1:1:1
1:1
Full Width
Scan the QRCode below with your phone to install
Or you can
download APK
to this computer
Scan the QRCode below with your phone to install
Or you can
download APK
to this computer