R0J0hound's Forum Posts

  • Mayfly

    The way you're calculating the expected direction could be off. Also increasing the simulation iterations could improve it.

    I've gotten a close before, but not completely exact which I attributed to the collision time being approximate.

    Unfortunately the capx is very wip and is left in incomplete state. Also it's a chunk of math to calculate the collision time and the result of a collision which I am no longer familiar with.

    https://www.dropbox.com/s/yz18begzbo294 ... .capx?dl=0

    Also here is some reading on the math it was based on:

    http://www.real-world-physics-problems. ... iards.html

    I just realized the capx uses the built in physics and not chipmunk if that matters. It's from an old attempt at the problem and I probably won't have the time to refine it. Basically it would be perfect if we replicated the physics simulation and advanced the simulation to see the path.

  • Hi,

    Sorry I won't be updating this plugin. Ideally webgl and canvas would be the same, unfortunately the canvas would require a bit of creativity to solve.

  • I like to use this expression:

    (var>0)-(var<0)

  • numbers are 64bit floating point values. You probably can get all the info you want by googling that.

  • Just to add, that is a geometric series and if you didn't have the floor there is a formula you could use to calculate the sum of any number of them without a loop:

    https://www.varsitytutors.com/hotmath/h ... ric-series

  • The code looks at each line segment and toggles the selection of the points below them. It toggles it instead of setting it because it matters how many line segments are above a point. Basically if you take any point and draw a line straight up, and then count how many lines crossed you'll know if it's inside or outside. Odd:inside, even:outside.

  • That's basically just manually doing the platform behavior, since it's the platform behavior that makes the objects act solid.

    Basically once the object overlaps a wall, you'd move it out in some direction till it's not overlapping. If the object isn't overlapping at its old position then move toward there. The other case is if you just place the Sprite in the wall, and it should just be moved to the closest open space.

    That's only the first part. After that try moving horizontally then vertically to get to the place it was overlapping. Of course just stopping short. When moving horizontally and it hits a solid then set the horizontal speed to zero. The same for vertical. Without this part the object would just stick to walls. When moving vertically you can find when the Sprite is on the ground, and there is where you'd simulate a jump if the jump key is pressed.

    Slopes would need some extra logic when moving horizontally, and moving platforms would need some logic too. It just depends what you need.

    Also here's an entirely different idea I posted elsewhere before. It still uses solid but makes a duplicate of the layout in a different location.

    https://www.dropbox.com/s/i1vr8srq201gw ... .capx?dl=0

    Here's the topic it's from. Maybe one of those solutions will help.

    ignore-selected-solids-workaround-list_t167029?&hilit=Disable+collision

  • That's probably the way to do it, even from JavaScript.

  • I somehow missed you wanted the lowest value. Sorted it will give the highest value with pairs or probably triples. For the lowest you could reorder the array every possible way and try each one to see which is lowest.

    I have a capx that does it that I can provide tomorrow if you want.

    edit:

    Here it is. It tries every combination and eventually gives the order with the lowest value:

    https://www.dropbox.com/s/ajbvvy32cwd8m ... .capx?dl=0

    The algorithm is O(n!) and the implementation is also slow. With 9 values it takes like 10 seconds on my machine. and gives this answer:

    1*8*9 + 3*4*6 + 2*5*7 = 214

  • lires

    There is a third party plugin already.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Turns out you don't need a recursive function to try all different orderings of the numbers. Instead just sort the list first and just multiply and sum them in order.

  • Armored Pig DEV

    Extract the folder in the zip into the C:\Program Files\Construct 2\exporters\html5\plugins directory.

  • There is always going to be rounding, so finding an exact decimal number in the array may not work. Usually when comparing decimal or floating point numbers you'd do abs(num1-num2)<0.0001 or some sufficiently small number.

    You may be able to get by if you reduce the number before dividing. So maybe (num1%num2)/num2

    A full solution is to reduce the fraction first before dividing so that 1/3 and 10/3 with the numbers before the decimal will be identical.

    Num1=num1%num2

    g=gcm(num1, num2)

    Result=(num1/g)/(num2/g)

    Gcm is the greatest common multiple. You could look at Wikipedia to see how to do that.

  • I made this long ago so I don't really recall what I did.

    The number 32 in event 5 is the radius of the two balls added together. Maybe calculating that on the fly would do what you want.

    When dragging them you probably want to set the speed to 0.