[SOLVED] Game_Screen: updateShake()

Status
Not open for further replies.

aporokizzu

anti-kumbaya
Veteran
Joined
Jan 14, 2020
Messages
59
Reaction score
89
First Language
english
Primarily Uses
RMMV
This is the function Game_Screen.prototype.updateShake (located in the rpg_objects.js file):
Game_Screen.prototype.updateShake.png

I am interested to know / am wondering if anybody can tell me where / what is processing the $gameScreen._shake and $gameScreen._direction values that are being altered during this function?

I am assuming that somewhere, these parameters are being taken and used to dictate which way the screen should move every update to create the shake effect... I just can't find where.

I tried looking through the other core JS files but came up blank.

Thanks in advance!
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,087
Reaction score
1,508
First Language
EN
Primarily Uses
RMMZ
I believe _shakeDirection is internal, i.e. it's only used to determine how _shake changes in this method. _shake itself determines a display offset for the current spriteset, cf. rpg_sprites.js:
JavaScript:
Spriteset_Base.prototype.updatePosition = function() {
    var screen = $gameScreen;
    var scale = screen.zoomScale();
    this.scale.x = scale;
    this.scale.y = scale;
    this.x = Math.round(-screen.zoomX() * (scale - 1));
    this.y = Math.round(-screen.zoomY() * (scale - 1));
    this.x += Math.round(screen.shake());
};
I.e. the x-position of all spritesets is offset by the screen's current _shake value. If the spriteset is offset, all its sprites will also be offset. :)
 

aporokizzu

anti-kumbaya
Veteran
Joined
Jan 14, 2020
Messages
59
Reaction score
89
First Language
english
Primarily Uses
RMMV
I believe _shakeDirection is internal, i.e. it's only used to determine how _shake changes in this method. _shake itself determines a display offset for the current spriteset, cf. rpg_sprites.js:
JavaScript:
Spriteset_Base.prototype.updatePosition = function() {[/INDENT]
[INDENT]    var screen = $gameScreen;[/INDENT]
[INDENT]    var scale = screen.zoomScale();[/INDENT]
[INDENT]    this.scale.x = scale;[/INDENT]
[INDENT]    this.scale.y = scale;[/INDENT]
[INDENT]    this.x = Math.round(-screen.zoomX() * (scale - 1));[/INDENT]
[INDENT]    this.y = Math.round(-screen.zoomY() * (scale - 1));[/INDENT]
[INDENT]    this.x += Math.round(screen.shake());[/INDENT]
[INDENT]};
I.e. the x-position of all spritesets is offset by the screen's current _shake value. If the spriteset is offset, all its sprites will also be offset. :)
Excellent! I appreciate the explanation. Thank you :)
 

Kuro DCupu

Trust me, I'm a veteran RMer
Veteran
Joined
Jul 6, 2014
Messages
480
Reaction score
1,467
First Language
Indonesia
Primarily Uses
RMMV
Yea, it's only shake left and right.

_shakeDirection only have 1 and -1 outcome, which is right and left respectively.

For example, if you put 5 as power, the expected outcome would be like this :
0, 1, 2, 3, 4, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -4, -3, -2, -1, 0

Then combine that with speed for the frequency.

The code looks a bit cringe, to be honest... but all is fair as long as it works I guess.
 

aporokizzu

anti-kumbaya
Veteran
Joined
Jan 14, 2020
Messages
59
Reaction score
89
First Language
english
Primarily Uses
RMMV
Yea, it's only shake left and right.

_shakeDirection only have 1 and -1 outcome, which is right and left respectively.

For example, if you put 5 as power, the expected outcome would be like this :
0, 1, 2, 3, 4, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -4, -3, -2, -1, 0

Then combine that with speed for the frequency.

The code looks a bit cringe, to be honest... but all is fair as long as it works I guess.
Thank you!
 

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
7,829
Reaction score
5,221
First Language
Dutch
Primarily Uses
RMXP

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

 
Status
Not open for further replies.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:
To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

Forum statistics

Threads
105,847
Messages
1,016,972
Members
137,561
Latest member
JaCrispy85
Top