{"id":11064,"student_id":10,"content":"setBackdrop(\"bg.jpg\",0, 0, 640, 480);\nvar paCard = createSprite(\"paCard.png\");\npaCard.moveTo(180,70);\nvar zeroCard = createSprite(\"zeroCard.png\");\nzeroCard.moveTo(260,70);\nvar mushCard = createSprite(\"mushroomCard.png\");\nmushCard.moveTo(340,70);\nvar kodingCard = createSprite(\"kodingCard.png\");\nkodingCard.moveTo(420,70);\nvar bunker01 = createSprite(\"bunker.png\");\nbunker01.moveTo(35,180);\nvar bunker02 = createSprite(\"bunker.png\");\nbunker02.moveTo(35,260);\nvar bunker03 = createSprite(\"bunker.png\");\nbunker03.moveTo(35,340);\nvar bunker04 = createSprite(\"bunker.png\");\nbunker04.moveTo(35,420);\nvar shovelCard = createSprite(\"shovel.png\");\nshovelCard.moveTo(535,70);\nvar role_position = [\n [\"null\",\"null\",\"null\",\"null\",\"null\",\"null\",\"null\",\"null\",\"null\"],\n [\"null\",\"null\",\"null\",\"null\",\"null\",\"null\",\"null\",\"null\",\"null\"],\n [\"null\",\"null\",\"null\",\"null\",\"null\",\"null\",\"null\",\"null\",\"null\"],\n [\"null\",\"null\",\"null\",\"null\",\"null\",\"null\",\"null\",\"null\",\"null\"]\n];\nvar countMush = 180;\nvar standard_x = [95,155,215,275,335,395,455,515,575];\nvar standard_y = [180,260,340,420];\nvar clock = 0;\n\n\nforever(function(){\n print(countMush,50,105,\"#004d40\",13);\n clock += 1;\n if(clock%300 == 0){\n createEnemy();\n }\n});\n\n// regular mushroom produce\nsetInterval(function(){\n var mushroom = createSprite(\"mushroom(s).png\");\n mushroom.moveTo(200+Math.random()*200 ,140);\n mushroom.hidden = false;\n mushroom.forever(function(){\n this.y += 0.2;\n if(this.y \u003e 400){\n mushroom.hidden = true;\n }\n });\n mushroom.on(\"click\", function(){\n countMush+=10;\n mushroom.hidden = true;\n });\n},10000);\n\nfunction createMush(mushplant){\n var mushroom = createSprite(\"mushroom(s).png\");\n mushroom.moveTo(mushplant.x+Math.random()*30 ,mushplant.y-Math.random()*30);\n mushroom.hidden = false;\n mushroom.forever(function(){\n mushroom.y += 0.2;\n if(mushroom.y \u003e 400){\n mushroom.hidden = true;\n }\n });\n mushroom.on(\"click\", function(){\n countMush+=10;\n mushroom.hidden = true;\n });\n}\n\nmushCard.on(\"click\", function(){\n if(countMush \u003e= 20){\n var mushPlant = createSprite(\"mushroom.png\");\n var fixed = false;\n var had_position = false;\n var timer = 0;\n mushPlant.forever(function(){\n if(cursor.isDown==false \u0026\u0026 fixed == false){\n mushPlant.moveTo(cursor);\n }else if(had_position==false \u0026\u0026 fixed ==false){\n had_position = set_postion(this);\n }else{\n fixed = true;\n timer += 1;\n if(timer%1000 == 0){\n createMush(this);\n } \n }\n });\n countMush -=20;\n }\n});\n\npaCard.on(\"click\", function(){\n if(countMush \u003e= 80){\n var pa = createSprite([\"pa01.png\",\"pa02.png\"]);\n var fixed = false;\n var had_position = false;\n var timer = 0;\n pa.forever(function(){\n if(cursor.isDown==false \u0026\u0026 fixed == false){\n pa.moveTo(cursor);\n }else if(had_position==false \u0026\u0026 fixed ==false){\n had_position = set_postion(this);\n }else{\n fixed = true;\n timer += 1;\n if(timer%100 == 0){\n defend(this,\"pa\"); \n } \n }\n });\n countMush -=80;\n }\n});\n\nzeroCard.on(\"click\", function(){\n if(countMush \u003e= 50){\n var zero = createSprite([\"zero01.png\",\"zero02.png\"]);\n var fixed = false;\n var had_position = false;\n var timer = 0;\n zero.forever(function(){\n if(cursor.isDown==false \u0026\u0026 fixed == false){\n zero.moveTo(cursor);\n }else if(had_position==false \u0026\u0026 fixed ==false){\n had_position = set_postion(this);\n }else{\n fixed = true;\n timer += 1;\n if(timer%100 == 0){\n defend(this,\"zero\"); \n } \n }\n });\n countMush -=50;\n }\n});\n\nkodingCard.on(\"click\", function(){\n if(countMush \u003e= 100){\n var koding = createSprite([\"koding01.png\",\"koding02.png\"]);\n var fixed = false;\n var had_position = false;\n var timer = 0;\n koding.forever(function(){\n if(cursor.isDown==false \u0026\u0026 fixed == false){\n koding.moveTo(cursor);\n }else if(had_position==false \u0026\u0026 fixed ==false){\n had_position = set_postion(this);\n }else{\n fixed = true;\n timer +=1 ;\n if(timer%50 == 0){\n this.nextCostume(); \n }\n }\n });\n countMush -=100;\n }\n});\n// shovel is not working\n\n// set every sprite's position in an array\nfunction set_postion(current_sprite){\n var current_col = Math.floor((current_sprite.x-35)/60);\n var current_row = Math.floor((current_sprite.y-180)/80);\n if(current_row \u003c 0){\n current_row = 0;\n }\n if(current_col \u003c 0){\n current_col = 0;\n }\n // in case the position has been taken \n if(role_position[current_row][current_col] !== \"occupied\"){\n current_sprite.x = standard_x[current_col];\n current_sprite.y = standard_y[current_row];\n role_position[current_row][current_col] =\"occupied\";\n return true;\n }else{\n return false;\n }\n}\n\nfunction defend(current_sprite,role){\n current_sprite.nextCostume();\n var weapons = createSprite([\"pa_arrow.png\",\"broom.png\"]);\n if(role == \"pa\"){\n weapons.costumeId = 0;\n }else{ \n weapons.costumeId = 1;\n }\n weapons.moveTo(current_sprite);\n weapons.forever(function(){\n if(weapons.x \u003c 600 ){\n weapons.x += 2;\n }else{\n weapons.destroy();\n }\n });\n}\n\nfunction createEnemy(){\n var enemy = createSprite([\"kido01.png\",\"kido02.png\",\"witch01.png\",\"witch02.png\"]);\n enemy.costumeId = Math.floor(Math.random()*3);\n enemy.moveTo(660,standard_y[Math.floor(Math.random()*4)]); \n enemy.forever(function(){\n enemy.x -= 0.05;\n if(enemy.touched(bunker01)){\n stop();\n }\n });\n\n}","created_at":"2017-03-01T20:52:04.729+08:00","updated_at":"2019-10-26T03:46:37.554+08:00","name":"Plants Killer","language":"javascript","screenshot":{"url":null},"parent_id":10375,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":386,"hashid":"npms3w3p","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":242763,"file_name":"bunker.png","project_id":11064,"asset_id":28185,"created_at":"2017-09-09T23:25:32.749+08:00","updated_at":"2017-09-09T23:25:32.749+08:00"},{"id":242764,"file_name":"mushroom.png","project_id":11064,"asset_id":28186,"created_at":"2017-09-09T23:25:32.751+08:00","updated_at":"2017-09-09T23:25:32.751+08:00"},{"id":242765,"file_name":"mushroom(s).png","project_id":11064,"asset_id":28187,"created_at":"2017-09-09T23:25:32.754+08:00","updated_at":"2017-09-09T23:25:32.754+08:00"},{"id":242766,"file_name":"bg.jpg","project_id":11064,"asset_id":28228,"created_at":"2017-09-09T23:25:32.756+08:00","updated_at":"2017-09-09T23:25:32.756+08:00"},{"id":242767,"file_name":"shovel.png","project_id":11064,"asset_id":28229,"created_at":"2017-09-09T23:25:32.759+08:00","updated_at":"2017-09-09T23:25:32.759+08:00"},{"id":242768,"file_name":"koding01.png","project_id":11064,"asset_id":28267,"created_at":"2017-09-09T23:25:32.761+08:00","updated_at":"2017-09-09T23:25:32.761+08:00"},{"id":242769,"file_name":"koding02.png","project_id":11064,"asset_id":28268,"created_at":"2017-09-09T23:25:32.763+08:00","updated_at":"2017-09-09T23:25:32.763+08:00"},{"id":242770,"file_name":"paCard.png","project_id":11064,"asset_id":28711,"created_at":"2017-09-09T23:25:32.766+08:00","updated_at":"2017-09-09T23:25:32.766+08:00"},{"id":242771,"file_name":"kodingCard.png","project_id":11064,"asset_id":28715,"created_at":"2017-09-09T23:25:32.767+08:00","updated_at":"2017-09-09T23:25:32.767+08:00"},{"id":242772,"file_name":"mushroomCard.png","project_id":11064,"asset_id":28716,"created_at":"2017-09-09T23:25:32.770+08:00","updated_at":"2017-09-09T23:25:32.770+08:00"},{"id":242773,"file_name":"zeroCard.png","project_id":11064,"asset_id":28717,"created_at":"2017-09-09T23:25:32.773+08:00","updated_at":"2017-09-09T23:25:32.773+08:00"},{"id":242774,"file_name":"pa_arrow.png","project_id":11064,"asset_id":28825,"created_at":"2017-09-09T23:25:32.775+08:00","updated_at":"2017-09-09T23:25:32.775+08:00"},{"id":242775,"file_name":"zero01.png","project_id":11064,"asset_id":28940,"created_at":"2017-09-09T23:25:32.779+08:00","updated_at":"2017-09-09T23:25:32.779+08:00"},{"id":242776,"file_name":"zero02.png","project_id":11064,"asset_id":28941,"created_at":"2017-09-09T23:25:32.781+08:00","updated_at":"2017-09-09T23:25:32.781+08:00"},{"id":242777,"file_name":"pa01.png","project_id":11064,"asset_id":28943,"created_at":"2017-09-09T23:25:32.784+08:00","updated_at":"2017-09-09T23:25:32.784+08:00"},{"id":242778,"file_name":"pa02.png","project_id":11064,"asset_id":28944,"created_at":"2017-09-09T23:25:32.787+08:00","updated_at":"2017-09-09T23:25:32.787+08:00"},{"id":242779,"file_name":"kido01.png","project_id":11064,"asset_id":28945,"created_at":"2017-09-09T23:25:32.790+08:00","updated_at":"2017-09-09T23:25:32.790+08:00"},{"id":242780,"file_name":"kido02.png","project_id":11064,"asset_id":28946,"created_at":"2017-09-09T23:25:32.793+08:00","updated_at":"2017-09-09T23:25:32.793+08:00"},{"id":242781,"file_name":"witch01.png","project_id":11064,"asset_id":28947,"created_at":"2017-09-09T23:25:32.795+08:00","updated_at":"2017-09-09T23:25:32.795+08:00"},{"id":242782,"file_name":"witch02.png","project_id":11064,"asset_id":28948,"created_at":"2017-09-09T23:25:32.798+08:00","updated_at":"2017-09-09T23:25:32.798+08:00"},{"id":242783,"file_name":"broom.png","project_id":11064,"asset_id":29096,"created_at":"2017-09-09T23:25:32.801+08:00","updated_at":"2017-09-09T23:25:32.801+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
下載 Android APP (APK)
截圖
1:1:1
1:1
full
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦