Example #1
0
 public TileRenderer(Tile data)
 {
     this.data = data;
     rectangleShape = new RectangleShape();
     rectangleShape.Size = this.data.Size;
     rectangleShape.FillColor = data.FillColor;
 }
Example #2
0
        public Tile(TileType tileType)
        {
            Size = new Vector2f(32, 32);
            Children = new Tile[8];
            Type = tileType;

            setTileType(tileType);
        }
Example #3
0
        public Map(Vector2i mapSize)
        {
            //need to make the map one unit bigger for the void frame
            mapSize.X++;
            mapSize.Y++;
            Size = new Vector2f(mapSize.X * 32, mapSize.Y * 32);
            Position = new Vector2f(-32, -32);

            tiles = new Tile[mapSize.X + 2, mapSize.Y + 2];
            rand = new Random();

            randomiseMap();
            setTileChildren();
        }
Example #4
0
        /// <summary>
        /// Makes the map random.
        /// </summary>
        private void randomiseMap()
        {
            int tmpNum = 0;
            for (int x = 0; x < tiles.GetLength(0); x++)
            {
                for (int y = 0; y < tiles.GetLength(1); y++)
                {
                    if (x == 0 || x == tiles.GetLength(0) - 1)
                    {
                        tiles[x, y] = null;
                    }

                    else if (y == 0 || y == tiles.GetLength(1) - 1)
                    {
                        tiles[x, y] = null;
                    }

                    else
                    {
                        tmpNum = rand.Next(0, 100);

                        if (tmpNum <= 80)
                            tiles[x, y] = new Tile(Tile.TileType.GRASS);
                        else if (tmpNum >= 80 && tmpNum <= 100)
                            tiles[x, y] = new Tile(Tile.TileType.DIRT);
                        //set the position
                        tiles[x, y].Position = new SFML.Window.Vector2f(x * 32 + Position.X, y * 32 + Position.Y);
                    }
                }
            }
        }