{"id":18157,"student_id":2591,"content":"var score = 0;\r\nvar speed = 1;\r\n\r\nvar bomb = createSprite(\"bomb.png\");\r\nbomb.scale = 0.2;\r\nbomb.direction = 180;\r\nbomb.layer = 10;\r\nbomb.rotationStyle = \"fixed\";\r\n\r\nvar boat = createSprite(\"boat.png\");\r\nboat.x = 320;\r\nboat.y = 80;\r\nboat.scale = 0.2;\r\nboat.layer = 5;\r\nboat.hp = 200;\r\n\r\nfunction createEnemy(enemyCategory,missileCategory,rate){\r\n var enemy = createSprite(enemyCategory);\r\n enemy.x = 20;\r\n enemy.y = Math.random()*280+180;\r\n enemy.direction = 90;\r\n enemy.scale = 0.2;\r\n enemy.rotationStyle = \"flipped\";\r\n if(Math.random()*2 \u003e 1){\r\n enemy.direction = 270;\r\n enemy.x = 680;\r\n }\r\n enemy.forever(function(){\r\n enemy.stepForward(1);\r\n if(clock % 240 == 0){\r\n var missile = createSprite(missileCategory);\r\n missile.x = enemy.x;\r\n missile.y = enemy.y;\r\n missile.scale = 0.1;\r\n missile.toward(boat);\r\n missile.forever(function(){\r\n missile.stepForward(speed + rate);\r\n if(missile.y \u003c 100){\r\n missile.destroy();\r\n }\r\n if(missile.touched(boat)){\r\n missile.destroy();\r\n boat.hp = boat.hp - (10*rate);\r\n }\r\n });\r\n }\r\n if(enemy.x \u003e 640 \u0026\u0026 enemy.direction == 90 || enemy.x \u003c 10 \u0026\u0026 enemy.direction){\r\n enemy.destroy();\r\n }\r\n });\r\n enemy.when(\"touch\",bomb,function(){\r\n enemy.destroy();\r\n boat.shot = false;\r\n score = score + (10*rate);\r\n })\r\n}\r\nforever(function(){\r\n if(clock%180 == 0){\r\n createEnemy(\"enemy.png\", \"missile.png\",1)\r\n }\r\n if(clock%600 == 0){\r\n speed += 0.2;\r\n }\r\n if(clock%1200 == 0){\r\n createEnemy(\"enemy_boss.png\", \"missile_boss.png\",2)\r\n }\r\n if(boat.shot){\r\n bomb.stepForward(2);\r\n if(bomb.y \u003e 480){\r\n boat.shot = false;\r\n }\r\n }else{\r\n bomb.x = boat.x;\r\n bomb.y = boat.y;\r\n print(\"Score: \" + score, 20, 20, \"red\");\r\n print(\"hp: \" + boat.hp, 20, 40, \"red\");\r\n if(boat.hp \u003c= 0){\r\n print(\"Your Score: \" + score, 220, 220, \"red\", 40)\r\n stop();\r\n }\r\n }\r\n});\r\nwhen(\"keydown\", \"space\", function(){\r\n boat.shot = true;\r\n});\r\nwhen(\"holding\", \"left\", function(){\r\n boat.x -= 4 + speed/2;\r\n});\r\n\r\nwhen(\"holding\", \"right\", function(){\r\n boat.x += 4 + speed/2;\r\n});","created_at":"2017-08-31T21:49:34.717+08:00","updated_at":"2019-11-09T17:57:58.592+08:00","name":"深水炸彈","language":"javascript","screenshot":{"url":"https://cdn5.koding.school/uploads/project/screenshot/18157/4adad88dbd74b15c0168f4e18f1f5a61.jpg"},"parent_id":10357,"plugin":"setBackdrop(\"#0072E3\");\nvar sky = createSprite(\"天空色.png\");\nsky.x = 320;\nsky.y = 50;\nsky.layer = 1;\nvar clock = 179;\nupdate(function(){\n\tclock++;\n});","description":null,"note":null,"status":"public","like_student_ids":[1934,1931],"is_featured":false,"views":129,"hashid":"36ysm6y9","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":370336,"file_name":"boat.png","project_id":18157,"asset_id":27734,"created_at":"2017-12-22T10:54:45.058+08:00","updated_at":"2017-12-22T10:54:45.058+08:00"},{"id":370337,"file_name":"天空色.png","project_id":18157,"asset_id":27735,"created_at":"2017-12-22T10:54:45.062+08:00","updated_at":"2017-12-22T10:54:45.062+08:00"},{"id":370338,"file_name":"bomb.png","project_id":18157,"asset_id":27736,"created_at":"2017-12-22T10:54:45.075+08:00","updated_at":"2017-12-22T10:54:45.075+08:00"},{"id":370339,"file_name":"enemy.png","project_id":18157,"asset_id":27737,"created_at":"2017-12-22T10:54:45.076+08:00","updated_at":"2017-12-22T10:54:45.076+08:00"},{"id":370340,"file_name":"enemy_boss.png","project_id":18157,"asset_id":27738,"created_at":"2017-12-22T10:54:45.078+08:00","updated_at":"2017-12-22T10:54:45.078+08:00"},{"id":370341,"file_name":"missile_boss.png","project_id":18157,"asset_id":27739,"created_at":"2017-12-22T10:54:45.079+08:00","updated_at":"2017-12-22T10:54:45.079+08:00"},{"id":370342,"file_name":"missile.png","project_id":18157,"asset_id":27740,"created_at":"2017-12-22T10:54:45.080+08:00","updated_at":"2017-12-22T10:54:45.080+08:00"}]
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
下載 Android APP (APK)
截圖
繁中
简中
English
日本語
1:1:1
1:1
全寬
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦