{"id":4719,"student_id":888,"content":"setBackdrop('#000000');\n\nvar bullets = [];\nvar score = 0;\nvar ship = createSprite({\n costumes: ['spaceship.png'],\n x: 320,\n y: 240,\n scale: 0.1\n});\n\nvar food = createSprite({\n costumes: ['life.gif'],\n x: 100 + Math.random() * 440,\n y: 100 + Math.random() * 280\n});\n\nGame.on('holding','up', function () {\n\tship.y -= 4;\n});\nGame.on('holding','down', function () {\n\tship.y += 4;\n});\nGame.on('holding','left', function () {\n\tship.x -= 4;\n});\nGame.on('holding','right', function () {\n\tship.x += 4;\n});\n\nship.on('touch', food, function() {\n\tfood.x = 100 + Math.random() * 440;\n food.y = 100 + Math.random() * 280;\n score += 100;\n});\n\nvar clock = 0;\nforever(function () {\n clock ++;\n \n print('socre: ' + score, 30, 30, 'red');\n \n if(clock % 3 == 0) {\n var pos = randomPos();\n var bullet = createSprite({\n costumes: ['bullet.gif'],\n x: pos.x,\n y: pos.y,\n direction: Math.random() * 360\n });\n bullet.speed = 1 + Math.random() * 3;\n bullets.push(bullet);\n }\n \n bullets.forEach(function (bullet) {\n if(bullet.touched(ship)) {\n stop();\n alert('遊戲結束,獲得 ' + score + ' 分!');\n }\n bullet.stepForward(bullet.speed); \n if(bullet.x \u003e 960 || bullet.x \u003c -320 || bullet.y \u003e 720 || bullet.y \u003c -240) {\n bullet.destroy();\n }\n });\n});\n\nfunction randomPos () {\n var x,y;\n while(true) {\n x = Math.random() * 1280 - 320;\n y = Math.random() * 960 - 240;\n if(x \u003c 0 || x \u003e 640 || y \u003c 0 || y \u003e 480) {\n return {x: x, y: y};\n }\n }\n}","created_at":"2017-03-01T20:52:04.729+08:00","updated_at":"2019-11-11T01:40:42.540+08:00","name":"太空生存戰","language":"javascript","screenshot":{"url":"https://cdn4.koding.school/uploads/project/screenshot/4719/d382e053cc5c1d8136e8ee180c499f1b.jpg"},"parent_id":2,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[10,979,1237,1407,149,1935],"is_featured":true,"views":2040,"hashid":"9ygs3j6","is_content_changed":null,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":129009,"file_name":"spaceship.png","project_id":4719,"asset_id":15693,"created_at":"2017-05-15T15:08:55.411+08:00","updated_at":"2017-05-15T15:08:55.411+08:00"},{"id":129010,"file_name":"bullet.gif","project_id":4719,"asset_id":15694,"created_at":"2017-05-15T15:08:55.412+08:00","updated_at":"2017-05-15T15:08:55.412+08:00"},{"id":129011,"file_name":"life.gif","project_id":4719,"asset_id":15695,"created_at":"2017-05-15T15:08:55.414+08:00","updated_at":"2017-05-15T15:08:55.414+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
下載 Android APP (APK)
截圖
1:1:1
1:1
full
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦