Exemple #1
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 (Keyboard.GetState().IsKeyDown(Keys.NumPad0))
            {
                Board.StopGame = false;
            }
            if (Keyboard.GetState().IsKeyDown(Keys.NumPad1))
            {
                Board.StopGame = true;
            }

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

            this.TargetElapsedTime = TimeSpan.FromSeconds(1.0f / Settings.SzybkoscGry);
            //TargetElapsedTime ?? change frequency of update
            if (!Board.StopGame)
            {
                GlobalVariables.KeyboardController.Update();

                Object2DEngine.Update(Board);
                GlobalVariables.KeyboardController.UpdateOld();

                base.Update(gameTime);
            }
        }
Exemple #2
0
        public void IsObjects2DCollidingTest()
        {
            Object2DEngine obj = new Object2DEngine();

            var path = Path.GetFullPath(Path.Combine(Environment.CurrentDirectory, @"..\..\..\GameRunningCube\Content\2D\"));

            var player = new Player(new Vector2(300, 600), new Vector2(19, 19), path + "Player.xnb");
            var enemy  = new Enemy(new Vector2(300, 600), new Vector2(19, 19), path + "Enemy.xnb");

            Assert.IsTrue(obj.IfTwoObjectsColiding(enemy, player));
        }
Exemple #3
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            GlobalVariables.Content            = this.Content;
            GlobalVariables.SpriteBatch        = new SpriteBatch(GraphicsDevice);
            GlobalVariables.KeyboardController = new KeyboardController();
            GlobalVariables.ObjectGenerator    = new ObjectGenerator();

            GlobalVariables.SpriteFont = Content.Load <SpriteFont>("FontArial");

            Board          = new GameBoard(Settings);
            Object2DEngine = new Object2DEngine();
        }