js程式碼
let grid = generateGrid(); //呼叫函數產生20x10格子
let fallingPieceObj = null;
let score = 0;
setInterval(newGameState,1000); //設定間隔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
1127tetris.https://kitty030994.blogspot.com/2023/11/vs-codemaintainobject.html
回覆刪除