R0J0hound's Recent Forum Activity

  • With the mouse object you can set the cursor image from a sprite. That won’t be a frame behind.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Brute force way would be to loop over all the keys, then loop over all the other keys and compare the values. But since you can’t do a double loop like that with one dictionary you’d want to copy the dictionary to another one first.

    Dcopy: load dictionary.asJSON
    Dictionary: for each key
    Dcopy: for each key
    Compare: dictionary.currentKey<>dcopy.currentKey
    Compare: dictionary.currentValue=dcopy.currentValue
    — do something since there are duplicate values

    That would let you handle it per duplicate value.

  • That’s unfortunate you can’t find any examples or tutorials. I know there are at least a few example of using a tilemap for digging. I’ve made some, dop2000 probably has too, and others as well.

    Had a quick look at your example. Yes, it makes it visually look like there are holes but as you’ve noticed that’s not enough to change collisions. To erase you need to destroy or distort objects.

    Here’s a mini tutorial on how to do digging with a tilemap.

    1. Add a tilemap and fill it with tiles.

    2. Add an event, on click, and add an action:

    Tilemap: erase tile at self. PositionToTileX(mouse.x), self. PositionToTileY(mouse.y)

    And that’s basically it. Reduce the tile size to make it less blocky.

    If you want to erase a shape instead of one tile you have to explicitly erase the tiles one by one. If you try to use object overlaps tilemap to erase tiles it won’t work because it won’t tell you what tiles are overlapping.

    To erase all the tiles overlapping an object you have to effectively check each tile one by one to see if they overlap. Construct doesn’t have a feature to do that so you’d need to do it indirectly.

    Loop over all the tile location on the tilemap. For each location that has a tile you’d place a square sprite the same size as the tile, then use an overlap condition to see if that square sprite overlaps the shape you want to erase. If it does erase the tile the square is over.

    To be faster you don’t have to loop over all the tiles. Just the ones around an object’s bounding box.

    Pseudo code for how the event fit that would look is this. Sprite is the object you want to erase and square is a tile sized sprite with an origin at its top left.

    For “x” from tilemap.positionToTileX(sprite.bboxLeft) to tilemap.positionToTileX(sprite.bboxRight)
    For “y” from tilemap.positionToTileY(sprite.bboxTop) to tilemap.positionToTileY(sprite.bboxBottom)
    tilemap: tile at loopindex(“x”),loopindex(“y”) <> -1
    — square: set position to tilemap.tileToPositionX(loopindex(“x”)), tilemap.tileToPositionY(loopindex(“y”))
    — square: overlaps sprite
    — — tilemap: erase tile at loopindex(“x”),loopindex(“y”)

    To texture the tilemap you’d probably just want to use a blend mode with a tiledbg.

    Anyways if that’s clear as mud then you’ll have to just wait till an example can be made or someone helps you find the previously made examples.

  • That’s unfortunate you can’t find any examples or tutorials. I know there are at least a few example of using a tilemap for digging. I’ve made some, dop2000 probably has too, and others as well.

    Had a quick look at your example. Yes, it makes it visually look like there are holes but as you’ve noticed that’s not enough to change collisions. To erase you need to destroy or distort objects.

    Here’s a mini tutorial on how to do digging with a tilemap.

    1. Add a tilemap and fill it with tiles.

    2. Add an event, on click, and add an action:

    Tilemap: erase tile at self. PositionToTileX(mouse.x), self. PositionToTileY(mouse.y)

    And that’s basically it. Reduce the tile size to make it less blocky.

    If you want to erase a shape instead of one tile you have to explicitly erase the tiles one by one. If you try to use object overlaps tilemap to erase tiles it won’t work because it won’t tell you what tiles are overlapping.

    To erase all the tiles overlapping an object you have to effectively check each tile one by one to see if they overlap. Construct doesn’t have a feature to do that so you’d need to do it indirectly.

    Loop over all the tile location on the tilemap. For each location that has a tile you’d place a square sprite the same size as the tile, then use an overlap condition to see if that square sprite overlaps the shape you want to erase. If it does erase the tile the square is over.

    To be faster you don’t have to loop over all the tiles. Just the ones around an object’s bounding box.

    Pseudo code for how the event fit that would look is this. Sprite is the object you want to erase and square is a tile sized sprite with an origin at its top left.

    For “x” from tilemap.positionToTileX(sprite.bboxLeft) to tilemap.positionToTileX(sprite.bboxRight)
    For “y” from tilemap.positionToTileY(sprite.bboxTop) to tilemap.positionToTileY(sprite.bboxBottom)
    tilemap: tile at loopindex(“x”),loopindex(“y”) <> -1
    — square: set position to tilemap.tileToPositionX(loopindex(“x”)), tilemap.tileToPositionY(loopindex(“y”))
    — square: overlaps sprite
    — — tilemap: erase tile at loopindex(“x”),loopindex(“y”)

    To texture the tilemap you’d probably just want to use a blend mode with a tiledbg.

    Anyways if that clear as mud then you’ll have to just wait till an example can be made or someone helps you find the previously made examples.

  • Simplest would be to cover the ground with small square sprites with the physics behavior and set to immovable. Then just destory the ones you wish to erase. You could place the tiles with a double loop at the start of the layout.

    However since that taxes the renderer, you could use one tilemap of small tiles to allow rendering to be faster. Erasing tiles becomes more involved though. You'd loop over the tiles near the mouse/touch and clear them if they are withing a certain distance away. Faster still could be to use to use the equation of a circle and erase runs of tiles at a time.

    Another way to modify a collision shape is to utilize a mesh to distort the object. That would be very light to render, but you'd need to do more logic to decompose the shape into multiple convex shapes.

    You could also probably get away by querying pixels on the drawing canvas around the ball and create hidden collision sprites on the fly to do the collisions.

    I'd search for lemmings, worms, or digging on the forum or tutorials section of the site to find examples.

  • The platform behavior resolves collisions in such a way that there is a small gap sometimes.

    By zooming in on small objects the gap will be more noticeable. A workaround could be to scale all the object sizes up so the relative size of the gap is smaller to make it less notable. I’ve also seen people shrink the collision polygon slightly to hid the gap, but that could shift it visually overlapping slightly.

    Another option could be to make the platform movement yourself with events, and do a different strategy to not have the gaps. The behavior resolves collisions by repeatedly moving in steps till the object doesn’t overlap. With your own collision resolving events you could control the size of the steps to have a smaller gap. Or do a tiered approach by first resolving with bigger steps then a few more passes with smaller steps.

    Also depending on the shapes you collide with it may be possible to use the geometry itself and calculate the exact position that the objects precisely touch.

    Anyways, just some ideas you can do on your end. Filing an issue is also an option that may or may not result in an improvement in the behavior. But it would get the dev’s opinion.

  • If you ever have the chance I’d recommend trying to replicate the drag n drop behavior with events. It’s not too complex and can give some more flexibility. But sounds like you got what you want working with the behavior.

    By losing collision detection, I meant at the transparent bits at the corners. If it’s just an image or effect, clicking on the transparent parts will still select the object. With the mesh you will be able to click through it. You could utilize the sdf of a rounded rectangle to do the collision detection, and actually the sdf of a rounded rectangle will be the basis of the effect if you look into doing that.

  • Things move in steps so the collision will almost always happen after objects overlap a bit. The behavior runs before the event sheet does so it makes sense that the behavior already resolved the collision and bounced the object.

    There are ways to detect the exact time a collision occurs but it mostly involves rolling your own physics engine. But beyond ball vs box collisions could get involved.

    If all you want is to have more control over the bounce angle you could save the velocity to a variable at the end of every tick. Then above that you could check for a collision and you’d have the before and after velocity and you could calculate the collision normal from that.

    You could also move the object backwards after a collision till it’s barely touching to get a more exact point of collision. However the way physics engines resolve collisions can be a bit inexact. They first push the objects apart, then calculate the bounce. If you saved the position before a collision you could use the loop idea to move forward to get a point of collision to avoid the push out inaccuracy. At that point we are using much less of the physics engine and mostly are using it for finding the collision normal.

  • Ah, it's just that the mesh edges aren't anti-aliased, but that doesn't seem like something we can control in construct. Guess you could paste to a canvas at double size and scale down to get some edge smoothing.

    Another option could be to make an effect to do the corner rounding. That would allow you to have antialiasing but you'd also lose the collision benefits.

  • You don't need to know how to use all the features of an array to use them. All arrays do is store multiple values in them, and all you need to be able to do is set the size, set values, and get values.

    Arrays indexes are 0 based, which means to access the first element of an array the expression would be Array.At(0), and the second would be Array.At(1), and so on...

    If you ever try to set a value in a cell that doesn't exist it will do nothing, and if you try to get a value from a cell that doesn't exist you'll get 0.

    And as noted above a way you can do what you're asking in your OP will look like this:

    So just literally changing a number variable to access different cells.

    The push action just increases the size of the array by 1 and places a value in the new cell. Array.CurValue, CurX, etc... are used when you use the "for each element" condition. You really don't really need to use those things. You could use normal event loops with loopindex as well. Overall arrays tend to be more closely related to traditional programming and is more abstract sometimes to understand them.

  • You can make a sprite like a 9patch with a mesh distort. Well, just as long as you want the edges and center to stretch and not repeat. You'd just need to run the event to update the mesh any time you resize the object or change the margin.

    dropbox.com/scl/fi/togz73on2n9750dx5k4y3/sprite_as_9patch.c3p

  • With 2d sprites you'd have to draw them lit from different sides I suppose.

    It may be enough to just have a gradient sprite over the flash with the additive, screen, or lighten blend mode though. You could even give the impression of a brighter flash by darkening everything underneath first. With more layers, or the drawing canvas you can mix and mask multiple light gradients with a sprite with blend modes. It's just something you'd have to fiddle with. If you find any information about how to do such a thing in photoshop or something the ideas may transfer.

    For more advanced lighting you could look into a normal map lighting effect. There is a built in one where you place the sprite, then a sprite on top to use as a normal map, and give the effect to that and provide the light location as parameters. There is also a third party effect that has more features. Anyways, the busywork to drawing/generating the normal maps of the sprites.