R0J0hound's Forum Posts

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

  • Try Construct 3

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

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

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

  • vikash2k2jsr

    Probably, that's why I mentioned it. I don't think I have the time to install that plugin and try it though.

  • It probably has to do with the color profile on your computer. Here is a link to other occurances of that:

  • It doesn't get too much simpler. With Alextro's you can still drag through the walls, and it may not work well for long shapes. If you tried the code I posted it would stop at walls but would snag on them and not slide.

    For sliding here are two different ways. The first moves horizontally then vertically a step at a time. Sliding works very well for unrotated walls.

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

    The second just pastes in the wall slide events I've used elsewhere with some other capx's. It's surprisingly modular I must say. Anyways, it requires putting an imagepoint at the corners of the walls, but the end result is smooth wall sliding.

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

  • This is a start:

    Global number x0

    Global number y0

    Global number x1

    Global number y1

    Start of layout

    --- set x0 to Sprite.x

    --- set y0 to Sprite.y

    Every tick

    --- set x1 to Sprite.x

    --- set y1 to Sprite.y

    --- Sprite: set position to (x0,y0)

    --- Sprite: set angle towards (x1, y1)

    Repeat distance(x0,y0, x1,y1) times

    --- Sprite: move forward 1 pixel

    ------ Sprite: is overlapping wall

    --------- stop loop

    --------- Sprite: move forward -1 pixels

    Every tick

    --- set x0 to sprite.x

    --- set y0 to Sprite.y

    That will stop the Sprite at walls when being dragged. Having it slide against the walls is more deluxe. There are a few examples around the forum. Not exactly simple but there may be other ways.

  • You can't use c++ with c2. Also Wikipedia seems to have a good description of that rng.