//the draw function
{
graphics.GraphicsDevice.Clear(Color.Black);
spriteBatch.Begin();
spriteBatch.Draw (circle, new Rectangle(circlePosY + 180, circlePosX + 180, circle.Height, circle.Width), Color.White);
spriteBatch.Draw(circleG, new Rectangle(0, 0, circleG.Height, circleG.Width), Color.White);
spriteBatch.End();
GPosResultX = rand.Next(1,380);
GPosResultY = rand.Next(1, 380);
}
//definitions
int circleGPosY;
int circleGPosX;
int GPosResultX;
int GPosResultY;
Random rand = new Random();
{
graphics.GraphicsDevice.Clear(Color.Black);
spriteBatch.Begin();
spriteBatch.Draw (circle, new Rectangle(circlePosY + 180, circlePosX + 180, circle.Height, circle.Width), Color.White);
spriteBatch.Draw(circleG, new Rectangle(0, 0, circleG.Height, circleG.Width), Color.White);
spriteBatch.End();
GPosResultX = rand.Next(1,380);
GPosResultY = rand.Next(1, 380);
}
//definitions
int circleGPosY;
int circleGPosX;
int GPosResultX;
int GPosResultY;
Random rand = new Random();
Sam HobbsPosted Aug 9, 2011, 10:22 PM
My guess is that you are not familiar with the way that graphics works in Windows. Windows depends on the application to draw a window and (here is the important part) Windows depends on the application to draw the window again whenever something happens such as when a window is minimized then restored or when another window is moved; things like that. The drawing is also called painting. So your program might be causing the drawing to be redone continuoulsy. Since your "draw function" is generating a new location each time, the location changes.
So you need to do two things. You need to do the random location determination outside the drawing code and you need to determine what is causing the drawing to be redone continuously.
Vilas GitePosted Aug 9, 2011, 12:53 AM
Hi Sam,
Refer: Our recommended articles
--------------------------------------