Esempio n. 1
0
        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            // Set the window size
            graphics.PreferredBackBufferWidth = 800;
            graphics.PreferredBackBufferHeight = 600;

            currentState = nextState = GameState.START;
            currentScene = new Start(this);
            Components.Add(currentScene);
        }
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)
        {
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                this.Exit();

            // TODO: Add your update logic here
            if (currentState != nextState)
            {
                Components.Remove(currentScene);
                switch (nextState)
                {
                    case GameState.START:
                        break;
                    case GameState.PLAY:
                        currentScene = new Play(this);
                        break;
                    case GameState.FINISH:
                        currentScene = new Finish(this);
                        break;
                }
                Components.Add(currentScene);
                currentState = nextState;
            }

            base.Update(gameTime);
        }