Hi all I m making a simple game in C# (Catch ME). In this game there will be a button to catch. when a user moves the pointer to click on to it. It moves further and doesnt get clicked. i have done it by changing the location of the button. But by doing so, the button moves in a fixed set location and also when pointer is brought near the form boundries the button gets out of the form or becomes invisible. So i want the some random number be generated and assigned to the location property of the button so that button moves randomly. Also ensure that it must be within the form boundries.
Thanks in advance for any Idea

Recommended Answers

All 9 Replies

Random class helps you, but your problem is easier than generating random number and so on. what you need is to detect Mouse.X and Mouse.Y and change the location of button to be out this area.

Thnks Ramy But i also need to generate a random number can u help me in that also

Plz Any one can give me any idea to access random class in C# and How to generate a random Number

Generating number between 1 and 100

Random random = new Random();
return random.Next(1, 100);

Thanks Again Ramy

If this the solution please mark this thread as solved. :)

One More quistion Ramy, I cant able to change the location of the button on mouse move. How to do it

How to change the location of the button on the movement of mouse

On the event of mouse move call the method which generates new location for the button.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.