public void Hold() { if (heldTetromino == null) { heldTetromino = TetrominoQueue[0]; TetrominoQueue.RemoveAt(0); } else { Tetromino temp = heldTetromino; heldTetromino = TetrominoQueue[0]; TetrominoQueue[0] = temp; } ResetTetromino(); }
private bool CheckTetromino(Tetromino t, int fx, int fy) { for (int x = 0; x < t.l_tetro.GetLength(2); x++) { for (int y = 0; y < t.l_tetro.GetLength(1); y++) { if (t.l_tetro[rotation, y, x] != 0) { if (fy + y + 1 >= G.FieldHeight || l_field[fx + x, fy + y + 1] != 0) { return(true); } } } } return(false); }
public void Draw(SpriteBatch spriteBatch) { for (int i = 0; i < G.FieldWidth; i++) { for (int j = 0; j < G.FieldHeight; j++) { Tetromino.DrawTetro(spriteBatch, tetroTexture, (Tetromino_Type)l_field[i, j], i, j); } } DrawGhost(spriteBatch); TetrominoQueue.ElementAt(0).Draw(spriteBatch, tetroTexture, currentX, currentY, rotation); TetrominoQueue.ElementAt(1).Draw(spriteBatch, tetroTexture, 12, 0, 0); TetrominoQueue.ElementAt(2).Draw(spriteBatch, tetroTexture, 17, 0, 0); TetrominoQueue.ElementAt(3).Draw(spriteBatch, tetroTexture, 22, 0, 0); if (heldTetromino != null) { heldTetromino.Draw(spriteBatch, tetroTexture, 12, 5, 0); } }
private void DrawGhost(SpriteBatch spriteBatch) { Tetromino hTetromino = new Tetromino(TetrominoQueue.ElementAt(0)) { tetroType = Tetromino_Type.Hh }; for (int y = currentY; y < G.FieldHeight; y++) { if (CheckTetromino(hTetromino, currentX, y)) { if (y == currentY) { break; } hTetromino.Draw(spriteBatch, tetroTexture, currentX, y, rotation); break; } } }
private bool CanMove(Tetromino t, int fx, int fy, int r) { for (int x = 0; x < t.l_tetro.GetLength(2); x++) { for (int y = 0; y < t.l_tetro.GetLength(1); y++) { if (t.l_tetro[r, y, x] != 0) { if (fx + x >= 0 && fx + x < G.FieldWidth && fy + y >= 0 && fy + y < G.FieldHeight) { if (l_field[fx + x, fy + y] != 0) { return(false); } } else { return(false); } } } } return(true); }
public Tetromino(Tetromino og) { this.l_tetro = og.l_tetro; this.tetroType = og.tetroType; }