core2d 2.11.1 → 2.11.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -1
- package/package.json +53 -53
- package/src/ACL.mjs +54 -54
- package/src/Animation.mjs +73 -73
- package/src/ButtonLayout.mjs +36 -36
- package/src/ButtonLayoutMap.mjs +1 -1
- package/src/Color.mjs +148 -148
- package/src/Command.mjs +10 -10
- package/src/CompositeOperations.mjs +11 -11
- package/src/Controller.mjs +82 -82
- package/src/Core2D.mjs +269 -269
- package/src/Direction.mjs +22 -22
- package/src/Engine.mjs +448 -448
- package/src/FontFamily.mjs +5 -5
- package/src/Frame.mjs +37 -37
- package/src/GamePad.mjs +43 -43
- package/src/Input.mjs +114 -114
- package/src/Key.mjs +18 -18
- package/src/KeyMap.mjs +18 -18
- package/src/Keyboard.mjs +28 -28
- package/src/Mouse.mjs +35 -35
- package/src/Point.mjs +61 -61
- package/src/Pointer.mjs +48 -48
- package/src/Rect.mjs +239 -239
- package/src/RenderableList.mjs +12 -12
- package/src/Scene.mjs +137 -137
- package/src/Sound.mjs +134 -134
- package/src/Sprite.mjs +686 -680
- package/src/Static.mjs +54 -54
- package/src/TextSprite.mjs +228 -228
- package/src/Touch.mjs +41 -41
- package/src/Transition.mjs +12 -12
- package/src/plugin/BaseTile.mjs +4 -4
- package/src/plugin/ClickableSprite.mjs +14 -14
- package/src/plugin/ControllableSprite.mjs +36 -36
- package/src/plugin/CursorSprite.mjs +32 -32
- package/src/plugin/Fog.mjs +23 -23
- package/src/plugin/FontSprite.mjs +59 -59
- package/src/plugin/JumperSprite.mjs +132 -132
- package/src/plugin/RandomRectTransition.mjs +22 -22
- package/src/plugin/Starfield.mjs +47 -47
package/src/Rect.mjs
CHANGED
|
@@ -7,243 +7,243 @@ import { Point } from "./Point.mjs";
|
|
|
7
7
|
* @extends Point
|
|
8
8
|
*/
|
|
9
9
|
export class Rect extends Point {
|
|
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
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Creates a new Rect.
|
|
12
|
+
* @param {number} x The x-coordinate of the rectangle.
|
|
13
|
+
* @param {number} y The y-coordinate of the rectangle.
|
|
14
|
+
* @param {number} [width=0] The width of the rectangle.
|
|
15
|
+
* @param {number} [height=0] The height of the rectangle.
|
|
16
|
+
*/
|
|
17
|
+
constructor(x, y, width = 0, height = 0) {
|
|
18
|
+
super(x, y);
|
|
19
|
+
this.width = width;
|
|
20
|
+
this.height = height;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The x-coordinate of the left edge of the rectangle.
|
|
25
|
+
* @type {number}
|
|
26
|
+
*/
|
|
27
|
+
get left() {
|
|
28
|
+
return this.x;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* The x-coordinate of the right edge of the rectangle.
|
|
33
|
+
* @type {number}
|
|
34
|
+
*/
|
|
35
|
+
get right() {
|
|
36
|
+
return this.x + this.width - 1;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* The y-coordinate of the top edge of the rectangle.
|
|
41
|
+
* @type {number}
|
|
42
|
+
*/
|
|
43
|
+
get top() {
|
|
44
|
+
return this.y;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* The y-coordinate of the bottom edge of the rectangle.
|
|
49
|
+
* @type {number}
|
|
50
|
+
*/
|
|
51
|
+
get bottom() {
|
|
52
|
+
return this.y + this.height - 1;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* The x-coordinate of the center of the rectangle.
|
|
57
|
+
* @type {number}
|
|
58
|
+
*/
|
|
59
|
+
get centerX() {
|
|
60
|
+
return this.x + Math.floor(this.width / 2);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* The y-coordinate of the center of the rectangle.
|
|
65
|
+
* @type {number}
|
|
66
|
+
*/
|
|
67
|
+
get centerY() {
|
|
68
|
+
return this.y + Math.floor(this.height / 2);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* The center of the rectangle.
|
|
73
|
+
* @type {Point}
|
|
74
|
+
*/
|
|
75
|
+
get center() {
|
|
76
|
+
return new Point(this.centerX, this.centerY);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Sets the width of the rectangle.
|
|
81
|
+
* @param {number} width The new width.
|
|
82
|
+
* @returns {Rect} This rectangle.
|
|
83
|
+
*/
|
|
84
|
+
setWidth(width) {
|
|
85
|
+
this.width = width;
|
|
86
|
+
return this;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Sets the height of the rectangle.
|
|
91
|
+
* @param {number} height The new height.
|
|
92
|
+
* @returns {Rect} This rectangle.
|
|
93
|
+
*/
|
|
94
|
+
setHeight(height) {
|
|
95
|
+
this.height = height;
|
|
96
|
+
return this;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Sets the size of the rectangle.
|
|
101
|
+
* @param {Rect} rect The new size.
|
|
102
|
+
* @returns {Rect} This rectangle.
|
|
103
|
+
*/
|
|
104
|
+
setSize(rect) {
|
|
105
|
+
this.setWidth(rect.width);
|
|
106
|
+
this.setHeight(rect.height);
|
|
107
|
+
return this;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Sets the x-coordinate of the left edge of the rectangle.
|
|
112
|
+
* @param {number} x The new x-coordinate.
|
|
113
|
+
* @returns {Rect} This rectangle.
|
|
114
|
+
*/
|
|
115
|
+
setLeft(x) {
|
|
116
|
+
this.x = x;
|
|
117
|
+
return this;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Sets the x-coordinate of the right edge of the rectangle.
|
|
122
|
+
* @param {number} x The new x-coordinate.
|
|
123
|
+
* @returns {Rect} This rectangle.
|
|
124
|
+
*/
|
|
125
|
+
setRight(x) {
|
|
126
|
+
this.x = x - this.width + 1;
|
|
127
|
+
return this;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Sets the y-coordinate of the top edge of the rectangle.
|
|
132
|
+
* @param {number} y The new y-coordinate.
|
|
133
|
+
* @returns {Rect} This rectangle.
|
|
134
|
+
*/
|
|
135
|
+
setTop(y) {
|
|
136
|
+
this.y = y;
|
|
137
|
+
return this;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Sets the y-coordinate of the bottom edge of the rectangle.
|
|
142
|
+
* @param {number} y The new y-coordinate.
|
|
143
|
+
* @returns {Rect} This rectangle.
|
|
144
|
+
*/
|
|
145
|
+
setBottom(y) {
|
|
146
|
+
this.y = y - this.height + 1;
|
|
147
|
+
return this;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Sets the x-coordinate of the center of the rectangle.
|
|
152
|
+
* @param {number} x The new x-coordinate.
|
|
153
|
+
* @returns {Rect} This rectangle.
|
|
154
|
+
*/
|
|
155
|
+
setCenterX(x) {
|
|
156
|
+
this.x = x - Math.floor(this.width / 2);
|
|
157
|
+
return this;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Sets the y-coordinate of the center of the rectangle.
|
|
162
|
+
* @param {number} y The new y-coordinate.
|
|
163
|
+
* @returns {Rect} This rectangle.
|
|
164
|
+
*/
|
|
165
|
+
setCenterY(y) {
|
|
166
|
+
this.y = y - Math.floor(this.height / 2);
|
|
167
|
+
return this;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Sets the center of the rectangle.
|
|
172
|
+
* @param {Point} point The new center.
|
|
173
|
+
* @returns {Rect} This rectangle.
|
|
174
|
+
*/
|
|
175
|
+
setCenter(point) {
|
|
176
|
+
this.setCenterX(point.x);
|
|
177
|
+
this.setCenterY(point.y);
|
|
178
|
+
return this;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* The x-coordinate of the left edge of the rectangle.
|
|
183
|
+
* @type {number}
|
|
184
|
+
*/
|
|
185
|
+
set left(x) {
|
|
186
|
+
this.setLeft(x);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* The x-coordinate of the right edge of the rectangle.
|
|
191
|
+
* @type {number}
|
|
192
|
+
*/
|
|
193
|
+
set right(x) {
|
|
194
|
+
this.setRight(x);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* The y-coordinate of the top edge of the rectangle.
|
|
199
|
+
* @type {number}
|
|
200
|
+
*/
|
|
201
|
+
set top(y) {
|
|
202
|
+
this.setTop(y);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* The y-coordinate of the bottom edge of the rectangle.
|
|
207
|
+
* @type {number}
|
|
208
|
+
*/
|
|
209
|
+
set bottom(y) {
|
|
210
|
+
this.setBottom(y);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* The x-coordinate of the center of the rectangle.
|
|
215
|
+
* @type {number}
|
|
216
|
+
*/
|
|
217
|
+
set centerX(x) {
|
|
218
|
+
this.setCenterX(x);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* The y-coordinate of the center of the rectangle.
|
|
223
|
+
* @type {number}
|
|
224
|
+
*/
|
|
225
|
+
set centerY(y) {
|
|
226
|
+
this.setCenterY(y);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* The center of the rectangle.
|
|
231
|
+
* @type {Point}
|
|
232
|
+
*/
|
|
233
|
+
set center(point) {
|
|
234
|
+
this.setCenter(point);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Creates a new rectangle that is the union of this rectangle and another rectangle.
|
|
239
|
+
* @param {Rect} rect The other rectangle.
|
|
240
|
+
* @returns {Rect} The new rectangle.
|
|
241
|
+
*/
|
|
242
|
+
makeUnion(rect) {
|
|
243
|
+
const RECT = new Rect(Math.min(this.x, rect.x), Math.min(this.y, rect.y));
|
|
244
|
+
|
|
245
|
+
return RECT.setWidth(
|
|
246
|
+
Math.max(this.right, rect.right) - RECT.x + 1
|
|
247
|
+
).setHeight(Math.max(this.bottom, rect.bottom) - RECT.y + 1);
|
|
248
|
+
}
|
|
249
249
|
}
|
package/src/RenderableList.mjs
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
export class RenderableList {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
constructor() {
|
|
5
|
+
this._elements = [];
|
|
6
|
+
}
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
add(renderable) {
|
|
9
|
+
this._elements.push(renderable);
|
|
10
|
+
}
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
render(context) {
|
|
13
|
+
for (let i = 0; i < this._elements.length; ++i) {
|
|
14
|
+
this._elements[i].render(context);
|
|
15
|
+
}
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
this._elements.length = 0;
|
|
18
|
+
}
|
|
19
19
|
}
|