This is the main type for your game
Exemplo n.º 1
0
        public Game1()
        {
            _graphics = new GraphicsDeviceManager(this);
            _graphics.PreferredBackBufferWidth = WIDTH;
            _graphics.PreferredBackBufferHeight = HEIGHT;

            Content.RootDirectory = "Content";

            _gameInstance = new GameInstance(_graphics, Content, this);
        }
Exemplo n.º 2
0
        public GameMenu(ContentManager content, GameInstance gameInstance, GameObject devil, GameObject angel)
        {
            _font = content.Load<SpriteFont>("Courier New");
            _title = content.Load<Texture2D>("title");
            _selectionBad = content.Load<Texture2D>("badpic");
            _selectionGod = content.Load<Texture2D>("godpic");
            _background = content.Load<Texture2D>("main");
            this.devil = devil;
            this.angel = angel;

            _titlePosition = new Vector2(300, 100);
            _selectionPosition = new Vector2(565-_selectionOffset, 250);
            _gameInstance = gameInstance;
        }
Exemplo n.º 3
0
        public void Update(GameInstance game)
        {
            KeyboardState keyState = Keyboard.GetState();
            if (_released && GamePad.GetState(PlayerIndex.One).Buttons.A == ButtonState.Pressed) // play again
            {
                _released = false;
                game.State = GameState.Playing;
            }
            if (_released && (GamePad.GetState(PlayerIndex.One).Buttons.B == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))) //return to menu
            {
                _released = false;
                game.State = GameState.Menu;
            }

            if (GamePad.GetState(PlayerIndex.One).Buttons.A == ButtonState.Released && GamePad.GetState(PlayerIndex.One).Buttons.B == ButtonState.Released
                && keyState.IsKeyUp(Keys.Escape))
            {
                _released = true;
            }
        }
Exemplo 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)
        {
            if(_gameInstance.Restart)
            {
                GameState nextState = _gameInstance.PreferredNextState;
                _gameInstance = new GameInstance(_graphics, Content, this);
                _gameInstance.Initialize(GraphicsDevice);
                _gameInstance.LoadContent();
                _gameInstance.State = nextState;
            }

            _gameInstance.Update(gameTime);
            base.Update(gameTime);
        }
Exemplo n.º 5
0
 public Controls(GameInstance gameInstance)
 {
     this.gameInstance = gameInstance;
 }