Ejemplo n.º 1
0
        public void RotateCCW()
        {
            if (this.game_end)
            {
                return;
            }
            Tetromino f    = this.minos.First();
            int       left = f.GetLeft();

            f.RotateCW();
            bool revert = false;

            foreach (System.Drawing.Rectangle r in this.minos.First().GetRectangles(0, 0))
            {
                int x = r.X / this.scale;
                int y = r.Y / this.scale;
                if (x >= 0 && x < 10 && y >= 0 && y < 20)
                {
                    revert |= this.grid[x, y].Color != System.Drawing.Color.FromArgb(128, 255, 255, 255);
                }
            }
            if (revert)
            {
                f.RotateCCW();
                int displacement = left - f.GetLeft();
                f.SetStart(displacement, 0);
            }
        }
Ejemplo n.º 2
0
        // Moves current block to the left
        public void MoveLeft()
        {
            if (game_end)
            {
                return;
            }
            Tetromino f = this.minos.First();

            if (f.GetLeft() > 0)
            {
                // check if any blocks are to the right
                bool go = true;
                foreach (System.Drawing.Rectangle rect in f.GetRectangles(0, 0))
                {
                    int x = (rect.X - this.scale) / this.scale;
                    int y = rect.Y / this.scale;
                    if (y < 0)
                    {
                        continue;
                    }
                    go &= (grid[x, y].Color == System.Drawing.Color.FromArgb(128, 255, 255, 255));
                    if (y < 20)
                    {
                        go &= (grid[x, y + 1].Color == System.Drawing.Color.FromArgb(128, 255, 255, 255));
                    }
                }

                if (go)
                {
                    f.Shift(false);
                }
            }
        }