{"id":229022,"student_id":10,"content":"Game.set({ width: 900, height: 1200 })\nsetBackdrop(\"bg.png\");\nvar stacks = [];\nvar vx = 10;\nvar balls = [];\nvar status = 'playing';\n\nrestart();\n\nfunction restart () {\n stacks.length = 0;\n stacks.push({ left: 300, right: 600, y: 750, color: randomColor() });\n stacks.push({ left: 300, right: 600, y: 800, color: randomColor() });\n vx = 10;\n status = 'playing';\n}\n\nfunction gameloop () {\n \n var top = stacks[0];\n var sec = stacks[1];\n \n if (status == 'playing') {\n if (top.left \u003e sec.left) vx -= 0.2;\n else vx += 0.2;\n top.left += vx;\n top.right += vx; \n }\n \n \n var scroll = top.y \u003c 500;\n\n for (var i = 0; i \u003c stacks.length; i++) {\n var s = stacks[i];\n var width = s.right - s.left;\n pen.size = 5;\n pen.color = 'black';\n pen.fillColor = s.color;\n pen.drawRect(s.left, s.y, width, 47.5);\n \n print(stacks.length - i, s.right + 15, s.y + 15, '#999', 40);\n \n pen.color = '#ffffff00';\n pen.fillColor = '#ffffff55';\n pen.drawRect(s.left, s.y, width, 25);\n\n if (scroll) s.y += 1;\n }\n \n for (var i = 0; i \u003c balls.length; i++) {\n var b = balls[i];\n b.x += b.vx;\n b.y += b.vy;\n pen.color = 'black';\n pen.size = 5;\n b.vy += 0.3;\n pen.fillColor = b.color;\n pen.drawCircle(b.x, b.y, 10);\n }\n}\n\nfunction onclick() {\n \n if (status == 'gameover') {\n return restart();\n }\n\n var top = stacks[0];\n var sec = stacks[1];\n \n if (top.left \u003e sec.right || top.right \u003c sec.left) {\n effects(top.right);\n status = 'gameover';\n return;\n }\n \n if (top.left \u003e sec.left) {\n top.right = sec.right;\n effects(top.right);\n } else {\n top.left = sec.left;\n effects(top.left);\n }\n \n var rand = Math.random() * 5 + 5;\n if (vx \u003e 0) vx = rand;\n else vx = -rand;\n \n var newStack = { \n left: top.left,\n right: top.right,\n y: top.y - 50,\n color: randomColor()\n }\n stacks.unshift(newStack);\n}\n\nfunction randomColor () {\n var colors = ['#affb86', '#ee8164', '#fae685', '#54a7dc', '#d17bf7'];\n var rand = Math.floor(Math.random() * 5);\n return colors[rand];\n}\n\nfunction effects (posX) {\n var top = stacks[0];\n balls.length = 0;\n for (var i=0; i\u003c20; i++) {\n balls.push({\n x: posX,\n y: top.y,\n color: randomColor(),\n vx: Math.random()*20 - 10,\n vy: Math.random()*20 - 10,\n });\n }\n}\n\non('click', onclick);\nforever(gameloop);","created_at":"2021-02-17T15:52:01.282+08:00","updated_at":"2021-02-17T18:18:52.745+08:00","name":"stack colors","language":"javascript","screenshot":{"url":"/uploads/project/screenshot/229022/c3f54e36911831b40d302588e5eee291.jpg"},"parent_id":2,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":384,"hashid":"npms348rj","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":4095981,"file_name":"Gymnopedie_No_1.mp3","project_id":229022,"asset_id":302341,"created_at":"2021-02-17T15:52:01.287+08:00","updated_at":"2021-02-17T15:52:01.287+08:00"},{"id":4095982,"file_name":"koding.png","project_id":229022,"asset_id":302340,"created_at":"2021-02-17T15:52:01.288+08:00","updated_at":"2021-02-17T15:52:01.288+08:00"},{"id":4095983,"file_name":"space_bg.jpg","project_id":229022,"asset_id":302339,"created_at":"2021-02-17T15:52:01.289+08:00","updated_at":"2021-02-17T15:52:01.289+08:00"},{"id":4095984,"file_name":"earth.png","project_id":229022,"asset_id":302338,"created_at":"2021-02-17T15:52:01.290+08:00","updated_at":"2021-02-17T15:52:01.290+08:00"},{"id":4096177,"file_name":"bg.png","project_id":229022,"asset_id":318334,"created_at":"2021-02-17T17:26:17.797+08:00","updated_at":"2021-02-17T17:26:17.797+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