Beispiel #1
0
    /*
     *      Draws a grid of tetris cells onto any canvas node, with a given cell width.
     */
    public static void DrawTetrisGrid(CanvasItem node, IGrid <TetrisCell> grid, float cellWidth)
    {
        var textures = node.GetNode <TetrominoTextures>("/root/gui/tetromino_textures").Textures;

        foreach (var pos in Utils.Range2D(grid.Cells.GetSize()))
        {
            if (grid.Cells[pos.Y][pos.X] != TetrisCell.Empty)
            {
                node.DrawTextureRect(
                    textures[grid.Cells[pos.Y][pos.X]],
                    new Rect2(pos.X * cellWidth, pos.Y * cellWidth, cellWidth, cellWidth),
                    false
                    );
            }
        }
    }