Beispiel #1
0
        protected override void Initialize()
        {
            this.previousMouseState      = Mouse.GetState();
            this.simpleGroundTextureRect = new Rectangle(192, 182, 48, 40);
            // Ground
            int groundTilesNum = this.graphics.PreferredBackBufferWidth / this.simpleGroundTextureRect.Width;

            if ((this.graphics.PreferredBackBufferWidth % this.simpleGroundTextureRect.Width) > 0)
            {
                groundTilesNum++;
            }
            Vector2 currentPosition = new Vector2(0, this.graphics.PreferredBackBufferHeight - this.simpleGroundTextureRect.Height);

            for (var i = 0; i < groundTilesNum; i++)
            {
                var ground = new GameElement();
                ground.Initialize(SURFACES_TEXTURE_ID, currentPosition, this.simpleGroundTextureRect);
                this.elementsService.GameElements.Add(ground);
                currentPosition.X += this.simpleGroundTextureRect.Width;
            }
            base.Initialize();
        }