private Point GetOrthogonalLocation(TiledTile tile)
        {
            var tx = tile.X * _map.TileWidth;
            var ty = tile.Y * _map.TileHeight;

            return(new Point(tx, ty));
        }
        private void RenderOrthogonal(TiledTile tile, TextureRegion2D region)
        {
            var tx = tile.X * _map.TileWidth;
            var ty = tile.Y * _map.TileHeight;

            _spriteBatch.Draw(region, new Rectangle(tx, ty, region.Width, region.Height), Color.White);
        }
Exemple #3
0
        private void RenderOrthogonal(TiledTile tile, TextureRegion2D region)
        {
            // not exactly sure why we need to compensate 1 pixel here. Could be a bug in MonoGame?
            var tx = tile.X*(_map.TileWidth - 1);
            var ty = tile.Y*(_map.TileHeight - 1);

            _spriteBatch.Draw(region, new Rectangle(tx, ty, region.Width, region.Height), Color.White);
        }
        private Point GetIsometricLocation(TiledTile tile)
        {
            var halfTileWidth  = _map.TileWidth / 2;
            var halfTileHeight = _map.TileHeight / 2;
            var tx             = tile.X * halfTileWidth - tile.Y * halfTileWidth + _map.Width * halfTileWidth;
            var ty             = tile.Y * halfTileHeight + tile.X * halfTileHeight - _map.TileWidth + _map.TileHeight;

            return(new Point(tx, ty));
        }
        private void RenderIsometric(TiledTile tile, TextureRegion2D region)
        {
            var halfTileWidth  = _map.TileWidth / 2;
            var halfTileHeight = _map.TileHeight / 2;
            var tx             = tile.X * halfTileWidth - tile.Y * halfTileWidth + _map.Width * halfTileWidth;
            var ty             = tile.Y * halfTileHeight + tile.X * halfTileHeight - _map.TileWidth + _map.TileHeight;

            _spriteBatch.Draw(region, new Rectangle(tx, ty, region.Width, region.Height), Color.White);
        }
Exemple #6
0
        private void RenderIsometric(TiledTile tile, TextureRegion2D region)
        {
            var tx = (tile.X*(_map.TileWidth / 2)) - (tile.Y*(_map.TileWidth / 2)) 
                //Center
                + (_map.Width * (_map.TileWidth/2)) 
                //Compensate Bug?
                - (_map.TileWidth / 2);
                
            var ty = (tile.Y*(_map.TileHeight/2)) + (tile.X*(_map.TileHeight/2)) 
                //Compensate Bug?
                - (_map.TileWidth + _map.TileHeight);

            _spriteBatch.Draw(region, new Rectangle(tx, ty, region.Width, region.Height), Color.White);
        }
        private TiledTile[] CreateTiles(int[] data)
        {
            var tiles = new TiledTile[data.Length];
            var index = 0;

            for (var y = 0; y < Height; y++)
            {
                for (var x = 0; x < Width; x++)
                {
                    tiles[x + y * Width] = new TiledTile(data[index], x, y);
                    index++;
                }
            }

            return tiles;
        }
 private void RenderLayer(TiledMap map, TiledTile tile, TextureRegion2D region)
 {
     switch (map.Orientation)
     {
         case TiledMapOrientation.Orthogonal:
             RenderOrthogonal(tile,region);
             break;
         case TiledMapOrientation.Isometric:
             RenderIsometric(tile, region);
             break;
         case TiledMapOrientation.Staggered:
             throw new NotImplementedException("Staggered maps are currently not supported");
         default:
             throw new ArgumentOutOfRangeException();
     }
 }
        private TiledTile[] CreateTiles(int[] data)
        {
            var tiles = new TiledTile[data.Length];
            var index = 0;

            for (var y = 0; y < Height; y++)
            {
                for (var x = 0; x < Width; x++)
                {
                    tiles[x + y * Width] = new TiledTile(data[index], x, y);
                    index++;
                }
            }

            return(tiles);
        }
Exemple #10
0
 private void RenderLayer(TiledMap map, TiledTile tile, TextureRegion2D region)
 {
     switch (map.Orientation)
     {
         case TiledMapOrientation.Orthogonal:
             RenderOrthogonal(tile,region);
             break;
         case TiledMapOrientation.Isometric:
             RenderIsometric(tile, region);
             break;
         case TiledMapOrientation.Staggered:
             throw new NotImplementedException("Staggered maps are currently not supported");
         default:
             throw new ArgumentOutOfRangeException();
     }
 }
 private Point GetIsometricLocation(TiledTile tile)
 {
     var halfTileWidth = _map.TileWidth / 2;
     var halfTileHeight = _map.TileHeight / 2;
     var tx = tile.X * halfTileWidth - tile.Y * halfTileWidth + _map.Width * halfTileWidth;
     var ty = tile.Y * halfTileHeight + tile.X * halfTileHeight - _map.TileWidth + _map.TileHeight;
     return new Point(tx, ty);
 }
 private Point GetOrthogonalLocation(TiledTile tile)
 {
     var tx = tile.X * _map.TileWidth;
     var ty = tile.Y * _map.TileHeight;
     return new Point(tx, ty);
 }
        private void RenderIsometric(TiledTile tile, TextureRegion2D region)
        {
            var tx = (tile.X*(_map.TileWidth / 2)) - (tile.Y*(_map.TileWidth / 2)) 
                //Center
                + (_map.Width * (_map.TileWidth/2)) 
                //Compensate Bug?
                - (_map.TileWidth / 2);
                
            var ty = (tile.Y*(_map.TileHeight/2)) + (tile.X*(_map.TileHeight/2)) 
                //Compensate Bug?
                - (_map.TileWidth + _map.TileHeight);

            _spriteBatch.Draw(region, new Rectangle(tx, ty, region.Width, region.Height), Color.White);
        }
Exemple #14
0
        private void RenderOrthogonal(TiledTile tile, TextureRegion2D region)
        {
            var tx = tile.X * _map.TileWidth;
            var ty = tile.Y * _map.TileHeight;

            _spriteBatch.Draw(region, new Rectangle(tx, ty, region.Width, region.Height), Color.White);
        }
Exemple #15
0
        private void RenderIsometric(TiledTile tile, TextureRegion2D region)
        {
            var halfTileWidth = _map.TileWidth / 2;
            var halfTileHeight = _map.TileHeight / 2;
            var tx = tile.X * halfTileWidth - tile.Y * halfTileWidth + _map.Width * halfTileWidth;
            var ty = tile.Y * halfTileHeight + tile.X * halfTileHeight - _map.TileWidth + _map.TileHeight;

            _spriteBatch.Draw(region, new Rectangle(tx, ty, region.Width, region.Height), Color.White);
        }