private Tetromino curTetromino; //Current tetromino which player is controlling public Arena(int width, int height) { this.width = width; this.height = height; arena = new int[width, height]; ClearArena(); curTetromino = new Tetromino(this); }
private void SaveTetromino(Tetromino t) { for (int i = 0; i < t.positions.Length; i++) { Vector2 pos = t.positions[i]; if (pos.Y >= 0 && pos.Y < height && pos.X >= 0 && pos.X < width) { arena[(int)pos.X, (int)pos.Y] = t.id; } } }
public void Update(GameTime gameTime) { curTetromino.Update(gameTime); if (curTetromino.isLanded) { SaveTetromino(curTetromino); if (curTetromino.GetMinPosition(curTetromino.positions).Y <= 0) { //GameOver(); } else { Console.WriteLine(curTetromino.GetMinPosition(curTetromino.positions).Y + " : Y pos"); curTetromino = new Tetromino(this); curTetromino.LoadContent(); } } int rowsFilled = 0; //Check if any row is filled for (int i = 0; i < height; i++) { bool isFilled = true; for (int j = 0; j < width; j++) { if (arena[j, i] == 8) { isFilled = false; } } if (isFilled) { DeleteRow(i); rowsFilled++; } } if (rowsFilled != 0) { score += rowsFilled * (rowsFilled * 5 + 50); } }