R0J0hound's Forum Posts

  • Here's a mess of previous topics. There are probably more.

    construct.net/en/forum/construct-3/how-do-i-8/math-result-text-line-145507

    construct.net/en/forum/construct-3/how-do-i-8/create-programming-language-138650

    construct.net/en/forum/construct-2/your-construct-creations-23/r0j0s-experiments-69314

    Specific to what you're going for here's this:

    More functions and expressions can be added in the "namelookup" function.

    dropbox.com/s/beavbwwu1usywyg/parser_example.capx

    It won't allow invalid syntax but the error messages need work.

    Anyways, the simplest would be to do a few string replaces and running the expression with the browser's execjs expression. However this isn't forgiving if there are syntax errors and can be a problem if some arbitrary js is run.

  • In the layout editor it only takes hex numbers. In events you use decimal numbers but you can use the set bit expression.

  • You do not have permission to view this post

  • Hi,

    Sorry for the late reply.

    Probably the simplest is to use a 32 character binary number of 1's and 0's. Each digit is a layer that you can make the object be in or not in.

    For example:

    1110 1010 1010 1111 1000 0100 1100 1011

    Then to input it into the layers property you need to first convert it to hex using google, or windows calculator.

    Here's one possible converter:

    convertbinary.com/binary-to-hexadecimal

    That binary number turns into this:

    EAAF84CB

  • Hi,

    For whatever motion you want to trace the future path of you’ll need a way to manually advance the object. Behaviors do that automatically every frame, but don’t give manual control to advance multiple frames.

    Logic overview would be:

    1. Save position and velocity

    2. Loop 100 times

    3. — move object a bit

    4. — handle collisions and bounces.

    5. — plot point

    6. Restore objects pos and vel

    Number 3 is pretty easy with an object affected by gravity.

    Add gravity/60 to Vy

    Set position to x+vx/60, y+vy/60

    Number 4, the collision detection and response is a topic of its own. Usually back up the object out of the wall, figure out the angle of the wall and do a bounce calculation.

    Anyways, that’s what you could do in any Game creation software.

    You may be able to do a hybrid approach with constructs features.

  • I wouldn’t mind at all.

  • For a fairly straightforward way of getting the collision point you can take all the points of one object’s collision polygon, and see if they overlap the other object. Then do the same for the second object with the first. Then, for all the points that do overlap just average the positions together to get a collision point.

    There are more robust ways, but it should work in most cases. One case where it would fail is if the objects are severely overlapping and no points overlap, just edges.

    For the impact sound it basically boils down to:

    Velocity_after - velocity_before

    Maybe Every tick save the old velocity to some variables. Then on the collision, after stopping or bouncing the object, subtract the velocities to get the impulse.

  • Here’s some pseudo code to do the bounce. The only trig has to do with the collision normal. The normal is perpendicular to the angle of the platform. So if you know the angle of the surface it’s enough to subtract 90 to get a perpendicular angle. Then to make the math look cleaner we can convert that angle to a vector.

    Anyways here’s the math.

    Nx,ny is the normal vector and can be calculated with:

    nx= cos(plat.angle-90)

    ny=sin(plat.angle-90)

    Next we calculate the velocity along the normal’s direction. Here vn is that velocity, and vx, vy is the x and y velocity of the object. We are utilizing a vector dot product to get the velocity along the normal’s direction.

    vn=vx*nx+vy*ny

    So far so good. Next is to do the bounce by changing the velocity.

    You only need to do the bounce if the object is going toward the platform.

    Then the bounce is done by taking the velocity along the normal, converting it back to a vector by multiplying it by the normal, and finally subtracting that twice from the velocity. If you subtracted just once, then it would just stop motion in the direction of the normal.

    if(vn >0)

    vx = vx -2*vn*nx

    vy = vy -2*vn*ny

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • megatronx

    The hexadecimal digits each are four bits. So you can use them for four layers. See the key here, but you can find it elsewhere as hexidecimal to binary. In total you can have 32 layers or 8 hexadecimal digits. In the layout editor it's convenient to use hex to set the layers. In the event editor you can do it too, or you can take an existing mask and modify it with construct's bitset expression.

    0 0000
    1 0001
    2 0010
    3 0011
    4 0100
    5 0101
    6 0110
    7 0111
    8 1000
    9 1001
    A 1010
    B 1011
    C 1100
    D 1101
    E 1110
    F 1111
  • I'm not sure why box2d is so jittery sometimes. Roughly, as I understand it, the way physics sims work is it moves stuff around with gravity and forces, then it loops over all the constraints (collisions and joints) to resolve them. It does that loop multiple times. The higher the iterations the closer to perfect it will be. In the case of rope with infinite iterations it should in theory be a perfectly stiff rope that doesn't stretch at all.

    Anyways, aside from iterations you should be careful with vastly different masses, that also can make things more unstable with something like a rope. As least from tests and what i've read. Your other issue of the rope being pulled through smaller pegs may be helped by links closer together, bigger pegs or even using segments instead of circles for the pieces of rope.

    I did this event based rope based physics to test some stuff out. It's probably much slower than box2d but the results are pleasing to me. The length of the rope is limited as you drag the rope around. Some things such as the pinned end and that it only works with one rope are hard wired in so far.

    dropbox.com/s/8vobbfougch0edt/verlet_rope_test.capx

    Here's also a quick modification to make it similar to you c3 project. The end is moved with the 8dir behavior and it's momentum is set to 0 so it kind of drags behind if the rope gets momentum.

    dropbox.com/s/c7ikyff1z4b7mtl/verlet_rope_test_8dir.capx

    Not sure either are useful. They are mostly just tests for fun. The first half of this post is the helpful part.

  • Hi,

    No, I don’t know why it doesn’t work anymore. Could be peerjs since as I recall it talks with their server to connect stuff together. Also I only have the vaguest idea what Cordova is. It never interested me.

    Anyways, never hurts to ask. I still pop in to read here and there. I’m not updating/fixing plugins though.

  • You can change the "steps" variable to control the strength of the light. The default is 20, which makes a 20*8 or 160 pixel radius light.

    Color light is probably done the same way you'd color lights with the shadow caster.

    Here's one way that doubles the amount of objects. Basically a layer to do the shadow, and another layer with the light color which is blended with the scene. This also animates the color and strength of the light.

    dropbox.com/s/y3m0iq02z0b3jbp/shadowtest7.capx

    Multiple lights would be done by doing each light separately and combining the shadow and color layers of each. As is the performance isn't good enough to do that. Also I'd want to reintroduce something like paster to handle the mixing instead of juggling layers.

    It's as far as I'll go with this for now. A significant speedup can be done by doing the floodfill algo with javascript, and the drawing should be simpler/faster to draw directly to textures for the shadows and colors. Less overhead at least, not my cup of tea to do that mixed with construct though.

  • WackyToaster

    Thanks

    I wasn't satisfied with the diamond shape, so here it is more rounded. Octagonal really. Also changed the falloff rate of light.

    dropbox.com/s/bw3lcf08ascchtv/shadowtest5.capx

    Another tweak to see if i could make it cast shadows instead of wrapping around as much. Ended up looking the same, but should do less checks.

    dropbox.com/s/tr4m8p6burf5uzt/shadowtest6.capx

  • Canvas is obsolete, but here is the third example done without paster at all:

    dropbox.com/s/xrukzy9cdv8p5az/shadowtest4.capx

    Paster just lets it blend more.

  • Had a go at attempting to replicate the effect, since it's not super clear how it works. I used C2 and the paster plugin for drawing and compositing. C3 may be able to do the drawing in some other way.

    My first attempt just used a shadowcaster blended with a radial gradient to do the shadows. Made lowres with a lower res paster object. The next step would be to do some kind of bloom to feather the lit area to light the surrounding walls. Maybe could be done with a shader, maybe. Anyways, I stopped there.

    dropbox.com/s/g068azvan5t3m7y/shadowtest.capx

    The next test did a kind of weighted flood fill to expand light gradually outward from a mouse click. When a wall is hit it wouldn't stop the light but make it reduce quicker. Used sprites as a test and only runs on a click.

    dropbox.com/s/0m9gm2fuqz5tdrn/shadowtest2.capx

    The third test used a weighted flood fill as well but in a different way. It referenced a tilemap for walls and used some arrays to keep track of stuff while flood filling. Paster was merely used here to draw the shadow area. The lit area is carved out with a destnation-out blend.

    dropbox.com/s/eo7iafxuoh3fsmz/shadowtest3.capx

    A hybrid between the first and third could look alright. Colored lights could be done with more blending modes with paster instances to do the multiple steps one by one. In C3 you may just need apply the ideas in a similar but different way since paster doesn't run there.

    Anyways just some ideas.