示例#1
0
        public static void Initialize()
        {
            Limits.Clear();
            Sonidos.StopBGM();
            Sonidos.PlayBGM();

            Limits.Draw(4, "Green");
            Console.ForegroundColor = ConsoleColor.DarkRed;
            for (int i = 0; i < 12; i++)
            {
                Console.SetCursorPosition(i, 0);
                Console.Write("█");
            }
            for (int i = 1; i < 5; i++)
            {
                Console.SetCursorPosition(0, i);
                Console.Write("█");
                Console.SetCursorPosition(11, i);
                Console.Write("█");
            }
            Console.ResetColor();


            Lose  = false;
            Score = 0;
            Lines = 0;
            Level = 0;
            for (int i = 1; i < 24; i++)
            {
                for (int j = 1; j < 11; j++)
                {
                    Matriz[j, i] = false;
                }
            }


            for (int i = 0; i < 12; i++)
            {
                Matriz[i, 0]  = true;
                Matriz[i, 24] = true;
            }
            for (int i = 0; i < 25; i++)
            {
                Matriz[0, i]  = true;
                Matriz[11, i] = true;
            }
            UpdateStatus();
        }
示例#2
0
        public static void About()
        {
            afliw.Clear(0, Console.WindowHeight, 31, Console.WindowWidth);
            SetWindowWidth((int)WindowSize.About.Width);
            Box Content = new Box(31, 5, 41, 10);

            Content.Draw(0, "Blue");
            Console.SetCursorPosition(45, 6);
            Console.Write("afliw's Tetris");
            Console.SetCursorPosition(32, 8);
            Console.Write("Written by afliw.");
            Console.SetCursorPosition(32, 10);
            Console.Write("Tetris' orginal concept by Alexy Pajitnov.");
            Console.SetCursorPosition(32, 12);
            Console.Write("Music and Sounds extracted from");
            Console.SetCursorPosition(32, 13);
            Console.Write("Super Nintendo game \"Super Tetris 3\".");
            Console.SetCursorPosition(32, 15);
            Console.Write("Sound System: The irrKlang SDK v1.3.0");
            Console.SetCursorPosition(32, 16);
            Console.Write("by Nikolaus Gebhardt.");
        }
示例#3
0
        static void Main(string[] args)
        {
            SetConsoleFont(GetStdHandle(STDOUT_HANDLE), 8);
            bool Quit = false, ShowingScores = false, ShowingAbout = false;

            Console.Title         = "afliw's Tetris";
            Console.CursorVisible = false;
            string[] HighScoresArray = new string[0];
            Sonidos.StopBGM();
            LoadScores(ref HighScoresArray);
            Box    NextPieceBox      = new Box(14, 0, 3, 3);
            bool   Paused            = false;
            Piezas ObPieza           = new Piezas();
            Thread GamePlay          = new Thread(Game);

            Console.Clear();
            Writeafliw();
            WriteInstructions();
            Console.WindowHeight = (int)WindowSize.Regular.Height;
            Console.WindowWidth  = (int)WindowSize.Regular.Width;
            Console.BufferHeight = (int)WindowSize.Regular.Height;
            Console.BufferWidth  = (int)WindowSize.Regular.Width;
            ConsoleFunctions.SetConsoleFont(8);
            Playground.Initialize();
            ObPieza.Initialize();
            NextPieceBox.Draw(0, "Green");

            GamePlay.Start(ObPieza);
            string UserAction = " ";

            do
            {
                if (!Playground.Lose)
                {
                    switch (UserAction = Console.ReadKey(true).Key.ToString())
                    {
                    case "UpArrow": if (ObPieza.Available && !Paused)
                        {
                            ObPieza.RotatePiece();
                        }
                        break;

                    case "DownArrow": if (ObPieza.Available && !Paused)
                        {
                            ObPieza.Fall();
                        }
                        Playground.PointsByFall(); break;

                    case "LeftArrow": if (ObPieza.Available && !Paused)
                        {
                            ObPieza.MoveLeft();
                        }
                        break;

                    case "RightArrow": if (ObPieza.Available && !Paused)
                        {
                            ObPieza.MoveRight();
                        }
                        break;

                    case "Enter": PauseGame(GamePlay, ref Quit, ref ObPieza); break;

                    case "Spacebar":
                        ShowingScores = ShowingScores ? false : true;
                        if (ShowingScores)
                        {
                            ShowScoresTable(HighScoresArray, -1);
                            if (ShowingAbout)
                            {
                                ShowingAbout = false;
                            }
                        }
                        else
                        {
                            SetWindowWidth((int)WindowSize.Regular.Width);
                        }
                        ConsoleFunctions.FlushConsoleInputBuffer();
                        break;

                    case "F1":
                        ShowingAbout = ShowingAbout ? false : true;
                        if (ShowingAbout)
                        {
                            About();
                            if (ShowingScores)
                            {
                                ShowingScores = false;
                            }
                        }
                        else
                        {
                            SetWindowWidth((int)WindowSize.Regular.Width);
                        }
                        ConsoleFunctions.FlushConsoleInputBuffer();
                        break;
                    }
                }
                else
                {
                    int i;
                    for (i = 0; i < HighScoresArray.Length && ConvertScore(HighScoresArray[i]) >= Playground.Score; i++)
                    {
                        ;
                    }
                    if (i < HighScoresArray.Length - 1 || (i == HighScoresArray.Length - 1 && ConvertScore(HighScoresArray[HighScoresArray.Length - 1]) < Playground.Score))
                    {
                        afliw.Clear(0, Console.WindowHeight, 31, Console.WindowWidth);
                        SetWindowWidth((int)WindowSize.SaveScore.Width);
                        string PlayersName;
                        Console.SetCursorPosition(37, 5);
                        Console.ForegroundColor = ConsoleColor.Cyan;
                        Console.Write("CONGRATULATIONS!");
                        Console.ResetColor();
                        Console.SetCursorPosition(35, 6);
                        Console.Write("You've made it in to");
                        Console.SetCursorPosition(34, 7);
                        Console.Write("the top 10 best scores.");
                        InputField getname = new InputField(15, true, true, true, false, false);
                        PlayersName = getname.GetString(33, 9, true, "Name ", true);


                        for (int j = HighScoresArray.Length - 1; j > i; j--)
                        {
                            HighScoresArray[j] = HighScoresArray[j - 1];
                        }
                        HighScoresArray[i] = PlayersName + "|" + Playground.Achivements();
                        SaveScores(ref HighScoresArray);
                        afliw.Clear(0, Console.WindowHeight, 32, Console.WindowWidth);
                        ShowScoresTable(HighScoresArray, i);
                    }
                    Console.SetCursorPosition(4, 8);
                    Console.Write("Play");
                    Console.SetCursorPosition(3, 9);
                    Console.Write("again?");
                    Menu Retry = new Menu(4, 11, -1, "Gray");
                    Retry.AddItem("Yes", "No");
                    if (Retry.DrawMenu(0) == 0)
                    {
                        RestartGame(ref ObPieza);
                    }
                    else
                    {
                        Quit = true;
                    }
                }
            }while(!Quit);
            try
            {
                GamePlay.Abort();
            }
            catch (Exception)
            {
                GamePlay.Resume();
                GamePlay.Abort();
            }
        }
示例#4
0
        public static void Options()
        {
            SetWindowWidth((int)WindowSize.Options.Width);
            afliw.Clear(0, Console.BufferHeight - 1, 31, Console.BufferWidth - 1);
            Box OptionsBox = new Box(31, 0, Console.BufferWidth - 34, Console.BufferHeight - 3);

            OptionsBox.Draw(0, "Magenta");
            string[] Opciones = { "Shadow", "Sounds", "Sound Volume", "Tetris' Flash", "Music", "Music Volume", "Back" };

            for (int i = 0; i < 7; i++)
            {
                Console.SetCursorPosition(35, 2 + (i * 3));
                Console.Write(Opciones[i]);
            }

            for (int i = 0; i < 6; i++)
            {
                OptSwitch(i, 0);
            }

            ushort[,] Normal = new ushort[1, Opciones[3].Length];
            for (int i = 0; i < Normal.GetLength(1); i++)
            {
                Normal[0, i] = 7;
            }
            int  Selected = 0;
            bool Back     = false;
            int  SaveBGM  = Sonidos.CurrentBGM;

            do
            {
                ushort[,] Highlight = new ushort[1, Opciones[Selected].Length];

                for (int i = 0; i < Highlight.GetLength(1); i++)
                {
                    Highlight[0, i] = 128;
                }
                for (int i = 0; i < Opciones.Length; i++)
                {
                    ConsoleFunctions.WriteConsoleAttribute(35, 2 + (i * 3), Normal);
                    if (i == Selected)
                    {
                        ConsoleFunctions.WriteConsoleAttribute(35, 2 + (i * 3), Highlight);
                    }
                }

                switch (Console.ReadKey(true).Key)
                {
                case ConsoleKey.UpArrow: if (Selected == 0)
                    {
                        Selected = 6;
                    }
                    else
                    {
                        Selected--;
                    } break;

                case ConsoleKey.DownArrow: if (Selected == 6)
                    {
                        Selected = 0;
                    }
                    else
                    {
                        Selected++;
                    } break;

                case ConsoleKey.RightArrow: OptSwitch(Selected, 1); break;

                case ConsoleKey.LeftArrow: OptSwitch(Selected, -1); break;

                case ConsoleKey.Enter: if (Selected == 6)
                    {
                        Back = true;
                    }
                    break;
                }
            }while(!Back);
            if (SaveBGM != Sonidos.CurrentBGM)
            {
                Sonidos.StopBGM();
                Sonidos.ChangeBGM();
            }
            SetWindowWidth((int)WindowSize.Regular.Width);
        }