How do I finish "Connect the Dots" game ?

Get help using Construct 2

Post » Tue Nov 26, 2013 8:33 pm

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:


Also can the code be more simplified/optimized ?
B
49
S
15
G
6
Posts: 534
Reputation: 7,195

Post » Tue Nov 26, 2013 8:55 pm

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)mindfaQ2013-11-26 21:01:44
Visual Novel 'Engine' in 100 Events
if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review
B
22
S
9
G
1
Posts: 788
Reputation: 3,788

Post » Wed Nov 27, 2013 1:20 am

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.....
B
28
S
5
G
2
Posts: 77
Reputation: 3,087

Post » Wed Nov 27, 2013 9:48 am

[QUOTE=mindfaQ] 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)[/QUOTE]
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

[QUOTE=Pennington Games] 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.....
[/QUOTE]
Thank you
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
B
49
S
15
G
6
Posts: 534
Reputation: 7,195

Post » Thu Nov 28, 2013 10:25 pm

Switching from Canvas to Paster since Canvas has lower FPS when WebGL is enabled
B
49
S
15
G
6
Posts: 534
Reputation: 7,195

Post » Thu Jan 07, 2016 10:22 pm

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
B
29
S
13
G
10
Posts: 355
Reputation: 8,317

Post » Thu Jan 07, 2016 11:33 pm

I made Mods to the code to close the loop line 6
Image
Then I changed 12 to read like this..
Image
which makes a loop and starts all over again.
B
29
S
13
G
10
Posts: 355
Reputation: 8,317


Return to How do I....?

Who is online

Users browsing this forum: Kin and 39 guests