R0J0hound's Forum Posts

  • I once poked around the C2 source to see where the default instance is pulled from.

    Basically the first layout the object appears, the lowest layer the object appears on that layout, and finally the one with the lowest uid.

    It may be the same in C3, not sure why it would change. The dev’s response indicates they want it to be thought of as arbitrary and could change. It won’t though imo. Most projects rely on the defaults.

    So it seems a good solution would be to create a layout, put one instance of every object, and move that layout to the top of the layout list.

    construct.net/en/forum/construct-3/how-do-i-8/instance-variable-initial-139702

  • Here's the way i found to see if a circuit is connected in a particular way. The idea is you give the wires an id and per connection you specify the two wires connected on either side. It looks like this:

    1,2:resistor;
    1,3:resistor;
    2,5:battery;
    3,4:switch;
    4,5:fuse;

    Now, depending on how you connected the stuff together it could give you this instead

    1,2:resistor;
    1,4:resistor;
    2,3:switch;
    3,5:fuse;
    4,5:battery;

    They still represent the same configuration, and there can actually be 5! (5 factorial or 5*4*3*2*1 or 120) different combinations that are correct when there are 5 wires. So to see if they match we check them all.

    The good news is different wires connected to the same nodes are considered the same nodes so that reduces the complexity.

    Also in this example i made it not matter which way you hooked up the components. For most components, like resistors, it doesn't matter, although things like batteries probably do matter.

    dropbox.com/s/4pv5ldu8vkuhzp2/node_idea_2_cleanup.capx

    This is the circuit you're trying to match.

  • Well the first part would be to somehow keep track of what is connected to what.

    One way would be to have the nodes you drag around, and the connections could be indicated by line sprites with two variables that indicate the two uids of the connected nodes.

    Since these are electronic components, I'd suppose each component has two nodes, an in and an out if you will.

    So you'd have components you can drag around, each with two nodes. Then you'd have a way to add a wire between any two nodes. It's doable by referencing stuff by uids, but there are probably other ways.

    To tell if a connection setup matches another should mostly be a matter of checking if the same list of components are used, and they have the same connections. I need to mess with the idea more since there is the issue with the order you added the components. Also most components with maybe the exception of batteries can be connected in reverse. So it would amount to checking all the different combinations.

    You could probably do it easier by checking some other criteria to see if it's a correct setup. Maybe just the same components used and everything is powered. Things like limiting the configurations possible can simplify things too, such as a single loop circuit.

    That leads to how the power is transmitted. For a single battery a simple thought would be to start from the positive and do a astar search along the connected nodes to the negative. For a true simulation it's probably more nuanced dealing with resistance. Probably a flood fill along the connections would work. Flood till you make a circuit. Electricity physics would be your friend here for really good results.

    Anyways, here's a example of how uids could be used to keep track of the connections. It also shows how a basic flood fill can be done. Could be useful for some ideas.

    dropbox.com/s/yh85n6xjtwij2f9/node_idea.capx

  • Here's another idea to add into the mix of clever ideas posted in this topic.

    You can define any path as a bunch of points. Between two consecutive points are lines. Then with a bit of math (vector projection) we can find the spot on a line closest to a point. We can then use that to move along that line, and when we move off the ends of the line we can make it switch to the next or previous lines.

    dropbox.com/s/njck4ai7ebh2ivr/drag_along_path.capx

  • According to this:

    developer.mozilla.org/en-US/docs/Glossary/Origin

    Two pages share the same local storage if their origin is the same.

    So while beta.myawesomegame.com and stable.myawesomegame.com don't work since they are considered different origins, you should be able to do myawesomegame.com and myawesomegame.com/beta or something like that and it should work.

  • Well, according to this:

    javascript.info/localstorage

    localStorage is per domain, but you can't access other site's localStorage.

    So I'd guess that means if the first game was on a website like:

    http://www.myawesomegame.com/game1/main.html

    and the second was on:

    http://www.myawesomegame.com/game2/main.html

    Then they would have the same localStorage. Would have to test, but I never upload games online so I don't know for sure.

    Now, I don't know how construct handles that internally. They could be somehow making it unique per game and not shared.

    You could do it manually with js to cut out the middle man to see what happens:

    // to set value
    localStorage.setItem('key1', 1337);
    
    // to get value
    localStorage.getItem('key1')

    Why can't it be that simple in Construct? They seem to prefer triggers.

  • antigenmx

    Probably better to ask in the topic where I originally posted it. I don’t recall it.

    Also It’s not a relevant question to this topic. Kind of bad form to hijack a topic like that. By tagging someone they well see it no matter where it is.

  • Ah, the issue was how i was doing the keyboard stuff. The joy variables were being set in the key triggers but they'd be 0 by the time the move event came up so it wouldn't move.

    Anyways here's the working version:

    dropbox.com/s/ibw8ac9wtlb7czq/move_between_circles.capx

    Edit:

    You can tune it a bit by changing the /1000. I picked that so the perpendicular distance had a low influence. You can set it lower to make it affect it more.

  • I think I need to actually test it to see what’s up. Sorry about that.

    One thing that comes to mind is maybe you should move the selection to the closest dot in every tick. It may not be exactly on it since pin is delayed a frame.

  • Seems like an interesting problem. Thanks for everyone for the examples. It took me a bit to realize what they did since I’m on my phone.

    Here’s my event based solution. The first part is just for input, the last event is the meat.

    First it skips the dot the cursor is on.

    Next it picks all the dots in a cone in the direction pressed.

    Then it utilizes “for each ordered” to sort them by distance. It would be the same as “pick closest” but it also adds a fraction of the perpendicular distance so it prefers the dots closer to the direction pressed as opposed to just one of them when they are all the same distance away.

    variable joyx=0
    variable joyy=0
    variable dir=0
    variable move=false
    
    every tick
    -- set move to true
    -- set joyx to 0
    -- set joyy to 0
    
    on left pressed
    -- add -1 to joyx
    
    on right pressed
    -- add 1 to joyx
    
    on up pressed
    -- add -1 to joyy
    
    on down pressed
    -- add 1 to joyy
    
    compare: abs(joyx)+abs(joyy)=0
    -- set move to false
    else
    -- set dir to angle(0,0,joyx,joyy)
    
    move is true
    pick dot by evaluate: dot.x<>cursor.x & dot.y<>cursor.y
    pick dot by evaluate: 45>anglediff(dir, angle(cursor.x, cursor.y, dot.x, dot.y))
    for each dot ordered by distance(cursor.x, cursor.y, dot.x, dot.y) + abs(cos(dir+90)*(dot.x-cursor.x)+sin(dir+90)*(dot.y-cursor.y))/1000 ascending
    -- stop loop
    -- cursor: set position to dot
  • You do not have permission to view this post

  • The code only does the one rotation. You’d have to add code to rotate a tilt.

  • Probably replace 1024 with 1025 but I haven’t tested it.

  • I don’t have time to work on such a thing. Seems like the kind of thing independent of the cloth sim. I mean in something from scratch can you attach a sprite to another sprite?

    Also the zorder is completely subjective with this cloth sim. Make it 3D and there would be an order but I’m taking a step away from this for a while.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hi,

    That plug-in hasn’t been ported unfortunately. Aside from my low interest in making plugins and barely using C3, I simply don’t have a lot of time to dedicate to doing much coding at all.