Exemplo n.º 1
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            _spriteBatch = new SpriteBatch(GraphicsDevice);

            // TODO: use this.Content to load your game content here
            _spr = Content.Load<SpriteFont>("spritefont");
            _tank1 = Content.Load<Texture2D>("tank1");
            _tank2 = Content.Load<Texture2D>("tank2");
            _cannon1 = Content.Load<Texture2D>("cannon1");
            _cannon2 = Content.Load<Texture2D>("cannon2");
            _cannonball1 = Content.Load<Texture2D>("cannonball1");
            _cannonball2 = Content.Load<Texture2D>("cannonball2");
            _back = Content.Load<Texture2D>("test1");
            _textureNormal = Content.Load<Texture2D>("test1_map");

            _deferred = Content.Load<Effect>("deferred");

            _tankmodel1 = new Tank(_tank1, _cannon1, _cannonball1, new Vector2(50, 550), 1,_spr);
            _tankmodel2 = new Tank(_tank2, _cannon2, _cannonball2, new Vector2(750, 50), 2,_spr);
            _lights = new Lights(_back, _textureNormal, _deferred);
        }
Exemplo 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
            var kb = Keyboard.GetState();
            if (kb.IsKeyDown(Keys.Q) && _flag == 0)
                this.Exit();
            if (kb.IsKeyDown(Keys.Escape))
            {
                _flag = 0;
                _tankmodel1 = new Tank(_tank1, _cannon1, _cannonball1, new Vector2(50, 500), 1, _spr);
                _tankmodel2 = new Tank(_tank2, _cannon2, _cannonball2, new Vector2(750, 100), 2,_spr);
                _lights = new Lights(_back, _textureNormal, _deferred);
            }
            if (kb.IsKeyDown(Keys.Space))
                _flag = 1;

            // TODO: Add your update logic here
            if (_flag==1)
            {
                _tankmodel1.Update(kb, _tankmodel2.pos, 1, gameTime);
                _tankmodel2.Update(kb, _tankmodel1.pos, 2, gameTime);
                _lights.Update(_tankmodel1.pos, _tankmodel2.pos);
            }

            base.Update(gameTime);
        }