Example #1
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            this.scenes = new Dictionary<MyGameStates, GameScene>();

            // TODO: Add your initialization logic here
            TitleScreenScene scene1 = new TitleScreenScene(this);
            MazeScene scene2 = new MazeScene(this);

            this.Components.Add(scene1);
            this.Components.Add(scene2);

            scene1.Visible = true;
            scene1.Enabled = true;

            this.scenes.Add(MyGameStates.Welcome, scene1);
            this.scenes.Add(MyGameStates.GamePlay, scene2);

            this.currentGameState = MyGameStates.Welcome;

            base.Initialize();
        }
Example #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)
        {
            KeyboardState state = Keyboard.GetState();

            //Saída
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || state.IsKeyDown(Keys.Escape))
                Exit();

            if(state.IsKeyDown(Keys.A))
            {
                this.soundTest.Play();
            }

            //Fullscreen
            if (state.IsKeyDown(Keys.LeftAlt) && state.IsKeyDown(Keys.Enter))
            {
                MyGame.Graphics.IsFullScreen = !MyGame.Graphics.IsFullScreen;
                MyGame.Graphics.ApplyChanges();
            }

            //Tela de apresentação para gameplay
            if (this.currentGameState == MyGameStates.Welcome)
            {
                if (state.IsKeyDown(Keys.Enter))
                {
                    this.scenes[MyGameStates.Welcome].End();
                    this.scenes[MyGameStates.GamePlay].Begin();

                    this.currentGameState = MyGameStates.GamePlay;
                }
            }

            // TODO: Add your update logic here
            base.Update(gameTime);
        }