Пример #1
0
        //Stein drehen
        public void CurrTetraminoMoveRotate()
        {
            Point Position = currTetramino.getCurrPosition();

            Point[] Shape = currTetramino.getCurrShape();
            Point[] S     = new Point[4];
            bool    move  = true;

            Shape.CopyTo(S, 0);   //Form in Point Array S kopieren
            currTetraminoErase(); //Stein löschen

            for (int i = 0; i < S.Length; i++)
            {
                //simulieren der Rotation
                double x = S[i].X;    //temporäre Variable
                S[i].X = S[i].Y * -1; // X-Koordinate durch Y-Koordinate * -1 ersetzen
                S[i].Y = x;
                //Prüfung der Y-Koordinaten
                if (((int)((S[i].Y + Position.Y) + 2)) >= Rows)
                {
                    move = false;
                }
                //Prüfung der X-Koordinaten nach links
                else if (((int)(S[i].X + Position.X) + ((Cols / 2) - 1)) < 0)
                {
                    move = false;
                }
                //Prüfung der X-Koordinaten nach rechts
                else if (((int)(S[i].X + Position.X) + ((Cols / 2) - 1)) >= Rows)
                {
                    move = false;
                }
                //Blockade im Weg, d.h. Feld farbig?
                else if (BlockControls[((int)(S[i].X + Position.X) + ((Cols / 2) - 1)), (int)(S[i].Y + Position.Y) + 2].Background != NoBrush)
                {
                    move = false;
                }
            }
            //wenn move == true -> drehen
            if (move)
            {
                currTetramino.movRotate();
                currTetraminoDraw();
            }
            //ansonsten Stein neu zeichnen, d.h. nicht drehen
            else
            {
                currTetraminoDraw();
            }
        }