R0J0hound's Recent Forum Activity

  • Ah, that's a bit different.

    Here's one way.

    dropbox.com/s/k4pdvewd4qbp4y8/shuffle_combinations.capx

    And modified if you want a specific combination included in the mix.

    dropbox.com/s/fv39mxvfsx41vsn/shuffle_combinations_with_a_predefined.capx

  • I suspect the issue has to do with the size of the drawing canvas.

    Don’t make it the size of the layout, just make it the size of the screen, and position it to the scroll position.

    You could make the draw reactance still cover the layout, or just make it cover the visible view area.

    Since it is visual effect you don’t need it to be bigger than the screen. Besides that will save video ram too.

    Anyways the reason the size of the canvas is probably causing your issue is the canvas is using a texture and webgl has a maximum texture size per device which is smaller than that layout size.

  • I've heard advanced random can generate a list of non repeating combinations but I haven't used it.

    Here's one way to generate an array of all the combinations. One idea more in addition to the other answers is you can store random(1) in the first column and then using sort(x) will effectively shuffle the array.

    dropbox.com/s/o2xmtjo8yqkid56/combination_shuffle.capx

    That just loops over that list of pairs which may be fine.

    An alternate idea is to just generate a random pair every time and check it against a history of the pairs of numbers. It will keep generating a random pair till it's unique. For example this is guaranteed to a not duplicate a pair of values for at least 5 turns.

    dropbox.com/s/xptgru4msx1rkz5/combination_history.capx

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ah, I see. Yeah, doing what you want is much simpler than what I proposed. I'd say still use the drawingCanvas. You can even use it to make the shadows from the objects directly.

    This clears the canvas, rotates the trees 221 degrees, pastes trees to canvas, return the trees to 0 degrees, then draws a black rectangle with the "source in" blend.

    dropbox.com/s/3noo9ie08ckvx6r/shadow_blend_simple.c3p

    Or instead of rotation, you could use distort meshes to make a skew.

    dropbox.com/s/qczxy22l8tr936s/shadow_skew.c3p

  • I think the drawingCanvas example would be the simplest one since it just uses the z order of the objects.

    Do you have an example project of how you set up the objects? If the shadows and objects are in one family then that’s fairly simple. If instead it’s an assorted variety of objects then that is a bit less simple.

    The verbose pseudo code of what we want to do is this:

    For each object ordered by zorder
    — is a shadow? Make visible and set opacity to 100
    — is not a shadow? Set blend to destinationOut
    — paste object
    — set blend mode to normal
    — is shadow? Make invisible

    But with events there are some simplifications.

    Anyways, with an example of how your objects are setup I could make a more specific example.

  • So here are some ideas. For an example I had a few solid green balls that are in front of and behind some blue clouds. The goal is for the clouds to be uniformly blended together. I went for the simple case of one object type, so you'd either have to use a family or do something more complex for multiple types.

    The first basically clones the first layer onto a second. Then all the objects are given 100% opacity and the solid objects have destination out.

    dropbox.com/s/vhegleb8dry4l15/shadow_blend_clones.capx

    The second C2 example uses the third party paster plugin. All the objects are drawn to the paster, but the solid are erased.

    dropbox.com/s/q893tdqvcaqmgu5/shadow_blend_paster.capx

    The C3 version using the drawing canvas. Basically the same as the paster one.

    dropbox.com/s/i7nl6hvrgdlkyhy/shadow_blend_c3_canvas.c3p

  • I’ll try to make an example tomorrow. Basically one layer would be just the objects, and the other layer would have objects and shadows, but the objects are subtracted away.

  • Besides a layer I suppose you could use a canvas instead.

    Draw all the shadows to the canvas with full opacity and all the other objects with a “destination out” blend. Then you can set the canvas’ opacity.

    I’m a bit iffy if the paste action be used like that in c3. You’d need to draw things in order.

    Another idea that would work is a layer. All the shadows are there and clones of all the objects with “destination out” blends. May be a bit tedious to work with though.

    What it comes down to is if we want multiple shadows to be equally transparent, even in the overlapping areas, we need to draw them full opacity together first and then make them transparent.

  • Here's one possible solution.

    For each of your items you'll want to store a "mask" of what squares it occupies within it's rectangle. So for a gun it could be:

    1111
    1000

    So when you drop an item into an inventory you'd only need to see if the 1 places were unoccupied as well as inside the array. If all the 1 were then you could then place the object in the inventory.

    Here is an example without arrays, although you could certainly use arrays instead. I'm just using "is overlapping point" instead of an array lookup. It handles placing and removing items, as well as throwing them out if they are placed in an invalid spot. Perhaps some of the ideas here are useful.

    dropbox.com/s/tpwx74fq1c43auc/Fit_shapes_into_slots.capx

  • I suppose one way would be to use these system expressions.

    CanvasToLayerX(layer, x, y)

    CanvasToLayerY(layer, x, y)

    LayerToCanvasX(layer, x, y)

    LayerToCanvasY(layer, x, y)

    Cx = LayerToCanvasX(sprite.layer, sprite.x, sprite.y)
    Cy = ...
    Lx = CanvasToLayerX(sprite2.layer, cx, cy)
    Ly = ...
    D = distance(sprite2.x,sprite2.y, lx,ly)

    Another is to come up with the formula to do the parallax. It may end up being simpler but may take a bit of fiddling to get it right.

    Off the top of my head if there’s no rotation then

    X2 = ((x-scrollx)*parallax+scrollx)*scale

    Could be a possible start

  • You'll still need to find the angle of the surface. This is often called the collision normal. Construct calculates that internally to some extent for the bounce and the push out. But besides that you'll have to calculate that yourself.

    However, why not just use the bullet behaviors bounce? No need to replicate it. You can add it to the object but have it disabled. Move the object with custom and when you want to bounce do this:

    1. bullet: enable
    2. bullet: set speed to custom.speed
    3. bullet: set angle of motion to custom.angleOfMotion
    4. bullet: bounce
    5. custom: set speed to bullet.speed
    6. custom: set angle of motion to bullet.angleOfMotion
    7. bullet:disable

    Or at lest something along those lines.

    You can go the other route of finding the normal of a collision, but you'll have to calculate that per shape type which can add up. Or you can guesstemate the angle by sampling a bunch of points around the object's edge and averaging the overlapping points, but that's a rough approximation.

  • Try it I suppose. Actually I just read your issue again. You’re using a 60pixel square and in the capx I use a 64pixel one. You just need to find the 32s in the events are replace them with 30s to fix it.

    It’s just half the width