R0J0hound's Forum Posts

  • Guess you could do it by marking all the instances in a way independent of the families. Unfortunately it can’t be a variable since that’s family specific, but maybe something global like opacity, or something you aren’t using.

    So the process would be to start by marking nothing then after filtering the sol set the mark and pick the other.

     Every tick
    — family1: set opacity to 100
    
    Some event that picks instances of family1
    — family1: set opacity to 50
    
    Family2: opacity=50
    — do stuff
    
    Every tick
    — family1: set opacity to 100

    It’s a bit annoying to have to utilize opacity so you could add picked Boolean variable per family as well.

    Basically you need a picked Boolean per family you want to copy the sol from. And for this to work the families involved need to all have the same object types. Hopefully the iid order of both families is the same too.

    Then with all instances of both picked you can use pick by evaluate as an implicit loop.

    Every tick
    — family1: set picked1 to false
    — family2: set picked2 to false
    
    Some event that picks instances of family1
    — family1: set picked1 to true
    
    Pick all family1
    Pick all family2
    Pick family2 by evaluate: family1.picked1
    — do stuff

    Either method requires resetting the picked value before using again.

    Edit: iid stuff shouldn’t be needed.

  • Doesn’t look like much is available beyond what the included text to speech plugin does. Limited local voices and many voices on the cloud but there seems to be limited selection. Maybe it’s hard to make one?

    From what I can tell there are two parts to doing text to speech.

    1. Convert text to a list of phonemes (or sounds) to say the words. Basically that would be done by applying all English pronunciation rules to the text. Could be tedious but a shortcut could be to utilize a website that can do the conversion to do it with all the dialog beforehand. Would make the code simpler.

    2. Have a recorded sound of each phoneme and their length so you can play that list. English has 44 so that’s mostly busywork to record and trim the recordings. Better playback varies volume, pitch and speed to replicate speech more closely but it would require more expertise to know in what ways to do that. A pro about doing it with just sounds is you can utilize any feature the audio plug-in provides.

    A prototype of the idea could be record a few phonemes to do some words to see how it sounds. Likely it would be fairly monotone and robotic.

    State of the art seems to utilize neural networks to extract phonemes from a sample of speech and a different one to blend the phonemes together to sound less robotic. But that’s out of the scope of my knowledge.

    That said I’m just sharing some ideas. I lack the time and expertise to make a complete solution at this time.

    Edit: tried a simple test where I tried recording the individual sounds and then combining them together manually. It came out pretty rough. More research is needed.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • If you have a screenshot of the next level and a current level screenshot you can load those onto sprites and utilize distort meshes to do the rotation. Or with a clever 3d camera rotation you could load the images onto the sides of a cube and just rotate it.

    You can take a screenshot of the current level pretty easily but to screenshot the next level you’d need to load it, and let it render a frame before taking a screenshot. But that flicker wouldn’t be nice. A possible workaround is to screenshot the start of all the levels beforehand and use those images.

    Another idea is to do your own level loading instead of doing layout changes. That would allow you to load the next level before unloading the current one. Then you’d be able to draw the new level onto a drawing canvas and use that for the second image.

    Honestly getting the images is the limiting part in construct.

  • One strategy is to just create a bunch of objects, then try repositioning them if any overlap, and finally just remove any overlapping sprites if repositioning doesn’t work. You can change the second repeat to have it try longer.

    Start of layout
    Repeat 100 times
    — create sprite at random(640), random(480)
    
    Start of layout
    Repeat 1000 times
    Sprite: overlaps sprite
    Pick random sprite instance
    — sprite: set position to random(640), random(480)
    
    Start of layout
    Sprite: overlaps sprite
    Pick random sprite instance
    — sprite: destroy

    But since you don’t like bunched up sprites or too much empty space you want more of a uniform spacing which is less random.

    One possible solution is to just move each pair of sprites away from each other if they get too close.

    So the logic is then: create a bunch of sprites, loop over each pair and push them apart, and finally clean up any overlapping sprites or any that were pushed off screen.

    Start of layout
    Repeat 100 times
    — create sprite at random(640), random(480)
    
    Var i0=0
    Var i1=0
    Var d=0
    Var a=0
    
    Start of layout
    For “i0” from 0 to sprite.count-2
    For “i1” from loopindex(“i0”)+1 to sprite.count-1
    — set i0 to loopindex(“i0”)
    — set i1 to loopindex(“i1”)
    — set d to distance(sprite(i0).x,sprite(i0).y,sprite(i1).x,sprite(i1).y)
    — set a to angle(sprite(i0).x,sprite(i0).y,sprite(i1).x,sprite(i1).y)
    — compare: d<100
    — — pick sprite instance i0
    — — — sprite move (100-d)/2 pixels at angle a
    — — pick sprite instance i1
    — — — sprite move -(100-d)/2 pixels at angle a
    
    Start of layout
    Sprite is offscreen
    — sprite: destroy
    
    Start of layout
    Sprite: overlaps sprite
    Pick random sprite instance
    — sprite: destroy

    It treats the objects as circles with a radius of 100 but you can change that. You can also add another repeat to the top of the second event to loop over the pairs multiple times to better ensure there is no overlaps.

    There are also other variations you can do. Such as using a family to reference other instances, or maybe utilizing the custom movement’s push out action to separate pairs. You could also just give the objects the physics behavior with no gravity and high damping. That would make the objects not overlap after a second or so.

  • You can place an object on the edge of a circle with:

    X=radius*cos(a)+centerX

    Y=radius*sin(a)+centerY

    To make it move around the circle you’d change “a”. One way to do it is:

    A=mouse.x

    Or you can tune that

    A=(mouse.x-scrollx)*factor+startAngle

    Where we subtract the scrollx to have a centered mouse result in no rotation. Factor is basically how fast the rotations come from the mouse position. And startAngle is where you want to start rotating from.

    That was for calculating an angle from mouse.x in an absolute way. You can do it relatively too.

    Var startX=0

    On touch start

    — set startX to touch.x

    Is touching

    — add touch.x-startX

  • I’d say the more common use case is for the push out actions to work successfully no matter what. Being able to specify a give up distance seems to needlessly make things more complex. And really if I wanted to do that I’d rather do it manually from the starting position and the pushed out position.

    That said, I stopped using the push out actions after finding they weren’t as accurate as I would have liked. Construct likely leans on its very good collision detection functions, but probably does some kind of repeated move and overlap check. So limiting the distance sounds like a way to limit huge loops. Just a guess though.

    There are other good solutions for resolving collisions though. A common one is utilizing overlap checks and iteratively moving stuff. If you treat the object you’re pushing out as a circle you can utilize sdfs. Then there’s SAT, GJK, or MPR if you want more deluxe solutions.

  • Post how you’re doing it now and maybe someone can spot what’s amiss.

    Generally the logic would be, request the file with Ajax, use tokenat to get a word at a time, then you could compare the length of the word before adding it to a dictionary.

    Var data=“”
    Var word=“”
    
    Start of layout
    — Ajax: request file “dictionary.txt”
    
    Ajax: on request complete
    — set data to Ajax.lastdata
    — repeat tokencount(data, newline) times
    — — set word to tokenat(data, loopindex, newline)
    — — compare: len(word) <= 7
    — — — dictionary: add key word

    For thousands of words this will be slow but at least it’s only done once. You could then save the dictionary.asJson and just load that so you don’t have to parse the file every time. Or if it’s essential to just parse fast, don’t use tokenat, use find and mid instead.

  • There’s a system condition “pick overlapping point” that will do that. Or depending on the shape there may be a simple algorithm to check.

  • Here's my last idea. Useful for any number of variables.

    dropbox.com/scl/fi/60yypcux55y0cy0edb0ws/highestVar_randInstWhenTied.capx

  • Doesn’t seem to draw anything on safari iOS but the math looks fine.

    You don’t have to convert to radians because construct uses degrees and not radians for the trig functions.

    I see you are ensuring the angle values are in the 0-360 range. That’s only needed for displaying the angles, the math will work the same without it.

    You probably don’t have to find the min and max noise value every time. I’d run it once, write down those values and just input those in the variables. That would at least remove the startup pause.

    You can probably combine steps together to use less events if you wanted too.

  • Yeah I’d do something like your first example and I’d refactor it as I go. Any abstractions would come organically as they made sense to simplify things. Basically I figure it out as I go.

    The second example is less readable to me.

  • No. Events aren’t actually converted into JavaScript. They are converted into data that the construct runtime runs and keeps track of picking and all the other nuances of the event system.

  • In my experience most elegant and readable is less abstractions for me. A tree of conditions and some variables should be enough. But we all have our own styles of what we consider elegant code.

  • Hmm well the meat of it is to compare what was typed so far with the command.

    text = left(command, len(left))

    If that's true that could be shown as a guess.

    I don't want to deal with form objects or js so here's a way to do it with the keyboard and text object.

    dropbox.com/scl/fi/13ai14e9r80zmv1qdm2j2/rough_autocomplete.capx

    Probably can do it with a textbox too. Just replace the text objects with textboxes. Then do some CSS to make the main editbox have a transparent background so you can see the guess underneath.

    Probably could do better with parsing the commands for syntax errors and giving more advanced autocomplete per token.

  • Spine, Spriter and dragonbones? No editor in C2 (that's not really possible) but you can load stuff in that was created with those tools.