예제 #1
0
        static void Main(string[] args)
        {
            Terminal.Open();
            Terminal.Set(string.Format("window.title='{0}'", "SharpSnake"));
            Terminal.Refresh();

            var consoleScreen = new ConsoleScreen(36, 28);
            var context       = new StateContext(consoleScreen, new Settings());
            var stateStack    = new StateStack(context);

            stateStack.RegisterState <MenuState>(StateId.Menu);
            stateStack.RegisterState <OptionsState>(StateId.Options);
            stateStack.RegisterState <PlayState>(StateId.Play);
            stateStack.RegisterState <GameOverState>(StateId.GameOver);
            stateStack.RegisterState <PauseState>(StateId.Pause);

            // Initial state
            stateStack.PushState(StateId.Menu);

            while (!stateStack.Empty)
            {
                stateStack.HandleInput();
                stateStack.Update();

                consoleScreen.Clear();
                stateStack.Draw();
                consoleScreen.Display();

                System.Threading.Thread.Sleep(16);
            }

            Terminal.Close();
        }