R0J0hound's Forum Posts

  • 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

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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.

  • 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.

  • Here is a more generic version.

    1. Place the cloth sprites wherever you want some cloth. It supports multiple instances.

    2. change the instance variables of the cloth sprite to change up the settings.

    a. resX, resY is the size of the grid that you want to simulate. bigger sizes are slower.

    b. diagonals turns on diagonal constraints. Makes cloth a bit stiffer.

    c. iterations will make the cloth less stretchy the higher it is. 1 is the default and fastest. More than 10 would be very stiff but very slow.

    dropbox.com/s/cl1205kk9cwjh3c/verlet_cloth_paster2.capx

  • I think it may be one of those things that construct doesn't update the values of until things are drawn. So the result is the calculation gives a position one frame behind.

    I haven't used those equations but I had the same issue when trying to get the screen left right after setting the scroll position. My solution was to calculate it manually.

    Off the top of my head this should give you the x,y position of the center of the screen on the 90,90 parallax layer. I haven't tested it though.

    x = scrollx*0.90

    y = scrolly*0.90