Esempio n. 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();
        }
Esempio n. 2
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            // TODO: Add your update logic here
            gGameMode.Update(gameTime);
            base.Update(gameTime);
        }
Esempio n. 3
0
        protected override void Update(GameTime gameTime)
        {
            KeyboardWrapper.UpdateState();
            GamePadWrapper.UpdateAllGamePads();
            MouseUtility.Update();
            FrameCounter.IncrementFrameCount();

            myStateStack.ResolveQueuedThings();

            if (myStateStack.GetCurrentState() == null)
            {
                Exit();
                return;
            }

            myStateStack.Update();

            base.Update(gameTime);
            NetPostMaster.Master.ResolveMessages();
        }
Esempio n. 4
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            _time.Update(gameTime);

            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            // TODO: Add your update logic here
            InputManager.UpdateCurrentStates();

            if (InputManager.OnKeyDown(Keys.Tab))
            {
                _gameConsole.Open(Keys.Tab);
            }

            _stateStack.Update(gameTime);

            InputManager.UpdatePreviousStates();

            base.Update(gameTime);
        }