劉任昌VS Code俄羅斯方塊maintain維護物件object

模仿印度開發人員

JS程式碼

let canvas = document.getElementById("tetris");
let scoreboard = document.getElementById("score");
let ctx = canvas.getContext("2d");
ctx.scale(30,30);
const FOUR = [                              //設定
    [[0,1,0,0],[0,1,0,0],[0,1,0,0],[0,1,0,0]],//I紅
    [[0,1,0],  [0,1,0],  [1,1,0]],            //J橘
    [[0,1,0],  [0,1,0],  [0,1,1]],            //L黃
    [[1,1,0],  [0,1,1],  [0,0,0]],            //Z綠
    [[0,1,1],  [1,1,0],  [0,0,0]],            //S藍
    [[1,1,1],  [0,1,0],  [0,0,0]],            //T靛
    [[1,1],    [1,1],]];             //M紫,正方形,以上共7個
const COLORS = [
    "lightgray","red","orange","yellow","darkgreen","blue","indigo","purple"];
const ROWS = 20;                    //列數ROWS
const COLS = 10;                    //欄數COLumnS
let grid = generateGrid();          //呼叫函數產生20x10格子
let fallingPieceObj = null;
let score = 0;
setInterval(newGameState,200);      //設定間隔500
function newGameState(){            //函數
    checkGrid();
    if(!fallingPieceObj){           //如果空的,產生新方塊
        fallingPieceObj = randomPieceObject();
        renderPiece();};                //新方塊
      moveDown(); }                        //繼續往下
function checkGrid(){ //函數逐列檢查是否滿格rowFiller?
    let count = 0;
    for(let i=0;i3){score+=100}    //刪4列100分
    document.getElementById("score").innerHTML = "劉任昌分數: " + score;}
function generateGrid(){        //函數一開始就設定格子
    let grid = [];              //宣告空白陣列[]
    for(let i=0; i=0 && p=0 && q0){ return true;};}
            else{ return true;}; }; };};
    return false;}
function renderGame(){
    for(let i=0; i

342

拷貝自w3schools

留言

  1. https://tustning.blogspot.com/2023/11/vs-codemaintainobject.html

    回覆刪除
  2. https://ctz642895.blogspot.com/2023/11/vs-codemaintainobject.html

    回覆刪除
  3. https://keiime.blogspot.com/2023/11/vs-codemaintainrender.html

    回覆刪除
  4. https://kitty030994.blogspot.com/2023/11/vs-codemaintainobject.html

    回覆刪除
  5. https://yun0205.blogspot.com/2023/11/vs-codemaintain.html

    回覆刪除
  6. https://whitexd.blogspot.com/2023/11/vs-codemaintainobject.html

    回覆刪除
  7. https://kk0725.blogspot.com/2023/11/vs-codemaintainobject.html

    回覆刪除
  8. https://htmlcssjavascriptjavapython.blogspot.com/2023/11/vs-codemaintainobject.html

    回覆刪除
  9. https://d10836153.blogspot.com/2023/11/vs-codemaintainrender.html

    回覆刪除
  10. https://oscarliu1688.blogspot.com/2023/11/vs-codemaintain.html

    回覆刪除
  11. https://howardhtmlcssjavascriptjavapython.blogspot.com/2023/11/vscodemaintainobject.html

    回覆刪除
  12. https://rrrrr-eeeee.blogspot.com/2023/11/vs-codemaintainobject.html

    回覆刪除
  13. https://mmmmmnnyytt.blogspot.com/2023/11/vs-codemaintainobject.html

    回覆刪除
  14. https://leeyicheng0531.blogspot.com/2023/11/vs-codemaintainobject.html

    回覆刪除
  15. https://rainhtmlcssjavascriptjavapython.blogspot.com/2023/11/vs-codemaintainobject.html

    回覆刪除
  16. https://xi715.blogspot.com/2023/11/js-let-canvas-document.html

    回覆刪除
  17. https://jduwy67fhkfcf4135.blogspot.com/2023/11/js-let-canvas-document.html

    回覆刪除
  18. https://grace8166.blogspot.com/2023/12/vs-codemaintain.html

    回覆刪除
  19. https://kitty030994.blogspot.com/2023/12/javascriptrandomfloorceilround.html

    回覆刪除

張貼留言

這個網誌中的熱門文章

柯聞折Javascript物件導向方法是物件的函數

甲劉任昌python串列List(陣列Array),元組Tuple,集合Set,字典Dict

劉任昌PYTHON陣列ARRAY串列LIST字典DIC集合SET元組TUPLE