R0J0hound's Recent Forum Activity

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

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

  • Try Construct 3

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

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

R0J0hound's avatar

R0J0hound

Member since 15 Jun, 2009

Twitter
R0J0hound has 155 followers

Connect with R0J0hound