R0J0hound's Recent Forum Activity

  • It’s simpler to look at with 1D arrays.

    So these two

    A =[ “a”, “b”, “c”]

    B =[“a”, “c”, “d”]

    Would give:

    C=[1,2,3]

    A:for each x
    — compare: A.at(A.curX)=B.at(A.curX)
    — — c: set at (a.curX) to 1
    — else
    — A: contains value B.at(A.curX)
    — — c: set at (a.curX) to 2
    — else
    — — c: set at (a.curX) to 3

    Doing it with 2D or 3D arrays may be similar, but I’m not up to working it out.

  • That particular event looks at all the outgoing roads except for the one the car came on and just picks a random one.

    To only turn right I guess you could pick roads whose angle is car.angle+90 or something.

    It’s honestly been long enough that I don’t like the events I wrote and would rather just redesign the whole thing and maybe reusing some of the concepts used here. I’ll probably have a go at that the next few days with better intersection logic. Maybe the cars could have preferences where they’d like to go for like pathfinding and such.

    In my experience when I make something and then change what I want it to do it’s not often a simple tweak. Besides rewriting it often yields a better design anyways.

  • This was built around casting rays against arbitrary triangles, and trying to fit it within 25 events. It may be possible to simply since 3D objects are limited, or there may be other approaches.

    Anyways I have no alternatives currently.

  • When I posted that example I didn’t have a good idea how to fix that issue and decided it still was good enough to post as it mostly worked.

    To fix I’d say the whole thing would need to be redesigned with more logic at intersections.

    As is it just moves along the roads, turns randomly at intersections, and stops if a car is ahead.

    Probably would need the cars to not enter the intersection unless it’s path doesn’t cross another one already in it. Not just look right in front of itself. Probably would do well with some kind of signal logic to keep things fair for cars who can’t enter.

  • No problem. Glad it worked.

    newt

    You can already do that with functions somewhat.

    What I’d like to see is being able to have simple structures as values in addition to numbers, text and bools. Would make some events way more readable I think.

  • So this is what the math would look like.

    X,y is the position on the curve.

    If we advance t by a small amount and get that xy then subtract the position from that we get a direction vector.

    We can then normalize it to make it have a length of 1.

    So then if we swap xy and make one negative it’s the same as rotating 90 degrees.

    So we end up with a point 50 pixels to the left and right of a point on the curve.

    x = cubic(x0,x1,x2,x3,t)
    y = cubic(y0,y1,y2,y3,t)
    dx = cubic(x0,x1,x2,x3,t+0.001)-x
    dy = cubic(y0,y1,y2,y3,t+0.001)-y
    mag = distance(0,0,dx,dy)
    dx = dx/mag
    dy = dy/mag
    
    points:
    x+dy*50, y-dx*50
    x-dy*50, x+dy*50
  • One way is to just make a curve for one edge. Cubic or qarp for example. Or even using the arc of a circle for minimal distortion. Then you can get points from one edge.

    You can get the other curved edge by moving the points out perpendicular from the curves angle.

    I’m probably not doing the idea justice without an example. I’ll try to make one tomorrow.

    This page has ideas how to bend roads which is very similar to what you’re trying to do.

    redblobgames.com/articles/curved-paths

    That guy’s whole site is full of a wealth of information.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You can use a dictionary for that. So basically use tokenat to get each number from the string and add a key to a dictionary. Duplicates will be the same key.

    Then you can loop over the keys and add it to a string and there will be no duplicates.

  • That was just what that algorithm did, which I honestly don’t fully understand. What I do know is it should be one of the faster algorithms for that problem, according to Wikipedia.

  • The algorithm came out cleaner in events than I expected.

    dropbox.com/scl/fi/szskojvpbvgmlvw0p4cs2/smallest_enclosing_circle.capx

  • It should be possible to implement the welzl algorithm to do it. We just need to use some cleverness to return multiple values and be able to pass arrays to the function.

    The meatiest part of the algorithm is probably the math to give the smallest circle around three points.

R0J0hound's avatar

R0J0hound

Member since 15 Jun, 2009

Twitter
R0J0hound has 155 followers

Connect with R0J0hound