Ejemplo n.º 1
0
        public Background(Texture2D texture, GameWindow window)
        {
            //Set amount of sprites on the width
            double tmpX = (double)window.ClientBounds.Width / texture.Width;

            nrBackgroundsX = (int)Math.Ceiling(tmpX);
            //Set amount of sprites on the height
            double tmpY = (double)window.ClientBounds.Height / texture.Height;

            nrBackgroundsY = (int)Math.Ceiling(tmpY) + 1;

            //Set array size
            backgroundSprites = new BackgroundSprite[nrBackgroundsX, nrBackgroundsY];

            //Fill array
            for (int i = 0; i < nrBackgroundsX; i++)
            {
                for (int j = 0; j < nrBackgroundsY; j++)
                {
                    int posX = i * texture.Width;
                    //Set the top row above the window
                    int posY = j * texture.Height - texture.Height;
                    backgroundSprites[i, j] = new BackgroundSprite(texture, posX, posY);
                }
            }
        }
Ejemplo n.º 2
0
        public Background(Texture2D texture, GameWindow gameWindow)
        {
            double tmpX = (double)gameWindow.ClientBounds.Width / texture.Width;

            nrBackgroundsX = (int)Math.Ceiling(tmpX);
            double tmpY = (double)gameWindow.ClientBounds.Height / texture.Height;

            nrBackgroundsY = (int)Math.Ceiling(tmpY) + 1;
            background     = new BackgroundSprite[nrBackgroundsX, nrBackgroundsY];
            for (int i = 0; i < nrBackgroundsX; i++)
            {
                for (int j = 0; j < nrBackgroundsY; j++)
                {
                    int posX = i * texture.Width;
                    int posY = j * texture.Height - texture.Height;
                    background[i, j] = new BackgroundSprite(texture, posX, posY);
                }
            }
        }