R0J0hound's Forum Posts

  • It involves rotating the points around the piggy center.

    dropbox.com/s/4332355gekn2sfn/distortmesh_rotating.c3p

  • I found this which is for desktop but is likely the same for documents. On windows at least, any language will have a "desktop" folder which points to the same folder with the translated version.

    stackoverflow.com/questions/57742157/node-js-how-to-find-the-desktop-path

    So for windows at least it would be this. Which will work for any language.

    NWJS.UserFolder&"Documents\"

    or you can also do a check to see if that folder exists and use this if it doesn't.

    NWJS.UserFolder&"my documents\"

    For mac and linux you can try. Notice the other slash. Actually you could probably use this for windows too. Windows doesn't care what slash you use.

    NWJS.UserFolder&"Documents/"

    I'm not sure if mac and linux do the same thing with different languages as windows. It looks like those are valid folder on those platforms like windows too.

    Worst case you can first see if the folder exists, and create it if it doesn't.

  • Dt is just used for things to change at the same rate no matter the framerate.

    Most common use is for something you want to smoothly move 100 pixels per second.

    set x to self.x+100*dt. Basically rate*time=distance.

    Sometimes the formula can be written dt/60, but that can be rewritten to 1/60*dt.

    There are other ways people use dt in formulas with varying complexity. You'd have to look at those formulas case by case.

  • I think you're mixing up some variables in there.

    every 30 seconds
    moneyInBank > 0
    --- add intrestReward*moneyInBank to moneyInBank
    
    every 30 seconds
    moneyInBank < 0
    --- subtract intrestCost*moneyInBank from moneyInBank
  • Like I said you can probably do it with js. You'd effectively be making at least parts of three plugins: "audio", "user media" and "video recorder". All to just add stereo recording, which it looks like is possible to add but I'm getting that from various sources when googling about it. It still is more work than I'm willing to do at this point even to test to see if you can record in stereo. Worst case the browser only has mono recording, or you have to handle setting it up differently for each export type.

    You can run other programs from a construct project with a nwjs export, but antivirus programs may complain, and then there's the matter of knowing where audacity is installed to run it. Unless you bundle it with your program that is. But the process of running a program, having it do something in an automated fashion and then feeding the result back to your original program is a very hard problem to solve, even if it's even possible. html5 and javascript within nwjs isn't the right tool for that job.

  • Here's one way. When dragging it gets the signed angle difference of the amount the hand turned and multiplies/divides that by 12 to set the other hand's position.

    dropbox.com/s/tydbry8387y2dn6/clockHand_drag.capx

    After that I looked at your files. You can at least half fix it. In event 15 you can set the minute hand's angle to hours.angle*12 and that will work as expected. But I don't have a quick fix for setting the hours hand from the minutes hand. Mainly because you have to preserve the hours and I haven't had much luck preserving that.

  • Best I can tell there isn’t a way to select between mono and stereo recording in construct. You’ll have to use JavaScript to do it at a lower level. It has nothing to do with construct at that point. In fact construct may just add some complexity to do it.

    Google is your friend to find examples of maybe some libraries that handle that.

    Best I can tell it involves requesting access to the microphone, creating a web audio context with stereo, use the microphone as a source, that sends chunks of raw audio to an array. Then use a library or something to encode it as some sound format.

    Doable but could take some time to do. Best case you’ll find some code you can drop in and use.

    I’m a fan of trying to find a way to do stuff. But you have to weigh the effort to do it vs shifting to a different idea.

  • I think that’s an artifact with how the perlin noise is calculated. It’s kind of hard to google info about it. According to the description of the algorithm on Wikipedia I can see a part of the calculation which will make the result tend more to a midrange value. If you implemented the algorithm with events you could correct that but I’m not sure if it would affect the look of the noise in an adverse way.

    From what I read, traditional perlin noise causes most values to be in the -0.7 to 0.7 range. But if you change that to the 0-1 range you get values like you’re testing.

    One thing you can do is scale the noise to be closer to the 0-1 range. Something like this:

    ((Noise(x,y)*2-1)/0.75)/2+0.5

    It converts it to the -1 to 1 range, scales it by 0.75 then converts it back to the 0 to 1 range.

    The 0.75 comes from your max value of 0.85. (0.85-0.5)*2=0.7 but I just used a slightly higher value.

    There’s also different way you can scale it. Using an exponent you can push values from the center.

    Value= Noise(x,y)*2-1

    Value= sign(value)*abs(value)^0.3

    Value= value/2+0.5

    The 0.3 is a bit arbitrary. But no matter the value you won’t get a result out of the 0 to 1 range.

    The way you calculate the min/max works too. You just don’t have to do that every time your games runs. The values you get will hover around the same thing for each noise type. So you can find those once outside your game and just use those values to normalize your game. You can then clamp that too if you have outliers.

    Clamp((Noise(x,y)-minValue)/(maxValue-minValue), 0, 1)

    You asked about simplex noise but I imagine that has the same quality as perlin. You could also do smoothed noise and get a perfect 0-1 range, it just looks more grid like.

  • Hi,

    Had a look and no, I'm not wrapping my head around it. I just see a lot of shuffling going on.

    Based on this whole thread you are doing three things: shuffling, shuffling using a specified order, and displaying the numbers.

    function shuffle(text)
    -- var i=0
    -- repeat 10 times
    -- -- set i to int(random(4))
    -- -- set text to left(text, i) & mid(text,i+1,10) & mid(text,i,1)
    -- return text
    
    function shuffleBy(text, order)
    -- var ret=""
    -- repeat 4 times
    -- -- add mid(text, find(text, loopindex), 1)
    -- return ret
    
    function display(text, x, y, anim)
    -- repeat 4 times
    -- -- create sprite at (x, y+32*loopindex)
    -- -- sprite: set frame to int(mid(text,loopindex,1))
    -- -- sprite: set animation to anim

    I can't follow all of what you're trying to do but everything can be done with those building blocks. Notice the display just creates the sprites. Just delete the old ones first.

    I the case of one of your first example. You have a number, it's then shuffled by one of three unique choices, then it's shuffled by another value and you get a result.

    var A = shuffle("0123")
    var B1="",B2="",B3=""
    while B1==B2 or B1==B3 or B2==B3 
    -- B1 = shuffle("0123")
    -- B2 = shuffle("0123")
    -- B3 = shuffle("0123")
    var correctB = choose(B1,B2,B3)
    var C = shuffle("0123")
    var answer = shuffleBy(shuffleBy(A, correctB), C)
    
    //display
    display(A, 100,100, "alpha")
    display(B1, 100,100+32*1, "digits")
    display(B2, 100,100+32*2, "digits")
    display(B3, 100,100+32*3, "digits")
    display(C, 100,100+32*4, "digits")
    display(answer, 100,100+32*5, "alpha")

    Beyond that all I can gather from your other posts is you have additional steps added. Here I just had the display create the objects on the fly but you can have it pick existing objects instead.

    I'm not sure if any of that is helpful. I'm going to have to take a break from this problem though.

  • Well depending on how you’re doing the noise you will have a function noise(x,y) which you can scale and offset with noise(x*scale+offsetX, y*scale+offsetY), or maybe you’re just setting random values to a 2d array.

    Anyways let’s say for example you want a 2d grid with a point every 32 pixels. Just have a 2d array of z values.

    You can get the nearest point’s z with

    Z = Array.at(round(x/32), round(y/32))

    Or if you want a linear interpolation between the points it would be:

    Z = lerp(

    lerp(array.at(int(x/32),int(y/32)), array.at(int(x/32)+1,int(y/32)), x/32-int(x/32)),

    lerp(array.at(int(x/32),int(y/32)+1), array.at(int(x/32)+1,int(y/32)+1), x/32-int(x/32)),

    Y/32-int(y/32))

    Or something like that. Google bilinear interpolation for other explanations. You can also do bicubic interpolation but that’s more involved albeit gives curved interpolation. Or you could use cosp instead of lerp.

    Anyways, it’s a bit harder to reason about 3d problems from descriptions.

  • I appreciate the offer but I’m a bit pressed for time lately. No coffees needed. I’m actually considering getting rid of that since I’m happy to help as I have time usually. I can try to have a look again one of these days. It’s just not a fun problem to work on and I’ve created more work for myself since I haven’t been able to create something that is easy to understand or use.

    I burn out on projects pretty quick, even the ones I enjoy. But I’ll see if I can get a chance to look at this again later.

  • Currently that can only be done at edit time.

  • Glad you’ve found it useful. I’m not currently developing it further. I coded myself into a corner and would need to take time to figure out the best way to rewrite it and I don’t have the same momentum or time to do that at this time.

  • One way is with a direction vector.

    Subtract one object’s position from the other and normalize that.

    DirX=Ax-bx
    DirY=ay-by
    Dirz=az-bz
    Length=sqrt(dirx^2+diry^2+dirz^2)
    Dirx=dirx/length
    DirY=diry/length
    Dirz=dirz/length

    I’d recommend reading some tutorials about vector math. It’s useful for 3d stuff even if you just learn the basics.

    There are other ways to define angles in 3d: spherical coordinates, axis angle, 3x3 matrices, quaternions. They all have their uses.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Shaders in construct are limited in what you can access. So you can't access additional textures currently unless they update it in the future. Best bet would be to add the idea to the suggestion platform and hope it's picked up.

    According to the manual:

    construct.net/en/make-games/manuals/addon-sdk/guide/configuring-effects

    That page lists what you have access to from an effect. Currently the two textures you can have access to are the foreground and background. Maybe with some trickery you could have two sprites stacked and use the backgound samper to get the image below. However that has a lot of cases it probably wouldn't work well.

    An unsupported way would be to use webgl directly but that can be tricky/kinda unsolved for C3. Construct's renderer uses webgl behind the scenes currently, with a focus on batching things for speed. In construct 2 I found that you could end all the current batches and then use any webgl you wanted for maximum flexibility. The only caveat was you needed to make sure the webgl state was unchanged when you finished the webgl code otherwise it would break construct's renderer.

    Construct 3's renderer has been reengineered and updated a few times so it's less clear how to utilize custom webgl, if at all. Last I looked it's setup in suck a way to be more of a black box that you can only interact with in a supported way. Also I believe they plan on utilizing a different api later on, and I could see them reworking the renderer in the future, so that would make any unsupported solution easy to break.

    Anyways if you want to attempt it you'll need a few things. First you'll need to access the webgl context of the canvas. There may be something in the js sdk that provides that or you can attempt to grab it from the canvas itself. Next you'll need to access the compiled shader program for your effect. That's probably the biggest roadblock as that might be hidden behind some closures in construct's renderer. Also even if you can find a list of shader programs in the renderer it may still be an issue of figuring out which one it is.

    Anyways, if you're able to find a way to access your effect's shader program then something like the following might be a way to set a second texture you can access from the effect.

    You'd add this line to your effect:

    uniform sampler2d texture2;

    Then to make that reference a texture you'd need to do something like this:

    function setTexture2(gl, program, texture)
    {
     var u_tex2Location = gl.getUniformLocation(program, "texture2");
     gl.uniform1i(u_image0Location, 4); // texture unit 4.
     gl.activeTexture(gl.TEXTURE4);
     gl.bindTexture(gl.TEXTURE_2D, texture);
    }

    You need to call that function with the webgl context, the shader program of your effect, and the handle to a webgl texture. The texture is either loaded with wegl or you somehow access another texture from a sprite or something. The most fragile part here is I'm assuming that texture unit 4 isn't used by construct's renderer so we take advantage of that by using it. You'd only need to call that function when we want to change the texture.

    Other potential issues that may need to be dealt with is how that will sync with the renderer. There may be other issues I'm not thinking of.

    Overall I generally just try to work within what features construct provides, but there are other potential solutions, they just don't always pan out.