R0J0hound's Forum Posts

  • Does the number have to be at the right? If you put it at the left you can do this. Pretty sure the text gets converted to a number to compare automatically.

    Best = (apple>pear)?apple:pear

    Best = (best>mango)?best:mango

  • That’s not implemented yet. Will be eventually when I get to it.

  • Lots of 3D stuff in my posts.

    construct.net/en/forum/search

    In the don’t stare topic i have and example of rotation and perspective scaling math.

    Also there’s a new plugin that I’m working on to do 3D.

    construct.net/en/forum/extending-construct-2/work-in-progress-addons-30/triangle3d-plugin-160497

    Then there’s this that draws in 3D with the paster object. I don’t think I posted it here. Not sure though.

    dropbox.com/s/gsga6cs5cj6byp8/3dMath_2.0.capx

  • Updated 5/15/21

    More useful for a 3d game. Still working out how to best handle the camera, but you can draw stuff with 3d rotations so that's cool.

    cheers

  • Gravity is just applying a force toward the planet. Not just any force, it should depend on the distance from the planet to be closer to real physics.

    Something like this:

    force 10000/distance(self.X,self.Y,earth.X,earth.Y)^2 toward (planet.x, planet.y)

    For an orbit you just set an initial velocity. Using an impulse to do that works too. Just make it perpendicular to the direction to the planet.

    Something like this:

    impulse: 50/distance(self.X,self.Y,earth.X,earth.Y) at angle(self.X,self.Y,earth.X,earth.Y)+90

    The 10000 and 50 were purely arbitrary. I just tuned them till i got something reasonable. the 10000 defined how strong the gravity was, and the 50 gave me orbits that lasted a while.

    If you're curious there are perfect values that can be calculated in real life, but the units with the physics behavior are wonky so I just fudged it to get something reasonable.

  • Tried brainstorming another idea. It would be nice if construct made compositing layers together more powerful, but anyways.

    Put a canvas on the shadow layer.

    Every tick clear the canvas and draw any objects in front of the light to it. Give the canvas object the colorize effect to make its color the same as the layer.

  • Triangle3d plugin:

    dropbox.com/s/tkvqvc9aefi1jtk/triangle3d%20v0.81.zip

    To install, extract to: C:\Program Files\Construct 2\exporters\html5\plugins

    Requires: webgl

    Description:

    Basic 3d triangle plugin that lets you make triangles one vertex at a time. Each vertex has an xyz position, a uv texture coordinate and a rgba color. Every three vertices makes a triangle, and you can load textures to use on the triangles.

    That's about it for now. Think of it as a low level building block for 3d or 2d graphics.

    Basic usage:

    1. add to layout

    2. add an event like this:

    every tick
    -- triangle3d: set color to (1,0,0,1)
    -- triangle3d: add vertex ( 0, 0,0,0,0)
    -- triangle3d: add vertex (100, 0,0,1,0)
    -- triangle3d: add vertex (100,100,0,1,1)
    -- triangle3d: draw triangles with texture ""

    3. and you get a red triangle.

    Examples:

    basic:

    dropbox.com/s/wy4e76otnxqq9px/Tiangle3d_example_0.8.capx

    Change log:

    Version 0.81
    - changed how rotations are calculated.
    + Added an action and some expressions to get axis vectors from rotations.
    + camera transforms no longer wip. Added cameraZoffset expression to see the default camera z. It's based on the fov, and it's combined with the camera transform.
    + now renders at the resolution of the current canvas size.
    + orthographic camera now works.
    
    Version 0.8
    - changed how things worked a bit so examples from version 0.1 may not work.
    + added matrix transformations for camera and meshes.
    + camera is very wip right now though.
    + have use "draw triangles" or "draw mesh" to draw anything.
    + added obj file loader.
    + added save mesh to speed up repeated use of add vertex.
    ... probably more i forgot.
    
    version 0.1
    + vertexes with xyz position, uv texture coordinates, and rgba color.
    + Every three vertices draws a triangle utilizing a zbuffer.
    + Texture loading and selection with tagging to manage multiple textures.

    Current known limitations and planned additions for next version:

    Limit: won't work with layer/layout scaling currently. but you can fiddle with the camera scale to do it i think.
    Planned: texture unloading. and general garbage cleanup behind the scenes
    planned: maybe coloring of meshes.
  • Ah. That’s a shame pasting doesn’t work with blend modes. That would’ve been more straightforward.

    The other blend mode approach sounds plausible too.

    Waiting a tick for something to happen always was a bit bothersome to me.

    Anyways, if you just had duplicates of the sprites on layer 1, but with solid colors, you could just zorder the light with solid blue trees and get the same effect, without canvas or blend modes. Probably what your first idea was. Hmm.

  • Blend modes come to mind as a possible idea.

    Could you draw the light to a canvas, then draw all the trees in front of the light to the canvas, but have the trees have the destination out blend?

    It would work with paster in c2 but I’m unsure of there could be more nuance in c3’s canvas.

  • I’ll get to it eventually when I get time. The solution is there one way or another in the other capx.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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.

    dropbox.com/s/fnhb1hpingkd7o0/verlet_cloth2.capx

    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.