Yann's Forum Posts

  • emixam23

    Toi j't'aime bien, tu payes à l'heure, c'est honnête. J'espère juste que tu tomberas pas sur des blaireaux. Si j'étais pas déjà embauché quelque part à plein temps (40h/s), j'aurais volontiers accepté =)

    Au pire si t'as des doutes sur la qualité et/ou le niveau de ce qu'on t'envoie, tu peux toujours me d'mander.

  • I was mostly refering to what the wait means in construct2.

    It doesn't mean blocking a thread it means calling something later.

    I agree with you though that C2 should be more programmer oriented in its design. Making things appear too easy for n00bs end up making things hard for more serious projects.

    Like, I'd love to have more basic types than number and strings. Booleans and null would be nice. I mean... manipulable boolean, not like the "is Doomed" kind of condition but more like "Doomed == true" or better "Doomed == Function.Call("isAllowedToBeDoomed")"

    But otherwise, that doesn't change the fact that wait being a thread blocking function or being a delayed callback mecanism is a matter of choice. And I'm not really sure if the "hack" you suggest is good or not.

    What would happen if you call a wait in a multi nested loop? should we multiply by all the loop indices, or just the last one? and what if the user would want to do the former?...

    In the end, since javascript is the language construct export to, I think the delayed callback mecanism makes more sense.

    And documentation... yeah... documentation... (never really read it <_<)

  • ^ is the exponent operator

    10^0 = 1
    10^1 = 10
    10^2 = 100
    etc...[/code:nisj0wkv]now in the formula, the / 10^n just set the digit you want to be the first digit.
    
    % is the modulo operator
    It's formal definition would be that it's the remainder of the euclidean division of two numbers
    for example: [code:nisj0wkv]5 : 3 = 1 with remainder 2[/code:nisj0wkv]
    If you don't like this explanation you can also look at how it behaves according to different input to get a feel for it (after all we're not mathematicians)
    for example:[code:nisj0wkv]0%3 = 0
    1%3 = 1
    2%3 = 2
    3%3 = 0
    4%3 = 1
    5%3 = 2
    6%3 = 0
    etc.
    (see how things cycle?)[/code:nisj0wkv]now in the formula, the % 10  just gives you the first digit of any number
  • opacity to 0... Invisible is better as draw is skipped

    + Button: On clicked
        + Grid: Is Visible  -> Grid: Set Invisible
        + Else              -> Grid: Set Visible[/code:3b90y1lx]
  • if you have a

    global number MyNumber = 123456[/code:3vjecb8n]
    
    For any digit n (counting from 0) from the right the formula would be:[code:3vjecb8n]floor(MyNumber/10^n)%10[/code:3vjecb8n]
    
    for example:[code:3vjecb8n]floor(MyNumber/10^0)%10  -> 6
    floor(MyNumber/10^1)%10  -> 5
    floor(MyNumber/10^2)%10  -> 4
    ... etc[/code:3vjecb8n]
  • The headache usually comes more from not understanding loops than misunderstanding wait.

    And building something on assumption about why programmers do what they do is a bit dangerous. There's already a lot of programming style out their and I'm not sure they would all agree on that one (:

    For example, in Java you would probably do something like

    class MyObject {
        private static final float ANGLE_STEP = Math.PI/180;
        private static final float AMOUNT_TO_ROTATE = Math.PI/2;
        private static final int ROTATION_RATE = 300;
        private float angle = 0.0;
        void onClick() {
            new Thread(new Runnable() {
                    void run() {
                        float deltaAngle = 0.0; // auto reset
                        float startAngle = angle;
                        while(deltaAngle < AMOUNT_TO_ROTATE) {
                            deltaAngle += ANGLE_STEP;
                            angle = startAngle + deltaAngle;
                            sleep(ROTATION_RATE); 
                        }
                        angle = startangle + AMOUNT_TO_ROTATE; // to be sure to avoid any imprecision
                    }
                }).start(); // I always forget that one
        }
    }[/code:3l2i8wzz]
    
    In javascript you would do the more or less equivalent:[code:3l2i8wzz]var MyObject = (function () {
        var ANGLE_STEP = Math.PI/180;
        var AMOUNT_TO_ROTATE = Math.PI/2;
        var ROTATION_RATE = 300;
        function MyObject() {
            this.angle = 0.0;
        }
        MyObject.prototype.onClick = function() {
            var deltaAngle = 0;
            var startAngle = this.angle;
            var self = this;
            function rotate () {
                deltaAngle += ANGLE_STEP;
                self.angle = startAngle + deltaAngle;
                if (deltaAngle < AMOUNT_TO_ROTATE) {
                    setTimeout(rotate,ROTATION_RATE);
                } else {
                    self.angle = startAngle + AMOUNT_TO_ROTATE;
                }
            }
            rotate();
        };
    
        return MyObject;
    })();[/code:3l2i8wzz]
    In javascript  you don't have any kind of loop, you just give a callback to the timer system and call the function again until you're done (or use setInterval). That's more or less what I do with the capx I provided using the timer behavior.
  • TheDoctor

    I understand your confusion now.

    In unity and java, python, etc, you can use some kind of wait or sleep to tell the thread to just stop execution for a (more or less) specific amount of time.

    But you don't really have threads in javascript (or rather you only have one), so the wait can't work the same.

    What the wait does is registering a set of actions to be called after a certain amount of time.

    But doing this registration happens in one go. The repeat 90 will register 90 set of action to be executed after a given time (hence the wait loopindex * 0.3)

    If the wait was really blocking the thread, all the game will stop receiving inputs (:

  • Your problem was that you had the scrollTo behavior on your menu as well, so the scroll was set between the two position.

    I did a few modification on your project:

    • moved the movement logic into the blue collision box
    • make the hero sprite slavishly follow the blue collision box (using Pin)
    • moved the scrollTo behavior to the blue collision box instead of the hero sprite. This way you don't have "hero moves -> pin position the blue box -> scroll to blue box" kind of potentially laggy interaction. Now it's more like "blue box move -> scroll to blue box + pin position the hero sprite" kind of flow.
    • few personnal tweaks on the layout properties because I'm maniac.

    scrollToConflict.capx

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 7Soul you're answer is so short that it looks wrong (:

    wp2000 for some (probably good) reasons I didn't have the motivation to investigate, c2 doesn't allow dt to be greater than 0.1s, if your game is slower than 10 fps, dt will then be wrong.

    on 60 fps -> dt = 1/60 = 0.017 so after 60 frames of adding dt you get 1 (probably what 7Soul meant)

    on 10 fps -> dt = 1/10 = 0.1 after 10 frames you get 1 as well

    on 5 fps -> dt = 1/10 = 0.1 after 5 frames you only get 0.5 and that's probably your issue

    The work around is to compute your own dt value using the wallclocktime system property.

    I made a practical example few days ago: hiddenObjectClock.capx

  • Might want to use the tilemap plugin instead of spawning lots of sprites and potentially killing your perf.

  • If you have any doubt, it works "multi-dimensionally"

    deleteIndexOnAxis.capx

  • You can also right click the global variable and "move to event sheet"

  • Hmmm maybe that will help

    bumpMappingAlpha.capx