Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PieceShape.I behavior #1

Closed
ojh050118 opened this issue Jun 24, 2022 · 0 comments
Closed

PieceShape.I behavior #1

ojh050118 opened this issue Jun 24, 2022 · 0 comments

Comments

@ojh050118
Copy link
Owner

Tetris.Game/Pieces/PieceGroupExtension.cs #L68 ~

foreach (var piece in group.Pieces)
            {
                var newX = (float)((piece.X - centerPosition.X) * Math.Cos(rotateRadian) - (piece.Y - centerPosition.Y) * Math.Sin(rotateRadian));
                var newY = (float)((piece.X - centerPosition.X) * Math.Sin(rotateRadian) + (piece.Y - centerPosition.Y) * Math.Cos(rotateRadian));

                piece.Position = centerPosition + new Vector2(newX, newY);

                if (group.PieceType == PieceShape.I)
                {
                    switch (group.Rotation)
                    {
                        case 90:
                            piece.Position += new Vector2(0, 30);
                            break;

                        case 180:
                            piece.Position += new Vector2(-30, 0);
                            break;

                        case 270:
                            piece.Position += new Vector2(0, -30);
                            break;

                        case 360:
                            piece.Position += new Vector2(30, 0);
                            break;
                    }
                }
            }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant