-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbentelk_Spin.js
83 lines (74 loc) · 2.56 KB
/
bentelk_Spin.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*:
* @plugindesc Allows you to cause the player to start/stop spinning in place (even while walking). See "help"...
* @author Ben Hendel-Doying
* @help
* To cause the player to start spinning, run this script (either via an event,
* or your own JS script)
*
* $gamePlayer.startSpinning(10);
*
* You can replace the 10 with any number from 1 to 60. A higher number means a
* greater speed of rotation. (Technically, this is the number of 90 degree
* turns per second; there are 60 frames per second, so...)
*
* To STOP the player spinning, call:
*
* $gamePlayer.stopSpinning();
*
* You may also start the player spinning in such a way that they will
* automatically stop spinning after some number of frames:
*
* $gamePlayer.startSpinning(20, 60);
*
* The above will cause the player to rotate 20 times per second; they will
* stop spinning after 60 frames (1 second).
*
* @help
* COMPATIBILITY:
* * ALIASES Game_Player..update
* * ALIASES Game_Player..initialize
* * ADDS Game_Player..startSpinning
* * ADDS Game_Player..stopSpinning
*/
(function() {
Spin_Game_Player_update = Game_Player.prototype.update;
Game_Player.prototype.update = function(sceneActive) {
if(typeof this._spinDuration != 'undefined')
{
if(this._spinDuration > 0)
this._spinDuration--;
else
this.stopSpinning();
}
if (this._spinning) {
this._spinStep = (this._spinStep + 1) % 60;
if(this._spinStep % (60 / this._spinTurnsPerSecond) == 0) {
this._directionFix = false;
this.turnRight90();
this._directionFix = true;
}
}
Spin_Game_Player_update.call(this, sceneActive);
};
Spin_Game_Player_initialize = Game_Player.prototype.initialize;
Game_Player.prototype.initialize = function() {
Spin_Game_Player_initialize.call(this);
this._spinning = false;
this._spinStep = 0;
this._spinDuration = undefined;
};
Game_Player.prototype.startSpinning = function(turnsPerSecond, duration) {
if(!this._spinning)
this._beforeSpinDirectionFix = this._directionFix;
this._spinning = true;
this._spinTurnsPerSecond = turnsPerSecond;
this._directionFix = true;
this._spinDuration = duration;
};
Game_Player.prototype.stopSpinning = function() {
this._spinning = false;
this._spinStep = 0;
this._directionFix = this._beforeSpinDirectionFix;
this._spinDuration = undefined;
};
})();