-
-
Notifications
You must be signed in to change notification settings - Fork 51
/
RS_TitleMoveLine.js
180 lines (146 loc) · 5.18 KB
/
RS_TitleMoveLine.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
//================================================================
// RS_TitleMoveLine.js
// ---------------------------------------------------------------
// The MIT License
// Copyright (c) 2020 biud436
// ---------------------------------------------------------------
// Free for commercial and non commercial use.
//================================================================
/*:
* @plugindesc <RS_TitleMoveLine>
* @author biud436
*
* @param Max Lines
* @type number
* @min 1
* @desc Set the max lines that creates on the screen
* @default 8
* @max 30
*
* @param Line Width
* @type string
* @desc Specify the evaluate expression that gets the line width.
* @default Math.floor(Graphics.boxWidth / 40)
*
* @param Bitmap Color
* @type string
* @desc Specify the color of the bitmap.
* @default rgba(255, 255, 255, 1)
*
* @param Opacity
* @type string
* @desc Specify the evaluate expression that gets an opacity
* @default 64 + Math.randomInt(64)
*
* @param Scale
* @type string
* @desc Specify the evaluate expression that gets the scale
* @default 1.0 + Math.random()
*
* @param Move Speed
* @type string
* @desc Specify the evaluate expression that gets the move speed of line.
* @default 2 + Math.random() * 4
*
* @param Replace Bitmap As Image
* @require 1
* @desc Choose the image file if you want to replace as image.
* @default
* @dir img/pictures/
* @type file
*
* @help
* This plugin allows you to move vertical lines on the screen.
* if the line collides with the out of screen, it will be changed the direction of movement.
* ================================================================
* Version Log
* ================================================================
* 2020.02.29 (v1.0.0) - First Release.
*/
var Imported = Imported || {};
Imported.RS_TitleMoveLine = true;
var RS = RS || {};
RS.TitleMoveLine = RS.TitleMoveLine || {};
(function($) {
"use strict";
var parameters = $plugins.filter(function (i) {
return i.description.contains('<RS_TitleMoveLine>');
});
parameters = (parameters.length > 0) && parameters[0].parameters;
RS.TitleMoveLine.Params = {};
RS.TitleMoveLine.Params.maxLines = Number(parameters["Max Lines"] || 8);
RS.TitleMoveLine.Params.lineWidth = parameters["Line Width"];
RS.TitleMoveLine.Params.bitmapColor = parameters["Bitmap Color"];
RS.TitleMoveLine.Params.opacityEval = parameters["Opacity"];
RS.TitleMoveLine.Params.scaleXEval = parameters["Scale"];
RS.TitleMoveLine.Params.moveSpeedEval = parameters["Move Speed"];
RS.TitleMoveLine.Params.imageName = parameters["Replace Bitmap As Image"] || "";
//================================================================
// Sprite_MoveLine
//================================================================
class Sprite_MoveLine extends Sprite {
constructor(bitmap) {
super(bitmap);
this.initMembers();
}
initMembers() {
this.opacity = eval(RS.TitleMoveLine.Params.opacityEval);
this.scale.x = eval(RS.TitleMoveLine.Params.scaleXEval);
this._power = eval(RS.TitleMoveLine.Params.moveSpeedEval);
}
update() {
super.update();
const width = Graphics.boxWidth;
const bitmapWidth = this.width;
this.x += this._power;
if(this.x > width - bitmapWidth || this.x < 0) {
this._power *= -1;
}
}
}
class Scene_TitleMoveLine extends Scene_Title {
start() {
super.start();
this.createLineBitmap();
this.initWithLines();
}
createLineBitmap() {
const lineWidth = eval(RS.TitleMoveLine.Params.lineWidth);
const lineHeight = Graphics.boxHeight;
const imageName = RS.TitleMoveLine.Params.imageName;
let bitmap = null;
if(imageName !== "") {
bitmap = ImageManager.loadPicture(imageName);
}
this._lineBitmap = bitmap ? bitmap : new Bitmap(lineWidth, lineHeight);
if(!bitmap) {
this._lineBitmap.fillAll(RS.TitleMoveLine.Params.bitmapColor);
}
}
initWithLines() {
this._lines = this.getLines();
this.nextLines();
}
nextLines() {
let line = this._lines.next();
if(!line.done) {
const child = line.value;
const index = this.getChildIndex(this._windowLayer) - 1;
this.addChildAt(child, index);
this.nextLines();
}
}
*getLines() {
const maxLines = RS.TitleMoveLine.Params.maxLines;
const boxWidth = Graphics.boxWidth;
for(let i = 0; i < maxLines; i++) {
const sprite = new Sprite_MoveLine();
sprite.bitmap = this._lineBitmap;
sprite.x = Math.random() * boxWidth;
sprite.y = 0;
yield sprite;
}
}
}
window.Scene_Title = Scene_TitleMoveLine;
})(RS.TitleMoveLine);