Beispiel #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()
        {
            //Initialize the board array
            board = new Gameboard(Constants.boardWidth, Constants.boardHeight,
                Content.Load<Texture2D>(Constants.unlitBlockName),
                Content.Load<Texture2D>(Constants.litBlockName), Content);//new LightButton[Constants.boardWidth, Constants.boardHeight];

            Vector2 startPosition = Constants.boardStartPosition;
            float posX = startPosition.X, posY = startPosition.Y;
            board.tiles[0, 0].Position = startPosition;

            Dimensions d = new Dimensions();
            d.width = (int)(((float)Constants.tileWidth) * Constants.scaleFactor);
            d.height = (int)(((float)Constants.tileHeight) * Constants.scaleFactor);
            int scaledOffset = (int)(((float)Constants.tileOffsetTop) * Constants.scaleFactor);

            for (int i = 0; i < Constants.boardWidth; i++)
            {
                for (int j = 0; j < Constants.boardHeight; j++)
                {
                    float Y = posY + (d.height * j);
                    float X = posX + (d.width * i);
                    board.tiles[i, j].Position = new Vector2(X, Y);
                }
            }

            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            background = Content.Load<Texture2D>(Constants.backgroundName);

            // Load the selection sprite
            selection = new Selector(Content.Load<Texture2D>(Constants.selectorName));
            viewportRect = new Rectangle(0, 0, graphics.GraphicsDevice.Viewport.Width, graphics.GraphicsDevice.Viewport.Height);

            // Load a puzzle
            board.LoadBoard("Puzzles\\Puzzles.xml", 1);
        }
Beispiel #2
0
 private Dimensions getBoardDimensionsInPixels()
 {
     Dimensions toReturn = new Dimensions();
     toReturn.width = tiles[0, 0].Sprite.Width * sizeAcross;
     toReturn.height = tiles[0, 0].Sprite.Height * sizeDown;
     return toReturn;
 }