R0J0hound's Recent Forum Activity

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

  • 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/s/t4hci8revuyaz1q/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.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Instead of the average you could find the median and use that for the center.

    X = (xmax+xmin)/2

    Y = (ymax+ymin)/2

    Then just use the furthest point. Might give a tighter circle.

  • Here’s one way to do it. Basically when creating the X you save the distance between the player and the X to a variable. Then while swinging you move the player so it’s at that same distance from the x. Also we cancel the perpendicular velocity of the player.

    The result should be swinging while keeping momentum.

    var d=0
    var a=0
    var vperp=0
    
    on x created
    -- set d to distance(player.x, player.y, x.x, x.y)
    
    compare: x.count >0
    -- set a to angle(player.x, player.y, x.x, x.y)
    -- player: move d-distance(player.x, player.y, x.x, x.y) pixeks at angle a
    -- set vperp to cos(a)*player.velocityX+sin(a)*player.velocityY
    -- player: set velocity to (self.velocityX-cos(a)*vrel, self.velocityY-sin(a)*vrel)
    
  • I mean minifying would make the export smaller.

    By not minifying it doesn’t make the program any more able to be modded. What gets minified is the plugins and and JavaScript scripts you write in the event sheet. But those aren’t really easily accessible. If you want your program to be more modable I’d try different measures.

  • Hard to say what you’re trying to calculate with the angles and how.

    If you are just turning you could just set the bullets angle to the cameras angle.

    If you look up and down too you can use spherical coordinates to get the orientation from two angles. But your math doesn’t look like that.

    Here’s a way to just shoot in the direction the camera is facing. Maybe something like that is what you’re after?

    construct.net/en/forum/construct-3/how-do-i-8/bullet-fire-center-screen-3d-166334

  • Hey that’s a pretty cool result you got. I’m glad it was usable enough to allow changes. Utilizing the fact mesh points can’t go negative was clever.

    Anyways, I agree the math is hard to read in parts, especially when I used arrays. I’m always trying to find ways to make the math look cleaner if possible.

    That deforming idea sounds like a doable thing. I probably just need the raycast to also return the triangle index.

    Cheers