R0J0hound's Forum Posts

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

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

  • Try Construct 3

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

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