{"id":187831,"student_id":10,"content":"setBackdrop(\"bg.png\");\n\nvar nextShape = createSprite('b_0.png', 'b_1.png', 'b_2.png', 'b_3.png', 'b_4.png', 'b_5.png', 'b_6.png');\nvar gameoverText = createSprite('gameover.png');\nnextShape.moveTo(1000, 100);\ngameoverText.hidden = true;\n\nvar moving = []; //存放移動的磚塊\nvar fixed = []; //存放固定的磚塊\nvar center; //移動磚塊的中心點\nvar score = 0; //分數\nvar clock = 0; //紀錄遊戲迴圈執行次數\nvar level = 0; //等級\nvar next = 0; //下一個要出現的磚塊種類\n\nvar shapeList = [\n [[1, 0], [1, 1], [1, 2], [1, 3]], //長條形\n [[1, 0], [1, 1], [1, 2], [2, 2]], //L形\n [[1, 0], [1, 1], [1, 2], [0, 2]], //反L形\n [[1, 0], [1, 1], [0, 1], [2, 1]], //山形\n [[1, 0], [1, 1], [0, 0], [2, 1]], //Z形\n [[1, 0], [1, 1], [0, 1], [2, 0]], //反Z形\n [[1, 0], [1, 1], [0, 0], [0, 1]], //正方形\n]\n\non('keydown', 'up', turnRight); //當按上鍵\non('keydown', 'down', moveDown); //當按下鍵\non('keydown', 'right', moveRight); //當按右鍵\non('keydown', 'left', moveLeft); //當按左鍵\n\ncreateSound('bgm.mp3', true);\n\nloadBlocks(); //載入磚塊\n\nforever(loop); //重複不斷執行遊戲迴圈\n\n// 遊戲主迴圈\nfunction loop () {\n drawText('score:' + score, 50, 30, 'white', 40);\n drawText('level:' + level, 50, 90, 'white', 40);\n\n checkGameover(); //檢查遊戲是否結束\n checkLines(); //檢查是否要消除磚塊\n\n clock++;\n if (clock % 30 == 0) moveDown();\n nextShape.costumeId = next;\n}\n\n// 載入磚塊\nfunction loadBlocks () {\n // var rand = Math.floor(Math.random()*7);\n var shape = shapeList[next];\n for (var i = 0; i \u003c 4; i++) {\n var b = createSprite('b_0.png', 'b_1.png', 'b_2.png', 'b_3.png', 'b_4.png', 'b_5.png', 'b_6.png')\n b.costumeId = next;\n b.x = shape[i][0] * 60 + 330;\n b.y = shape[i][1] * 60 + 30;\n moving.push(b);\n }\n center = moving[1];\n next = Math.floor(Math.random()*7);\n}\n\n\n//向上移動\nfunction moveUp () {\n for (var i = 0; i \u003c moving.length; i++) {\n moving[i].y -= 60;\n }\n}\n\n//向下移動\nfunction moveDown () {\n var undo = false;\n for (var i = 0; i \u003c moving.length; i++) {\n moving[i].y += 60\n if (moving[i].y \u003e 900 || moving[i].touched(fixed)) {\n undo = true;\n }\n }\n\n if (undo) {\n moveUp();\n fixed = fixed.concat(moving);\n moving.length = 0;\n loadBlocks();\n createSound('hit.mp3');\n }\n}\n\n//向右移動\nfunction moveRight () {\n var undo = false;\n for (var i = 0; i \u003c moving.length; i++) {\n moving[i].x += 60\n if (moving[i].x \u003e 900 || moving[i].touched(fixed)) {\n undo = true;\n }\n }\n if (undo) moveLeft();\n createSound('move.mp3');\n}\n\n//向左移動\nfunction moveLeft () {\n var undo = false;\n for (var i = 0; i \u003c moving.length; i++) {\n moving[i].x -= 60\n if (moving[i].x \u003c 300 || moving[i].touched(fixed)) {\n undo = true;\n }\n }\n if (undo) moveRight();\n createSound('move.mp3');\n}\n\n\n//順時針選轉\nfunction turnRight () {\n var undo = 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 300 || moving[i].x \u003e 900 || moving[i].touched(fixed)) {\n undo = true;\n }\n }\n if (undo) turnRight();\n createSound('move.mp3');\n}\n\n\n//檢查是否佔滿一行\nfunction checkLines () {\n \n var line = 0;\n \n var arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n \n for (var i = 0; i \u003c fixed.length; i++) {\n f = Math.floor(fixed[i].y / 60)\n arr[f] += 1;\n }\n \n for (var i=0; i \u003c 15; i++) {\n drawText(arr[i], 240, 60*i, 'white', 40)\n if (arr[i] == 10) {\n eraseLine(i);\n line++;\n }\n }\n if (line == 1) {\n score += 10\n createSound('1.mp3')\n }\n if (line == 2) {\n score += 50\n createSound('2.mp3')\n }\n if (line == 3) {\n score += 100\n createSound('3.mp3')\n }\n if (line == 4) {\n score += 300\n createSound('4.mp3')\n }\n\n level = Math.floor(score / 100);\n if (level \u003e 10) level = 10;\n}\n\n// 清除一行\nfunction eraseLine (f) {\n for (var i = 0; i \u003c fixed.length; i++) {\n var floor = Math.floor(fixed[i].y / 60)\n if (floor == f) fixed[i].y = 1000;\n if (floor \u003c f) fixed[i].y += 60;\n }\n}\n\n// 檢查遊戲是否結束\nfunction checkGameover () {\n for (var i = 0; i \u003c fixed.length; i++) {\n if (fixed[i].y \u003c 60) {\n stop();\n gameoverText.hidden = false;\n }\n }\n}","created_at":"2020-09-02T10:40:21.764+08:00","updated_at":"2020-09-03T17:21:05.742+08:00","name":"俄羅斯方塊","language":"javascript","screenshot":{"url":"https://cdn9.koding.school/uploads/project/screenshot/187831/1d3992cae15d68b9cabb0df15fa689d6.jpg"},"parent_id":2,"plugin":"Game.set({\n width: 1200,\n height: 900,\n})","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":237,"hashid":"zpesm395","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":3191670,"file_name":"bg.png","project_id":187831,"asset_id":255849,"created_at":"2020-09-02T12:04:54.555+08:00","updated_at":"2020-09-02T12:04:54.555+08:00"},{"id":3191783,"file_name":"bgm.mp3","project_id":187831,"asset_id":255908,"created_at":"2020-09-02T15:56:52.875+08:00","updated_at":"2020-09-02T15:56:52.875+08:00"},{"id":3191668,"file_name":"b_4.png","project_id":187831,"asset_id":255847,"created_at":"2020-09-02T11:58:18.465+08:00","updated_at":"2020-09-02T11:58:18.465+08:00"},{"id":3191669,"file_name":"b_5.png","project_id":187831,"asset_id":255848,"created_at":"2020-09-02T11:58:18.466+08:00","updated_at":"2020-09-02T11:58:18.466+08:00"},{"id":3191664,"file_name":"b_0.png","project_id":187831,"asset_id":255843,"created_at":"2020-09-02T11:58:17.526+08:00","updated_at":"2020-09-02T11:58:17.526+08:00"},{"id":3191665,"file_name":"b_1.png","project_id":187831,"asset_id":255844,"created_at":"2020-09-02T11:58:17.528+08:00","updated_at":"2020-09-02T11:58:17.528+08:00"},{"id":3191776,"file_name":"b_6.png","project_id":187831,"asset_id":255903,"created_at":"2020-09-02T15:22:22.342+08:00","updated_at":"2020-09-02T15:22:22.342+08:00"},{"id":3191597,"file_name":"block.png","project_id":187831,"asset_id":255839,"created_at":"2020-09-02T10:40:36.317+08:00","updated_at":"2020-09-02T10:40:36.317+08:00"},{"id":3191805,"file_name":"move.mp3","project_id":187831,"asset_id":255910,"created_at":"2020-09-02T16:07:27.959+08:00","updated_at":"2020-09-02T16:07:27.959+08:00"},{"id":3191779,"file_name":"1.mp3","project_id":187831,"asset_id":255904,"created_at":"2020-09-02T15:45:06.732+08:00","updated_at":"2020-09-02T15:45:06.732+08:00"},{"id":3191780,"file_name":"2.mp3","project_id":187831,"asset_id":255905,"created_at":"2020-09-02T15:45:06.734+08:00","updated_at":"2020-09-02T15:45:06.734+08:00"},{"id":3191781,"file_name":"3.mp3","project_id":187831,"asset_id":255906,"created_at":"2020-09-02T15:45:07.323+08:00","updated_at":"2020-09-02T15:45:07.323+08:00"},{"id":3191782,"file_name":"4.mp3","project_id":187831,"asset_id":255907,"created_at":"2020-09-02T15:45:07.324+08:00","updated_at":"2020-09-02T15:45:07.324+08:00"},{"id":3191806,"file_name":"hit.mp3","project_id":187831,"asset_id":255911,"created_at":"2020-09-02T16:08:14.742+08:00","updated_at":"2020-09-02T16:08:14.742+08:00"},{"id":3191666,"file_name":"b_2.png","project_id":187831,"asset_id":255845,"created_at":"2020-09-02T11:58:18.013+08:00","updated_at":"2020-09-02T11:58:18.013+08:00"},{"id":3191667,"file_name":"b_3.png","project_id":187831,"asset_id":255846,"created_at":"2020-09-02T11:58:18.014+08:00","updated_at":"2020-09-02T11:58:18.014+08:00"},{"id":3192772,"file_name":"gameover.png","project_id":187831,"asset_id":189062,"created_at":"2020-09-03T11:34:33.903+08:00","updated_at":"2020-09-03T11:34:33.903+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
下載 Android APP (APK)
截圖
1:1:1
1:1
full
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦