Jonforum

Veteran
Veteran
Joined
Mar 28, 2016
Messages
1,636
Reaction score
1,459
First Language
French
Primarily Uses
RMMV
hi, there is a more elegant way to write this code ?
in my context, i would like to inverse the proprety easeX but randomly.

PHP:
            if(Boolean(Math.round(Math.random()))){ obj.easeX = ~obj.easeX+1;};
            if(Boolean(Math.round(Math.random()))){ obj.easeY = ~obj.easeY+1;};
if one have a beter sugestion.
because it is a little heavy for make a simple random reverse.
but I can't imagine another way cleaner.
thank you
 
Last edited:

Clock Out

Veteran
Veteran
Joined
Jun 14, 2016
Messages
92
Reaction score
45
First Language
English
Primarily Uses
RMMV
So the code should flip the sign of the number and the expression of the if statement generates either a 1 or 0. I think this can be simplified.
Code:
if (Math.random() < 0.5) {
    obj.easeX  *= -1;
}
 

Jonforum

Veteran
Veteran
Joined
Mar 28, 2016
Messages
1,636
Reaction score
1,459
First Language
French
Primarily Uses
RMMV
yes thank you, after sleeping, the solution jumps to my eyes, these fascinate how the brain becomes useless with exhaustion.

PHP:
var end = (function(){ //register Closures setup
        var easeX = setup.xStrength||0;
        var easeY = setup.yStrength||0;
        var rot = setup.rotStrength||0;
        var time = setup.time||100;
        var oX = pixiBox.x;
        var oY = pixiBox.y;
        return function(obj){
            var rand1 = Math.random();
            var rand2 = Math.random();
            if(rand1>0.5){ easeX = ~easeX+1;};
            if(rand2>0.5){easeY = ~easeY+1;};
          this._valuesEnd = {x:oX+(rand1*easeX+1), y:oY+(rand2*easeY+1), rotation:(rand1*rot)/100 };
          this.duration(rand1*time+time);
          this.start();
        };
    })();
 

Latest Threads

Latest Posts

Latest Profile Posts

Steam has announced a new feature to let people switch between playing on PC and on Steam Deck with the same save. I'll come back to add support for it to my steam plugins when the time comes.
Hang on, let me get my glasses...
giphy.gif
Bust Status 1!
Animated lipsynch as well as lineart. Just lineart so far...
Ramona Expression 1-2 L.gifRamona Expression 1-1 L.gifRamona Bust 1C.png
2 FPS 5 FPS Static
SF_People3_7 added!
index.php

Anyone want dynamically soft shadow? :kaohi:
1643106068630.png

Forum statistics

Threads
118,691
Messages
1,117,942
Members
155,819
Latest member
SCW
Top