How do I finish "Connect the Dots" game ?

0 favourites
  • 7 posts
From the Asset Store
five golem elements Sprites Sheet.Best for enemy or villain game characters.
  • After 1-2 days of work I finished my "Connect the Dots" game engine. Here is the online preview:

    https://dl.dropboxusercontent.com/u/187666202/ConnectDots/index.html

    The problem is that I don't know how to end the game (connect the last node with the first node).

    One possible way would be to create the last node exactly under first node and finish the game when the user connects the last node, but I don't like it (sounds like weak implementation).

    How do I connect the last node with the first node and complete the level ?

    Here is my source code:

    <img src="http://s17.postimg.org/z2dprbxhr/Connect_the_dots_c2_code.jpg" border="0">

    Also can the code be more simplified/optimized ?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • if drawnline.count = nodes.count-1:

    pick nodes, nodes.number = 0 (or whatever you first one is): set next node x to nodes.x etc

    as subevent of the event where you set nextnode (which you should set to on touch start instead of is touching to save performance (even if it is very minor))

    all nodes connected:

    if drawnline.count = nodes.count-1: do stuff to show that game is completed

    (note: won't work if the line is supposed to skip inbetween)

  • Why not add an invisible dot at location one that can be connected from 6 in this example. then when that dot is connected go to your completion routine... window music flashing etc.....

  • if drawnline.count = nodes.count-1:

    pick nodes, nodes.number = 0 (or whatever you first one is): set next node x to nodes.x etc

    as subevent of the event where you set nextnode (which you should set to on touch start instead of is touching to save performance (even if it is very minor))

    all nodes connected:

    if drawnline.count = nodes.count-1: do stuff to show that game is completed

    (note: won't work if the line is supposed to skip inbetween)

    Thanks, but I've found a better solution for me: creating an End Node (counting the last node as the end node)

    Also, I tried "On touched object" instead of "Is touching object" before, but the results were not what I wanted: I've had to release the touch after reaching a new Node in order to progress to the next one <img src="smileys/smiley2.gif" border="0" align="middle" />

    Why not add an invisible dot at location one that can be connected from 6 in this example. then when that dot is connected go to your completion routine... window music flashing etc.....

    Thank you <img src="smileys/smiley1.gif" border="0" align="middle" />

    This is the "solution" that I thought first:

    "One possible way would be to create the last node exactly under first node and finish the game when the user connects the last node, but I don't like it (sounds like weak implementation)."

    Yes, making an End Node (counting the last node as the end node) is the best solution for me since the "drawings" will not connect always the last node with the first node.

    I was so fixed to connect the last node with the first one so I overlooked this possibility <img src="smileys/smiley2.gif" border="0" align="middle" />

  • Switching from Canvas to Paster since Canvas has lower FPS when WebGL is enabled <img src="smileys/smiley24.gif" border="0" align="middle" />

  • Ok! I got the code to work after playing around with it for a little while. (origin point middle left for draw line and test line sprites) (origin point center for nodes). Now how to expand on this code. Pick random start point and connect any nodes or if 3 points connected = new line start point.

    Any thoughts? I will continue to play with the code to see what happens.

    Have fun and enjoy. JC

  • I made Mods to the code to close the loop line 6

    Then I changed 12 to read like this..

    which makes a loop and starts all over again.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)