How do I create flexible wires in C3?

2 favourites
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • well, that turned out to be a much deeper rabbit hole than I expected...

    I made each component a "Node" (renamed Family1 to NodeFamily), and after looking at the Circuit project at the top of the thread decided we needed to add an Connector object as well, because you can drag Nodes or you can drag the connection point.

    so, after a lot of debugging, infinite recursive loops, and strange side-effects, I think I have the connecting of Nodes working pretty well. Right now the Connector objects know how things are joined together, but the Nodes themselves don't build a proper linked list that would be required to test the logic of the circuit...

    drag Nodes or connectors until they overlap (the connectors will turn blue), when you drop the object the connection is made. Right now there is no way to break a connection. And each connector can only make one connection (unlike the example Circuit project linked at the top). My code needs a lot more comments to be readable! and it probably could be cleaned up now that it is mostly working.

    https://www.rieperts.com/games/forum/NodeConnect.c3p

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • well, that turned out to be a much deeper rabbit hole than I expected...

    I made each component a "Node" (renamed Family1 to NodeFamily), and after looking at the Circuit project at the top of the thread decided we needed to add an Connector object as well, because you can drag Nodes or you can drag the connection point.

    so, after a lot of debugging, infinite recursive loops, and strange side-effects, I think I have the connecting of Nodes working pretty well. Right now the Connector objects know how things are joined together, but the Nodes themselves don't build a proper linked list that would be required to test the logic of the circuit...

    drag Nodes or connectors until they overlap (the connectors will turn blue), when you drop the object the connection is made. Right now there is no way to break a connection. And each connector can only make one connection (unlike the example Circuit project linked at the top). My code needs a lot more comments to be readable! and it probably could be cleaned up now that it is mostly working.

    https://www.rieperts.com/games/forum/NodeConnect.c3p

    Awesome!!! Very nice example!

    As I understand it, it is still not possible to check if the circuit was assembled correctly (following the same order of the diagram), right?

    EDITED:

    Components could not be connected to components directly. How could I do to add this rule?

    And with regard to breaking the connection, I thought about erasing (destroying) a wire to be able to release the stuck component. Would that be a good idea?

    I found a small problem: if I bring the cable close to the battery, perpendicularly, the wire connects to the two nodes of the battery, automatically

  • I just updated the file, so re-download it from the previous link.

    I added wire cutters - if you drop them on a connection, it breaks it.

    I also added a connection value field. Component connections have a value of 1, wires a value of 0. When you attempt to make a connection, the total value must be less than 2. So, that means components can't be directly joined together. (although I think that should be ok, and the example you linked to allows those types of connections.)

    I didn't do anything about the double battery connection - if the connectors line up, it allows the connections. at least now you can cut one... it would be hard to tell which of the two the user wanted to connect.

  • Very nice! I will check it. Thanks.

    Could you tell me what I can do to check if the user made the connections according to the diagram or if it is wrong?

  • The cutting tool is very good, as well as the possibility of not connecting components.

    I forgot to comment that other circuits may have other components, that is, when we verify that the order is correct, there may be more or fewer components. To verify, the user will have to turn on the switch, if he is right, an animation of the wires will appear as it happens in the online simulator that I included in the first post.

  • it shouldn't be hard to have it check a correct answer for different circuits once the linked list of components is properly maintained... one thing that is probably significant is how a component is wired in. Things like batteries and resisters would have to be connected the correct way (not reversed). Right now I changed all the components so that imagepoint 1 is on the left and imagepoint 2 is on the right, so that could be considered positive and negative respectively. I have some ideas on that and the animation, but wont have much time today...

  • Ok. Thanks.

  • Hi AllanR

    The linked list of components will be created in the log as the components are connected by wires, right? I think this is the way to check if the connections are correct or not. Would you know how the connections will be included in this list?

    Maybe checking if the nodes with the same UIDs of the components are overlapping the nodes of the wires and then comparing the IDs to be at the ends of the wires there are two components that are part of the sequence? Wow, this is really hard for my brain 'o'

  • I still need to understand how to check if the circuit is correct or not. Could someone help me with this?

  • I just updated the previous file - it now has a global string of what components are required in the circuit. So you can change that for different circuits.

    Every time it checks connections it starts with the first component in the Answer variable and checks if it is in a circuit that loops back around to that first component, and checks if the circuit has the correct components in the correct order. It doesn't include wires in the solution, and doesn't check if components are wired in frontwards or backwards...

  • Thank you so much for this.

    Regarding the wires, I will need to show in this demonstration how to test the circuit or measure the voltage of some components without one or more wires connected to them. Should this be another way of checking what you just did, or is it possible to include the wires in that check?

  • The way it is now the wires need to be there, they just don't factor into determining if the circuit is correct or not. The same thing would apply to testing voltage - you would have to know what each component does (adds or subtracts from what it inherits from the previous component). For wires, they would have no effect other than passing on what voltage they receive (if any).

    will you need to have more than 1 battery? I would need to know what effect each component has on voltage passing through it - Fuse, how much before it breaks; resister, how much it resists; battery, how much it provides...

  • Thanks a lot for your help.

    In fact, these data change continuously, mainly because new components will be included later, besides that it is possible to measure various types of voltages (voltage/resistance/etc). I thought about setting these values directly on the multimeter when the test probes overlapped the ends of the components or the nodes that are over these ends.

    Here are the values for this demonstration circuit:

    - battery = 12 volts (I don't know if there will be more than one battery in future circuits)

    - fuse = 5 amps

    - resistor 1 = 100 ohms

    - resistor 2 = 200 ohms

    I would need to check that the circuit is complete, that the components are in order and that some of the wires or components have been disconnected, which can alter the measurement of any component or circuit.

  • Hi AllanR

    Just checking if you’ll continue to help me complete this demo.

  • I am willing... but have limited time today. Will see how tomorrow goes.

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