R0J0hound's Recent Forum Activity

  • I’m on my phone but I may have one idea. Could be vastly different to your project, idk.

    So I’m guessing you have something like this currently:

    Set marker position to minimap.x + enemy.x/32, minimap.y + enemy.y/32

    If the minimap is 1/32 scale

    Relative, just mean subtract the players position from the enemy position.

    Set marker position to minimap.x +(enemy.x-player.x)/32, minimap.y + (enemy.y-player.y)/32

  • There’s this older topic with some ideas. The ones I did I’ve never been super happy with:

    construct.net/en/forum/construct-2/how-do-i-18/creating-top-down-car-traffic-127583

    Best I can tell it involves solving a lot of little problems that together can give the result you’re after.

    * making car follow road. Obeying traffic rules.

    *avoid collisions with obstacles.

    *avoid collisions with other moving cars.

    Pathfinding is too much for this, and it can’t handle moving obsticles. It’s enough to only look ahead a short time in the future. Basically calculate where the cars will be like 10 frames in the future if the stay in the direction they are going, and if they collide then brake or steer now to avoid collision. Seems there are a lot of options here, you could do something arbitrary or come up with something more sophisticated to choose what to do.

    Probably you’d add some events for the cars ai so it can break some of the rules depending on the situation. On example is the pursuing vehicle, it would want to crash into the player car, and maybe wouldn’t mind hiring other cars or walls to do it.

    Speaking of collisions, you’d probably want to use physics instead of the car behavior in this case. The solid behavior isn’t up to snuff for collisions.

    For the Sunday drivers following the road, you can probably just have it decide where to drive as it goes. Mostly just knowing what road section it’s on and what intersection is coming up.

    Out of ordinary stuff would be good to handle too. Like it the car is knocked off the road it may need to backup or whatnot to get back on the road. Or maybe it could need to navigate around cars blocking the road or make excessive maneuvers to avoid reckless drivers. There’s probably a lot of extra finesse you could add.

    Kind of complex overall I think.

    A simplification would be to just think of each car individually responding to its sensors of what’s around it. Could give some interesting divergent behavior.

  • I guess I’ll point out that you didn’t provide enough information. What did you do exactly to get that result.

    Anyways, the issue you’re having probably isn’t because of the math, it’s because the number is rounded a bit when it’s displayed as text. If you manually convert a number to text with str() then it doesn’t do any rounding.

  • Construct only deals with numbers and text. You’ll have to do it via JavaScript. You could make it into a plugin later if you like.

    Anyways it’s a straight JavaScript problem. Roughly you do this.

    1. Create a image

    2. Set the source to the data url.

    3. When it loads, create a canvas, and draw the image to it.

    4. The canvas then has a function to get the image data array.

    I don’t know any of the syntax exactly offhand but it’s something you can find online.

  • Here are some more tests.

    Simple terrain generator. Wrapped it onto a circle to see how that would look.

    dropbox.com/s/tuc8s5u9mi12sz0/terrain_midpoint.capx

    Next I was doing some more tests with distorted quads. Uses Custom Draw plugin, which can be found here:

    construct.net/en/forum/extending-construct-2/addons-29/r0j0hound-plugin-list-135781

    First I was trying various ways to animate various distortions.

    dropbox.com/s/koljyea1m4k9atj/customDraw_test3.capx

    Modified the above a bit. It's a bit cleaner, and you specify the function to use to do the distortion.

    dropbox.com/s/bv721i9d2ucvh4e/customDraw_test4.capx

    Finally here's a 3x3 bezier patch to do the distortions. It's more usable without dealing with math parameters. Seems decent at doing shears, tapers, bends and such. On cool thing you can do is make a square into a circle pretty easily.

    dropbox.com/s/nhmp81cqcwql5az/bezier_patch.capx

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You can do it the same way as you did with one instance with else’s. Just add a “for each blue” event and put the events you used before as sub events. That way it will only be looking at one blue instance at a time.

    “For each” is usually the solution when something works with one instance and you want to make it work with multiple.

  • You can use lerp in a different way as well to do the motion at a constant speed.

    You can do it with a t variable.

    Every tick
    — set t to min(1, t+dt/duation)
    — set x to lerp(startx, endx, t)
    — set y to lerp(starty, endy, t)

    It will move from a start position to an end position in “duration” seconds.

    Basically that’s what the easing behaviors do.

  • That’s a c2 effect. It would have to be ported to c3 to use, and then it’s just a matter of using it.

    Other than that there’s a broad amount of ways to fake 3D. You can google search the forum to find quite a few examples over the years.

  • You could play with the pool idea by using a text variable. We'll be using it like an array.

    Here's a pool of random numbers than uses one at a time and then removes it from the pool. Only works 10 times.

    global text pool="0123456789"
    global number n=0
    global rnd=0
    
    every 1 seconds
    -- set n to int(random(1)*len(pool))
    -- set rnd to int(mid(pool, n, 1))
    -- set pool to left(pool, n) & right(pool, len(pool)-n-1)

    There are various ways we can adjust this.

    The list of unique numbers can be expanded to have more than single digits. We can even generated the list with events at the start of layout to make things easier.

    Another idea is to make the list reusable by adding the values back to the list. That would semi break the limit of no duplicate numbers, but maybe only allow a number to be picked again after say 50 numbers or something.

    It can be fairly tedious to emulate an array with text though.

    If the amount of random numbers is unbounded i'd just generate the random numbers and add them to a dictionary. If the number wasn't in it then it is unique, otherwise generate a new number. Seems simple enough, and fast at lookups. The caveat is this will use more and more memory over time.

    global number rnd=0
    on function "unique random"
    while
    -- set rnd to random(1)
    ---- dictionary: doesn't have key rnd
    ------ add key rnd to dictionary
    ------ stop loop
    ------ set return to rnd
  • Pandy Joined your discord.

    I don't have a plugin needed to open the capx, but it seems to mostly just be the original example?

    Custom Draw isn't finished but I'm also not working on it, so it's missing some features like z-order.

  • Advanced random is useful for creating a texture. The new canvas plugin could be used to create a gradient. Probably by setting the colors of each pixel.

    as a psuedo example suppose you have a 100x100 canvas and you want to make a horizontal gradient from red [255,0,0] to blue [0,255,0]. You could do something like this:

    start of layout

    for x=0 to 99

    for y=0 to 99

    -- set pixel at x,y to rgb(lerp(255, 0, x/99), lerp(0, 255, x/99), lerp(0, 0, x/99))

    The actual use of the new canvas plugin seems to have a few other steps you have to consider, such as copying the pixels to the image, but that is just one action.

  • Here's one possible solution.

    Create a new sprite, and place it at the start of your track. Also set it's initial visibility to invisible. The idea is you'll place instances of this object around the track like a dotted line along the shape of the track. For simplicity you should create the instances as you go around the track so they'll be in order for event purposes.

    global number i=0
    global number t=0
    
    start of layout
    repeat 10 times
    -- set i to int(random(sprite.count))
    -- set t to random(1)
    -- create tree at lerp(sprite(i).x, sprite(i+1).x, t), lerp(sprite(i).y, sprite(i+1).y, t)
    -- tree move random(-40, 40) pixels at angle 90+angle(sprite(i).x,sprite(i).y,sprite(i+1).x,sprite(i+1).y)

    dropbox.com/s/81o7e6i8qefaoec/create_along_path.capx

    It creates everything beforehand instead of only around the player, but it's part of the solution.