Helping me reduce this Method size

Hi guys so I was writting a secret plugin although I meet a problem....this method is like TO MUCH big and have repetetive code in it...so I would like to ask you to show me possible way's to shortening this method?

because I will being honest it's like 51 freaking line's >>"

Emoji_Secret.prototype.updatePictureSprite = function(sprite) {// setting the sprite bitmap. sprite.bitmap = this._imageBitmap;// if spinBitmap is enabled it's will doing rotative movement. if (this.spinBitmap){ sprite.rotation += this.rotationSpeed;// else if rotation = 0 it's not affecting the sprite. } else if (this.rotationSpeed === 0 ){ sprite.rotation = 0;// else the sprite is serve for reference and rotating the sprite in a // specific angle. } else { sprite.rotation = Math.PI / this.radiant; }// Starting Sprite movement.// if static is enabled. if (this.enableStatic){ // if particle are falling. if (this.fallingParticle){ sprite.ay += this.speed * Math.cos(sprite.rotation); // else particle are moving in up movement. } else { sprite.ax += this.speed * Math.sin(sprite.rotation); } // if inverted Axis is enabled for sprite it's go for the right if (this.invertAxis){ sprite.ax -= this.speed * Math.sin(sprite.rotation); // else the sprite will start from the left. } else { sprite.ay += this.speed * Math.cos(sprite.rotation); } // if static is not enabled. } else { // if particle are falling. if (this.fallingParticle){ sprite.ay += this.speed; // else particle are moving in up movement. } else { sprite.ay -= this.speed; } // if inverted Axis is enabled for sprite it's go for the right if (this.invertAxis){ sprite.ax -= this.speed; // else the sprite will start from the left. } else { sprite.ax += this.speed; } }// FadeOut the sprite. sprite.opacity -= this.speed; };thanks for any further answer
While you could trim this down by using ternary operators (var a = expression ? b : c😉, there is nothing inherently wrong with a long function. Most of the time, simple ifs are actually faster, than using short, fancier ways.


/edit: That said, i would probably split the function at the outermost if and add 2 more. "updatePictureSpriteStatic" and "updatePictureSpriteNoStatic" (only examples, name them however you want). This makes your code easier to organize and also makes it easier to extend the class from another plugin, if it's make public.
True lol I think it's would be better to split it in two or 3 for avoid super long method...

Well Personally I think long method are not alway's easy to read honestly and need organisation haha
Each on of the inner if statements can be a method.

Original thread: https://forums.rpgmakerweb.com/threads/helping-me-reduce-this-method-size.53283/