I have two classes one called GameObjects.cs, this initialises a object and its x and y values and my second class is Program.cs and in this I would like a way to randomise the x and y coordinates of the objects each time i run the codei.e. currently its is (10, 10) for example for a tree object.
Game Object class
namespace objectRandom
{
class GameObject
{
public string Name { get; }
public int X { get; }
public int Y { get; }
public GameObject(string name, int x, int y)
{
Name = name;
X = x;
Y = y;
}
public override string ToString()
{
return String.Format("Name: {0}, X: {1}, Y: {2}", Name, X, Y);
}
}
Program class
namespace objectRandom
{
class Program
{
static IEnumerable<GameObject> GenerateGameObjects(int mapWidth, int mapHeight)
{
List<GameObject> gameObjects = new List<GameObject>();
gameObjects.Add(new GameObject("Tree", 10, 10));
return gameObjects;
}
static void Main(string[] args)
{
foreach (GameObject gameObject in GenerateGameObjects(50, 50))
{
Console.WriteLine(gameObject);
}
}
}