Ejemplo n.º 1
0
        public void Draw(Renderer renderer, TetrisView view, int row, int column, out TetrisPoint[] alloc)
        {
            IPiece piece = view.Model[row, column];

            if (piece == null)
            {
                alloc = new TetrisPoint[0];
                return;
            }
            List <TetrisPoint> list = new List <TetrisPoint>();

            for (int i = 0; i < piece.Width; i++)
            {
                for (int j = 0; j < piece.Height; j++)
                {
                    int realRow    = row + j;
                    int realColumn = column + i;
                    if (!piece.IsVisible(row, column, realRow, realColumn))
                    {
                        continue;
                    }
                    Vector2 pos = view.ModelToView(realRow, realColumn);
                    list.Add(new TetrisPoint(realRow, realColumn));
                    TetrisColorEnum?colorE = piece.RenderingSource as TetrisColorEnum?;
                    if (!colorE.HasValue)
                    {
                        throw new ArgumentException();
                    }
                    DrawAt(renderer, pos, colorE.Value);
                }
            }
            alloc = list.ToArray();
        }
Ejemplo n.º 2
0
 public Game1()
 {
     this.graphics         = new GraphicsDeviceManager(this);
     Content.RootDirectory = "Content";
     this.tetrisView       = new TetrisView(14, 9);
     tetrisView.Position   = new Vector2(32, 0);
 }
Ejemplo n.º 3
0
 public TetrisModel(TetrisView view)
 {
     tetrisView = view;
     InitAll();
 }