The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: terb on March 29, 2009, 08:45:56 PM

Title: Connect the dots
Post by: terb on March 29, 2009, 08:45:56 PM
Hey guys

If the is the wrong section, please move topic :)

I've haven't been coding in MASM for quite a while due to real life issue, but lately I have started my old hobby again. Anyway, I have decided to code a connect the dot type application. Yes, I know its a silly thing, but its basicly just to get some graphic aspects in the right place in my head.

My idea was to either let the pc generate random dots or let the user place a certain amount on the screen. Then the user simply has to connect the dots, for example within a certain time.

My questions are these:


Hope there's someone out the that call guide me in the right direction. Thanks in advance :)
Title: Re: Connect the dots
Post by: baltoro on March 29, 2009, 09:16:24 PM
If you don't want to save the "silly" image, and you want to display everything in a window, the simplest way would be to let the user select the dot position with a mouse click. There is a Windows API that does exactly that, and you call it with the invoke syntax.   
This might prove helpful: http://msdn.microsoft.com/en-us/library/ms645602(VS.85).aspx
Title: Re: Connect the dots
Post by: donkey on March 29, 2009, 10:26:18 PM
For random dots you can use a mersenne twister (http://www.masm32.com/board/index.php?topic=10088.0) to set the x and y coordinates of the dot, just set the maximum value to the width and height of the window client area. You can use SetPixel to draw the dot and WM_LBUTTONDOWN to find out if the user has clicked on a dot (just check the color of the pixel at the mouse coordinates with GetPixel). To draw the line between the dots use LineTo.