Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Console.CursorVisible = false;


            MenuWindow menuWindow = new MenuWindow();

            menuWindow.SetButtonActive(ButtonName.Start);
            menuWindow.SetButtonActive(ButtonName.Quit);

            menuWindow.Draw();



            //Window menu = new Window(0, 0, 120, 30, "MENU");
            //menu.Draw();



            /*
             * Diamond diamond = new Diamond(5, 10);
             * diamond.Draw();
             *
             * Candle candle = new Candle(40, 3);
             * candle.Draw();
             *
             *
             * Rectangle rectangle = new Rectangle(60, 10, 15, 10);
             * rectangle.Draw();
             *
             * Rectangle rectangle2 = new Rectangle(60, 7, 5, 7, '+');
             * rectangle2.Draw();
             *
             * int x = 30;
             * int y = 15;
             * int width = 20;
             * TextLine textLine = new TextLine(x, y, width, "My super todo list app!");
             * textLine.Draw();
             *
             *
             *
             *
             * Console.ReadKey();
             *
             */
            Console.ReadKey();
            Console.SetCursorPosition(0, 25);
        }
Ejemplo n.º 2
0
    public void ShowMenu()
    {
        Console.SetWindowSize(GameEngine.GameScreenWidth, GameEngine.GameScreenHeight);
        Console.SetBufferSize(GameEngine.GameScreenWidth, GameEngine.GameScreenHeight);

        RenderWindowIfNotAlreadyOpened(_menuWindow);

        int keyCode;

        do
        {
            keyCode = Console.ReadKey(true).Key.GetHashCode();
        } while (keyCode != 37 && keyCode != 39 && keyCode != 13);

        if (keyCode == 37)
        // left arrow
        {
            if (_menuWindow.GetCurrentButtonActive() > 0)
            {
                _menuWindow.SetButtonActive(_menuWindow.GetCurrentButtonActive() - 1);
                _menuWindow.RenderButtons();
            }
            ShowMenu();
        }

        else if (keyCode == 39)
        // right arrow
        {
            if (_menuWindow.GetCurrentButtonActive() < _menuWindow.ButtonCount - 1)
            {
                _menuWindow.SetButtonActive(_menuWindow.GetCurrentButtonActive() + 1);
                _menuWindow.RenderButtons();
            }
            ShowMenu();
        }

        else if (keyCode == 13)
        // enter
        {
            _menuWindow.IsAlreadyOpen = false;

            switch (_menuWindow.GetCurrentButtonActive())
            {
            case 0:
                ShowCredits();
                break;

            case 1:
                ShowHighScore();
                break;

            case 2:
                // start game
                GameEngine.StartGame();
                break;

            case 3:
                // enable/disable sound
                SoundManager.EnableOrDisableMusic();
                _menuWindow.IsAlreadyOpen = true;
                ShowMenu();
                break;

            case 4:
                ShowExitWindow();
                break;
            }
        }
    }