R0J0hound's Recent Forum Activity

  • The first part was just to fill the tilemap with something. Ideally I’d just draw an image and load that but that’s another can of worms.

    So anyways I just use the equation for a sine wave to define the terrain:

    y >= y0 + amplitude*sin(frequency*x +x0)

    x0 and y0 just adjust where the sine wave is.

    I use >= because I want everything below the sine wave to be filled.

    So you could fill the tilemap by looking at all the tile locations, plugging x and y of the tile into that formula and if it’s true drawing that tile.

    It could look like this:

    For “x” from 0 to tilemap.width-1

    For “y” from 0 to tilemap.height-1

    Compare: loopindex(“y”)>=y0+amplitude*sin(x0+loopindex(“x”)*frequency)

    — set tile at (loopindex(“x”), loopindex(“y”)) to 1

    Erasing is basically the same. Look at all the tiles and measure their distance to the center of the circle. If the distance is less than the radius, erase that tile.

    Now it’s slow to loop over all the tiles. But we don’t have to. With a circle we can look at the box of them a radius away from the circle.

    We can do it faster by utilizing the “erase range” action instead of erasing each individually.

    So we can loop x from -radius to positive radius.

    And we can calculate the y position of the top half of the circle at that x. The bottom half y is basically flipped.

    Sorry. I’m probably not helping at all. I’ve run out of time.

    Hopefully it got the gist of it out there. The rest was just trickery to do less so it’s faster.

  • This topic has a working capx that should import into construct 3 fine.

    It utilizes some math to erase a circle. Same equation to graph a circle.

    construct.net/en/forum/construct-2/how-do-i-18/simple-scorched-earth-worms-ga-129595

  • So the steps are.

    1. create all the points you want, wherever you want.

    2. create all the edges you want between pairs of points.

    3. when the simulation starts use the starting length of the edges as the limit length.

    If you ever want to move the points around so the cloth has a new rest position then you have to do 3 again.

    Here's a test that's basically the same as the examples before, but it calculates the limit lengths when the simulation starts.

    It shows three ways to make the mesh. The first is a simple chain created manually. The next is a square grid created with some loops and some cleverness. The third loads from an obj file created in blender.

    uc9e67ddfd14751930be897a5d1a.dl.dropboxusercontent.com/cd/0/get/CiGtNc8FTpn6qzC2jy73RuVMprqxTKsvJdpn_GcN0DUvOuaLNWyEF7T4vkIalRgXfYJu54ghMUUJrIpFLEa8nZyB8JVZPyHYdOKagSVuf3vX9nvKFEB7Kixpfck20onfRO3rTkIa8f-mGINCzvRfxtn0/file

    I will continue to use it for the foreseeable future until there is something else that can replace it’s enjoyable niche for me. The end of support isn’t a worry for me.

    I don’t really have projects so I guess I’m not the typical customer. I just like tinkering with tiny projects here and there.

  • Well here’s the general idea how you can do it.

    Currently, it creates a grid of points over a sprite (at least in my example). Then it uses a loop to do all the edges between the points in an automated fashion. All the edges have a fixed length.

    The change needed is to make each edge length customizable. You could make it even calculate the lengths from the distances between the points.

    Seems unwieldy to me though. And very tedious to have to define the length of each edge.

  • The example just did a grid mesh of points and edges since that’s fairly simple to do, results in a nice uniform simulation and finally because it matches what c3 can do with its distort mesh, which also is a uniform grid.

    You could conceivably put points anywhere you wanted and have edges all over. The issue is it’s tedious to setup. Also it wouldn’t be simple to make work with the distort mesh.

    Just thinking aloud though.

    Where there’s a use case and an interest to do it there’s a way. What you want to do is still vague.

  • You’re welcome

  • As for the math part, sin and cos in construct take degrees and not radians like in that example.

    So just multiply the values inside the sin and cos by 180/pi and it should be correct. No idea if it’s the same noise function though.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Here's the example using an array.

    uc08a3811279c1679a1e985d51ef.dl.dropboxusercontent.com/cd/0/get/CiF2jIF17-8atTe_v-zCpW94n6nZdcKMDpuVp3itJLiu0Z9IAsNF0u0GDEARiadDSpJoHt7iKJlAyQOw4JZsbm9jtT5jafJ00iWQRy5T-xRpxSmUpZCfx2neSwLkpdCW66u0TXHsUUmjG4gZTqjOYUPy/file

    The array has 1 if something is at that grid space and 0 if nothing is there. That's initially setup at the start of layout.

    motion logic is basically this:

    want to move right?
    is right grid position empty?
    -- set current grid position to empty
    -- set right grid position to full
    -- start move

    You then look at the sprites in order as you have with "for each ordered".

  • I probably explained it poorly. The gist is to not check the objects current position for collisions, but the position it’s moving to.

  • On further thought you can avoid the array entirely. You just need another sprite for each moving sprite to be for collision detection. The idea is that additional sprite is where the moving sprite will be going and can be used for collision detection.

    Here's a c2 example that can load into c3. The tilemovement behavior isn't in c2 so i did it with events.

    uca87f8c48c9d82029dd94c9c087.dl.dropboxusercontent.com/cd/0/get/Ch6GIN2flB0sMs5TDrFCLlCaLUDkCk37tMYik1LTE44MMmj8hvul3r-pbbMq454YPOQj4DBsg8GbRO9sJt5995MyBbJYrxZT58PxrQbEjJlnJ4ZHvnhcEuviulw7dsxzKnxzXPM1H_C8VTIjIHYHq1S-/file

  • One solution is to remove the solid behavior completely and do your collision detection yourself. An array can be useful for this since its grid based. Then you fill the array with wherever the objects are. The trick is when you move an object to update its position in the array to the goal position so it’s old position is free for other objects to move onto.

    The setup of the array could look like this:

    Start of layout:

    — Array: set size to (layoutWidth/32, layoutHeight/32, 1)

    ——array: for each xy

    —— compare tile at(array.curx,array.cury)=-1

    ———array: set (array.curx,array.cury) to 1

    —— for each fmotion

    ———array: set (fmotion.x/32,fmotion.y/32) to 1

    Then before simulating moving left for instance, you’d check if that spot was free, and if it was simulate the key press and update the array.

    Array at (fmotion.x/32-1, fmotion.y/32) =0

    — fmotion: simulate left pressed

    — array: set (fmotion.x/32, fmotion.y/32) to 0

    — array: set (fmotion.x/32-1, fmotion.y/32) to 1

    It would be very similar for the other three directions. You’d use that with the for each ordered logic you already have.

    That’s at least one idea. There may be clever ways to make it simpler. The issue with the solid behavior is it doesn’t know how to handle moving objects.

R0J0hound's avatar

R0J0hound

Member since 15 Jun, 2009

Twitter
R0J0hound has 156 followers

Connect with R0J0hound