コード例 #1
0
        public void Render(TileLayout tileLayout)
        {
            spriteBatch.Begin();

            var top = 0;

            foreach (var tileRow in tileLayout.GetTileMatrix())
            {
                var tileVisualRow = tileRow.Select(tile => tileVisualFactory.CreateTileVisual(tile)); // turn all the Tile's into TileVisual's
                var left = 0;

                foreach (var tile in tileVisualRow)
                {
                    var rectangle = new Rectangle(left, top, tile.Width, tile.Height);

                    spriteBatch.Draw(tile.Visual, rectangle, Color.White);

                    //#magic number alert!
                    left += 64; // tile.Width; // not all widths are the same
                }
                top += tileVisualRow.Max(r => r.Height);
            }

            spriteBatch.End();
        }
コード例 #2
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()
        {
            // Model
            tileLayout = new TileLayoutBuilder()
                .GetInitialLayout();

            base.Initialize();
        }