vendredi 2 octobre 2020

Is it possible to make a public random variable in C#?

I have window being updated in a while loop to allow for shapes to move.

while (!Window.CloseRequest)
{
  game.Update();
  if (game.Quit) break;   
}
Window.Close();

And within the Update function I am drawing a shape

//Generate Random Int outside Update()

public void Update()
{
_GameWindow.Clear(Color.Blue);
_Object.Draw();
_GameWindow.Refresh(60);

I am trying to pass a Random number into the Update function. Is it possible to make a public Random variable with a random type? If I have it within the Update method the number is changing each time the loop happens.




Aucun commentaire:

Enregistrer un commentaire