R0J0hound's Recent Forum Activity

  • The browser doesn't provide much control with how it rasterizes text. Unless Construct wanted to do their own rasterizer with the freetype library or something like that.

    Here's an updated example that draws text and outlines using an sdf based sprite font. It's a tad simpler than the previous one, but lets you specify font size and colors. Only issue is there are some limits with how big of an outline you can have depending on the generated sdf image.

    dropbox.com/scl/fi/tt071d610pfzqfyda8czj/tiledbg_based_sdf_text_with_outline.c3p

  • If you only have a limited amount of text like that you could just pre-draw the text to images. I'm sure there are programs with font rasterizers that don't glitch like the one in some browsers.

    If your text can be a lot of different things you could instead try using a spritefont to do it. To do the outline you'd have two spritefonts, one for the outline, and one for the normal text. You'd just draw the outline first and place the text over it.

    Here's a test of that idea. I didn't use a generator that is easily adaptable to the spritefont object, but it's simple enough to use a tilebg to draw it char by char. There is some tighter kernelling in the json, but I didn't bother with that. The outline width is baked at 10px.

    dropbox.com/scl/fi/lzm4uaui3n7vs34tqt08v/tiledbg_based_text_with_outline.c3p

    As an exercise you can make the text scalable. You just need to multiply most values by a scale number. However, that would change the outline width as well.

    You could also extend the idea by using an sdf spritefont. There is a threshold effect that could be used to convert the sdf to crisp letters. Also, you could use the same sdf to draw outlines with dynamic widths. You'd have to test to see if that effect is up for the job.

  • This looks familiar somehow...

    What we do know is an outline effect works by coloring transparent pixels if there are pixels around it that aren't transparent on the texture.

    Maybe since the effect samples pixels far from the pixels on the sprite it could be sampling pixels from other sprite sheeted images.

    So maybe the effect isn't clamping the sampling to to just within the current sub-texture.

    If that is the case then either the effect could be modified, or we could take advantage to how the c3's effect compositor works to avoid sampling beyond the frame (sub-texture). You could do that by adding another effect to the object, and order that to be before the outline effect. When there are multiple effects the first effect is drawn to a temporary texture and that is used as input for the next one. With that nothing would be beyond the image to possibly sample.

    Anyways, just an idea.

  • If you're just doing it in events without behaviors, you will also need to handle the collisions with events too. That involves checking for an overlap with obstacles and then moving out of the obstacle and maybe updating the velocity.

    There are many ways to do that, but one way to do an event based movement for a jump with gravity would be:

    on any key pressed
    -- sprite: set vy to -100
    
    every tick:
    -- sprite: add 100*dt to vy
    -- sprite: set y to self.y+vy*dt
    
    sprite: y > 400
    -- sprite: set y to 400
    -- sprite: set vy to 0

    That last event acts as the collision detection and response for a ground at y=400. Likely you'd want to collide with actual objects but that would get more involved.

    One possible solution could be to move backwards till no longer overlapping. or in the case of landing on some ground you'd move it up.

    on any key pressed
    -- sprite: set vy to -100
    
    every tick:
    -- sprite: add 100*dt to vy
    -- sprite: set y to self.y+vy*dt
    
    sprite: vy>0
    while
    sprite: overlaps ground
    -- sprite: set y to self.y-1
    -- sprite: set vy to 0

    You'd likely want something similar when moving up, left, and right, just need to go backwards by pixel steps (or smaller steps to have smaller gaps). A common technique is to handle horizontal movement first, then vertical movement.

    Instead of moving backwards in steps it is possible to calculate exactly how far to move the object to not be overlapping, but that's less trivial to do.

    You could also utilize a behavior that has control turned off as a quick way to handle the collision response for you, but you get less control, and usually they work better when it's that behavior that moves the object.

  • You only need to access node transforms. Objects and bones are just nodes in glb files.

  • Nice feature request. But in the meantime you could build the model with those objects and toggle their visibility.

    Another idea could be to load the glb/gltf file directly and parse out the skeleton and animation data, then transform that to match the 3dmodel. It works but in my tests making a glb loader I haven’t been able to get the Skelton to perfectly match the 3dmodel yet.

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

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

  • Try Construct 3

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

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