"Connect the dots" Game - Sample Code or advice?

Hi, Does anyone know of any sample code that I could look at to learn how to make a connect the dots game? 

If not, can you point me in the right direction as to where to start? I am taking a course on Corona, but I am hoping to find some sample code to start with. 

Thanks!!

 

Hi,

I’m no use on the source code front (just because I’m not sure what’s out there - there may be example connect-the-dots apps), but happy to brainstorm with you if you want. I assume you’re looking for help with the actual game play, rather than the app as a whole (since any sample app will work for that).

For me personally, I’d probably make all the dots active with listeners right from the start, then you’d have several gameplay options; you could only display the line if they click the next correct dot, or display the line even if they click the wrong next dot, but e.g. make it a different colour, or let them remove the line when they realise it’s wrong. So something like;

have the dot data as a table, in whatever format seems logical to you - e.g. dots.dot1X = 50, dots.dot1Y = 100, etc.

create dots using display.newCircle - I’d use a for loop, with some variable going from 1 to maxDots, and creating a dot at each pair of coordinates

add a .name property to each dot, e.g. “dot1”, “dot2”, etc. (or perhaps even a .dotNumber property, which could be numerical, rather than a string)

label dots using display.newText

add event listeners to each dot - all pointing to the same function, and use the ‘.name’ or ‘.dotNumber’ property to identify which dot was clicked

create the function for clicking a dot; this checks what the previously clicked dot was (you would store this as a variable) and then check which dot was clicked, and then uses display.newLine to create a line between the two dots, then updates the previously-clicked-dot variable to the dot just clicked. I’d probably also set the just clicked dot to a different colour so the player knows where they’re drawing the line from.

Also, I would make it so that if the user clicked the wrong dot, it still draws the line, but in the wrong colour, and then if the user “backtracks” it erases the line; so if user clicks dot1 then dot3, it’ll draw a red line, and then if they click dot1 again the function checks if the line between 3 and 1 exists, sees it does, and then erases it.

Sorry if that’s not very straight forward; just writing what came to mind. Happy to answer questions, or have a bit of back-and-forth. Also, other users might have more efficient approaches.

Cheers,

Simon

Dixon Court Entertainment

Hi Simon, Thank you for responding. I am currently finishing the course that I am taking, and I should be able to play around with this soon. I would love to collaborate and I will keep you posted. Being that I am such a noob, I was hoping to find some existing source code. lol

Hi,

I’m no use on the source code front (just because I’m not sure what’s out there - there may be example connect-the-dots apps), but happy to brainstorm with you if you want. I assume you’re looking for help with the actual game play, rather than the app as a whole (since any sample app will work for that).

For me personally, I’d probably make all the dots active with listeners right from the start, then you’d have several gameplay options; you could only display the line if they click the next correct dot, or display the line even if they click the wrong next dot, but e.g. make it a different colour, or let them remove the line when they realise it’s wrong. So something like;

have the dot data as a table, in whatever format seems logical to you - e.g. dots.dot1X = 50, dots.dot1Y = 100, etc.

create dots using display.newCircle - I’d use a for loop, with some variable going from 1 to maxDots, and creating a dot at each pair of coordinates

add a .name property to each dot, e.g. “dot1”, “dot2”, etc. (or perhaps even a .dotNumber property, which could be numerical, rather than a string)

label dots using display.newText

add event listeners to each dot - all pointing to the same function, and use the ‘.name’ or ‘.dotNumber’ property to identify which dot was clicked

create the function for clicking a dot; this checks what the previously clicked dot was (you would store this as a variable) and then check which dot was clicked, and then uses display.newLine to create a line between the two dots, then updates the previously-clicked-dot variable to the dot just clicked. I’d probably also set the just clicked dot to a different colour so the player knows where they’re drawing the line from.

Also, I would make it so that if the user clicked the wrong dot, it still draws the line, but in the wrong colour, and then if the user “backtracks” it erases the line; so if user clicks dot1 then dot3, it’ll draw a red line, and then if they click dot1 again the function checks if the line between 3 and 1 exists, sees it does, and then erases it.

Sorry if that’s not very straight forward; just writing what came to mind. Happy to answer questions, or have a bit of back-and-forth. Also, other users might have more efficient approaches.

Cheers,

Simon

Dixon Court Entertainment

Hi Simon, Thank you for responding. I am currently finishing the course that I am taking, and I should be able to play around with this soon. I would love to collaborate and I will keep you posted. Being that I am such a noob, I was hoping to find some existing source code. lol