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()
        {
            // TODO: Add your initialization logic here

            W = Window.ClientBounds.Width;
            H = Window.ClientBounds.Height;

            _ground1 = new Ground(0, (H - 20));
            _ground2 = new Ground(0, 0);
            _goku = new Player();

            base.Initialize();
        }
Example #2
0
        public void CheckBackground(Ground back)
        {
            if(_pos.X == 600)
            {
                _offset += 2;
                back.Position -= back.Position + new Vector2((float)(_offset), 0);
            }

            if (_pos.X == 200)
            {
                _offset -= 2;
                back.Position -= back.Position + new Vector2((float)(_offset), 0);
            }
        }
Example #3
0
        public void Update(GameTime gameTime, Ground back)
        {
            _keyboard = Keyboard.GetState();

            if (_keyboard.IsKeyDown(Keys.Right))
            {
                if (_pos.X < 600)
                    this._pos = new Vector2((_pos.X += 2), _pos.Y);
                else
                    CheckBackground(back);
            }
            else if (_keyboard.IsKeyDown(Keys.Left))
            {
                if (_pos.X > 200)
                    this._pos = new Vector2((_pos.X -= 2), _pos.Y);
                else
                    CheckBackground(back);
            }
        }