{"id":187836,"student_id":10,"content":"var bg1 = createSprite('bg.png')\nvar bg2 = createSprite('bg_2.png')\nbg2.layer = 1;\n\nvar moving = []\nvar fixed = []\nvar center;\nvar score = 0;\nvar clock = 0;\nvar level = 0;\n\nvar blocks = [\n [{x: 5, y: 0}, {x: 6, y: 0}, {x: 7, y: 0}, {x: 510, y: 0}], //長條形\n [{x: 5, y: 0}, {x: 6, y: 0}, {x: 7, y: 0}, {x: 7, y: -1}], //L形\n [{x: 5, y: 0}, {x: 6, y: 0}, {x: 7, y: 0}, {x: 7, y: 1}], //反L形\n [{x: 5, y: 0}, {x: 6, y: 0}, {x: 7, y: 0}, {x: 7, y: 1}], //反L形\n [{x: 5, y: 0}, {x: 5, y: 1}, {x: 4, y: 1}, {x: 6, y: 1}], //山形\n [{x: 5, y: 0}, {x: 5, y: 1}, {x: 4, y: 1}, {x: 4, y: 2}], //z形\n [{x: 5, y: 0}, {x: 5, y: 1}, {x: 6, y: 2}, {x: 6, y: 1}], //反z形\n]\n\non('keydown', 'space', loadBlocks)\non('keydown', 'up', turnRight)\non('keydown', 'down', moveDown)\non('keydown', 'right', moveRight)\non('keydown', 'left', moveLeft)\n\nloadBlocks();\nforever(loop);\n\nfunction loop () {\n drawText('score:' + score, 50, 30, 'white', 40);\n drawText('level:' + level, 50, 90, 'white', 40);\n \n clock++;\n if (clock % (40 - 9 * 3) == 0) moveDown()\n checkGameover();\n}\n\n\nfunction loadBlocks () {\n var rand1 = Math.floor(Math.random()*blocks.length);\n var rand2 = Math.floor(Math.random()*6);\n var pos = blocks[rand1];\n \n for (var i=0; i\u003cpos.length; i++) {\n var b = createSprite('b_0.png','b_1.png','b_2.png','b_3.png','b_4.png','b_5.png')\n b.costumeId = rand2;\n b.x = pos[i].x*40 + 20 + 400\n b.y = pos[i].y*40 + 20 + 50\n moving.push(b)\n }\n \n center = moving[1]\n}\n\n\nfunction moveUp () {\n for (var i = 0; i \u003c moving.length; i++) {\n moving[i].y -= 40\n }\n}\n\nfunction moveDown () {\n var rollback = false;\n for (var i = 0; i \u003c moving.length; i++) {\n moving[i].y += 40\n if (moving[i].y \u003e 850 || moving[i].touched(fixed)) {\n rollback = true;\n }\n }\n\n if (rollback) {\n moveUp();\n fixed = fixed.concat(moving);\n moving.length = 0;\n loadBlocks();\n checkLines();\n }\n}\n\nfunction moveRight () {\n var rollback = false;\n for (var i = 0; i \u003c moving.length; i++) {\n moving[i].x += 40\n if (moving[i].x \u003e 800 || moving[i].touched(fixed)) {\n rollback = true;\n }\n }\n\n if (rollback) moveLeft();\n}\n\nfunction moveLeft () {\n var rollback = false;\n for (var i = 0; i \u003c moving.length; i++) {\n moving[i].x -= 40\n if (moving[i].x \u003c 400 || moving[i].touched(fixed)) {\n rollback = true;\n }\n }\n\n if (rollback) moveRight();\n}\n\n\nfunction turnRight () {\n var rollback = false;\n for (var i = 0; i \u003c moving.length; i++) {\n var b = moving[i];\n var d = b.distanceTo(center)\n b.toward(center)\n b.stepForward(d)\n b.direction += 90\n b.stepForward(d)\n b.direction = 90;\n if (moving[i].x \u003c 400 || moving[i].x \u003e 800) rollback = true;\n }\n if (rollback) turnRight();\n}\n\n\nfunction checkLines () {\n var line = 0;\n for (var i = 19; i \u003e= 0; i--) {\n var count = 0;\n for (var j = 0; j \u003c fixed.length; j++) {\n var floor = Math.floor(fixed[j].y / 40)\n if (i == floor) count++;\n }\n if (count == 10) {\n line += 1;\n eraseLine(i);\n i++;\n }\n }\n \n if (line == 1) score += 10\n if (line == 2) score += 50\n if (line == 3) score += 100\n if (line == 4) score += 300\n \n level = Math.floor(score / 100)\n if (level \u003e 9) level = 9\n}\n\nfunction eraseLine (f) {\n for (var i = 0; i \u003c fixed.length; i++) {\n b = fixed[i];\n var floor = Math.floor(b.y / 40)\n if (f == floor) {\n b.destroy()\n fixed.splice(i, 1)\n i--;\n }\n if (b.y / 40 \u003c f) b.y += 40;\n }\n}\n\nfunction checkGameover () {\n for (var i = 0; i \u003c fixed.length; i++) {\n if (fixed[i].y \u003c 90) {\n stop();\n drawText('gameover', 400, 400, 'white', 120) \n }\n }\n}","created_at":"2020-09-02T14:47:54.477+08:00","updated_at":"2020-09-02T14:51:52.845+08:00","name":"俄羅斯方塊 v2","language":"javascript","screenshot":{"url":"https://cdn1.koding.school/uploads/project/screenshot/187836/81c01a9f831a2284fee8a45f9d68688e.jpg"},"parent_id":187831,"plugin":"Game.set({\n width: 1200,\n height: 900,\n})","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":225,"hashid":"5j3sgvkp","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":3191770,"file_name":"b_2.png","project_id":187836,"asset_id":255897,"created_at":"2020-09-02T14:48:40.127+08:00","updated_at":"2020-09-02T14:48:40.127+08:00"},{"id":3191771,"file_name":"b_3.png","project_id":187836,"asset_id":255898,"created_at":"2020-09-02T14:48:40.128+08:00","updated_at":"2020-09-02T14:48:40.128+08:00"},{"id":3191768,"file_name":"b_0.png","project_id":187836,"asset_id":255895,"created_at":"2020-09-02T14:48:39.047+08:00","updated_at":"2020-09-02T14:48:39.047+08:00"},{"id":3191769,"file_name":"b_1.png","project_id":187836,"asset_id":255896,"created_at":"2020-09-02T14:48:39.049+08:00","updated_at":"2020-09-02T14:48:39.049+08:00"},{"id":3191772,"file_name":"b_4.png","project_id":187836,"asset_id":255899,"created_at":"2020-09-02T14:48:40.602+08:00","updated_at":"2020-09-02T14:48:40.602+08:00"},{"id":3191773,"file_name":"b_5.png","project_id":187836,"asset_id":255900,"created_at":"2020-09-02T14:48:40.604+08:00","updated_at":"2020-09-02T14:48:40.604+08:00"},{"id":3191774,"file_name":"bg_2.png","project_id":187836,"asset_id":255901,"created_at":"2020-09-02T14:48:41.092+08:00","updated_at":"2020-09-02T14:48:41.092+08:00"},{"id":3191775,"file_name":"bg.png","project_id":187836,"asset_id":255902,"created_at":"2020-09-02T14:48:41.094+08:00","updated_at":"2020-09-02T14:48:41.094+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
下載 Android APP (APK)
截圖
1:1:1
1:1
full
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦