R0J0hound's Recent Forum Activity

  • Here are some more tests.

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

    uc0953bc54fd2b80f3a81bee1e8f.dl.dropboxusercontent.com/cd/0/get/Ch7C3EgHDErUCIwXZYB0vk1AWz6mAJ1Xb2zZFzg44UMWP21vEoOLcAZibtzhPByU5foHNZMwy75z2ZdPGm82nk9Hww76DUcTCezeEZTILvLR8pkjJHe8b5CuhmhZXrjSaJU/file

    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.

    uccf0b4dc650411386672059c2a4.dl.dropboxusercontent.com/cd/0/get/Ch468QRCUhdCcbxefMlBNx-OOb8M2IXSs3cGLEYm39rpe3_Duae4mvTIyyQRmy1r32r3cMylk16bC217iFvpQ0rAPvp0DJR00XdWfEOFAU0mspSnbRjBTgB3eIZmRTdxDqQ/file

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

    ucc63b1480c00fcaaee940b7f481.dl.dropboxusercontent.com/cd/0/get/Ch4MlXtOopFFUOFNsDbpbvUleKTEs__23g7iOWqdSmd680i2XcpcYwTTSn5AwSd9clctlzeB-5W_6-TI1x0H2bqWh8THvpRCukqxi_VBUj0swaztwNAu1PLkH6SmYYR4eyw/file

    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.

    uc4504da273f5c53597fb3a50d9a.dl.dropboxusercontent.com/cd/0/get/Ch5NPhNrxpDSFLx_APAvopwyL1WTrNb3US0EY_Oio0laMFkdfoF8GuOSkE1kyE4r2z32gmp3_SsoxSVQzJF2S_IS3uRIafqbNd11MCPh5c863tZFMuBn52sJw9RjqTuxyBM/file

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

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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)
  • It actually looks like a combination of things. The water, falling lava and sand piling up looks like the "falling sand game." When particles are going fast or being pulled by something, it's just simple particle physics. Then when there are big clumps rolling around it's a rigid body physics simulation. All that with some logic to switch between the three in a fairly seamless way. It doesn't look like it's doing a true fluid simulation.

    They could have used an existing physics engine like box2d to do the rigid bodies, but it would need to be scanning the terrain and generating the collision polygons from the pixels pretty often. Making their own per pixel physics engine isn't out of the question. It actually is probably faster and simpler for their purposes.

  • Set the animation speed to 0, and just set the frame with events depending on if it's jumping or falling. For the running you can come up with a nice expression that changes between 0 and 1 over time.

    is jumping
    -- set frame to 2
    else
    is falling
    -- set frame to 3
    else
    -- set frame to int(10*time)%2

    The 10 in the last expression is the frames per second.

    But you can make it in another way too. No need for fancy expressions.

    global number runframe=0
    
    every 0.1 seconds
    -- set runframe to 1-runframe
    
    every tick
    -- set frame to runframe
    
    is jumping
    -- set frame to 2
    
    is falling
    -- set frame to 3
  • No worries for asking questions. It’s often hard to find answers to old questions.

    Sounds like you’re onto the start of a working solution.

    Basically all that’s needed to wall slide is to move out of the wall in the closest direction when you overlap a wall. The two parts to this is detecting where the walls are and moving away from the walls.

    Detectors can work for the first, but you have to be careful with the collision boxes.

    The moving out can be done by just moving out by a bit from each overlapping wall, using the detectors to know which direction.

    Here’s a rough example.

    Repeat 10 times

    — position detector sprites

    — detectorLeft is overlapping wall

    —— sprite: move right 1 pixel

    — detectorRight is overlapping wall

    —— sprite: move left 1 pixel

    ...and so on for up and down.

    So something like that would move out a max of 10 pixels out of the walls, a pixel at a time. Could prove jittery though, so you can make it move by less than 1 pixel. Also if it doesn’t move far enough you’d increase the repeats. It’s a balance between jittery and fast or smoother yet slow.

    There is also the custom movement behavior’s push out action. It does stuff like the above with one action. Could be useful.

    There are jumping issues with that behavior so here is a more precise solution. Makes very smooth wall sliding. Hopefully simple enough to copy paste over.

    construct.net/en/forum/construct-2/how-do-i-18/how-do-i-make-the-8-direction-95148

  • That looks pretty impressive. You couldn’t do that with construct. Indeed they used the gpu to handle all those particles at once, but shaders are only a subset of the gpu features needed. I mean they cold have also used cpu for a lot of it too. There are astounding amounts of performance gains to be had if you have the know how in assembly and stuff.

    What I like about games like that is they put a good amount of work in their own tech to create something cool that’s not easily repeatable by others.

R0J0hound's avatar

R0J0hound

Member since 15 Jun, 2009

Twitter
R0J0hound has 156 followers

Connect with R0J0hound