core2d 2.11.1 → 2.11.2
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/Color.mjs
CHANGED
|
@@ -3,152 +3,152 @@
|
|
|
3
3
|
import { Static } from "./Static.mjs";
|
|
4
4
|
|
|
5
5
|
export const Color = Static.makeHash([
|
|
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
|
-
|
|
6
|
+
"AliceBlue",
|
|
7
|
+
"AntiqueWhite",
|
|
8
|
+
"Aqua",
|
|
9
|
+
"Aquamarine",
|
|
10
|
+
"Azure",
|
|
11
|
+
"Beige",
|
|
12
|
+
"Bisque",
|
|
13
|
+
"Black",
|
|
14
|
+
"BlanchedAlmond",
|
|
15
|
+
"Blue",
|
|
16
|
+
"BlueViolet",
|
|
17
|
+
"Brown",
|
|
18
|
+
"BurlyWood",
|
|
19
|
+
"CadetBlue",
|
|
20
|
+
"Chartreuse",
|
|
21
|
+
"Chocolate",
|
|
22
|
+
"Coral",
|
|
23
|
+
"CornflowerBlue",
|
|
24
|
+
"Cornsilk",
|
|
25
|
+
"Crimson",
|
|
26
|
+
"Cyan",
|
|
27
|
+
"DarkBlue",
|
|
28
|
+
"DarkCyan",
|
|
29
|
+
"DarkGoldenRod",
|
|
30
|
+
"DarkGray",
|
|
31
|
+
"DarkGreen",
|
|
32
|
+
"DarkGrey",
|
|
33
|
+
"DarkKhaki",
|
|
34
|
+
"DarkMagenta",
|
|
35
|
+
"DarkOliveGreen",
|
|
36
|
+
"Darkorange",
|
|
37
|
+
"DarkOrchid",
|
|
38
|
+
"DarkRed",
|
|
39
|
+
"DarkSalmon",
|
|
40
|
+
"DarkSeaGreen",
|
|
41
|
+
"DarkSlateBlue",
|
|
42
|
+
"DarkSlateGray",
|
|
43
|
+
"DarkSlateGrey",
|
|
44
|
+
"DarkTurquoise",
|
|
45
|
+
"DarkViolet",
|
|
46
|
+
"DeepPink",
|
|
47
|
+
"DeepSkyBlue",
|
|
48
|
+
"DimGray",
|
|
49
|
+
"DimGrey",
|
|
50
|
+
"DodgerBlue",
|
|
51
|
+
"FireBrick",
|
|
52
|
+
"FloralWhite",
|
|
53
|
+
"ForestGreen",
|
|
54
|
+
"Fuchsia",
|
|
55
|
+
"Gainsboro",
|
|
56
|
+
"GhostWhite",
|
|
57
|
+
"Gold",
|
|
58
|
+
"GoldenRod",
|
|
59
|
+
"Gray",
|
|
60
|
+
"Green",
|
|
61
|
+
"GreenYellow",
|
|
62
|
+
"Grey",
|
|
63
|
+
"HoneyDew",
|
|
64
|
+
"HotPink",
|
|
65
|
+
"IndianRed",
|
|
66
|
+
"Indigo",
|
|
67
|
+
"Ivory",
|
|
68
|
+
"Khaki",
|
|
69
|
+
"Lavender",
|
|
70
|
+
"LavenderBlush",
|
|
71
|
+
"LawnGreen",
|
|
72
|
+
"LemonChiffon",
|
|
73
|
+
"LightBlue",
|
|
74
|
+
"LightCoral",
|
|
75
|
+
"LightCyan",
|
|
76
|
+
"LightGoldenRodYellow",
|
|
77
|
+
"LightGray",
|
|
78
|
+
"LightGreen",
|
|
79
|
+
"LightGrey",
|
|
80
|
+
"LightPink",
|
|
81
|
+
"LightSalmon",
|
|
82
|
+
"LightSeaGreen",
|
|
83
|
+
"LightSkyBlue",
|
|
84
|
+
"LightSlateGray",
|
|
85
|
+
"LightSlateGrey",
|
|
86
|
+
"LightSteelBlue",
|
|
87
|
+
"LightYellow",
|
|
88
|
+
"Lime",
|
|
89
|
+
"LimeGreen",
|
|
90
|
+
"Linen",
|
|
91
|
+
"Magenta",
|
|
92
|
+
"Maroon",
|
|
93
|
+
"MediumAquaMarine",
|
|
94
|
+
"MediumBlue",
|
|
95
|
+
"MediumOrchid",
|
|
96
|
+
"MediumPurple",
|
|
97
|
+
"MediumSeaGreen",
|
|
98
|
+
"MediumSlateBlue",
|
|
99
|
+
"MediumSpringGreen",
|
|
100
|
+
"MediumTurquoise",
|
|
101
|
+
"MediumVioletRed",
|
|
102
|
+
"MidnightBlue",
|
|
103
|
+
"MintCream",
|
|
104
|
+
"MistyRose",
|
|
105
|
+
"Moccasin",
|
|
106
|
+
"NavajoWhite",
|
|
107
|
+
"Navy",
|
|
108
|
+
"OldLace",
|
|
109
|
+
"Olive",
|
|
110
|
+
"OliveDrab",
|
|
111
|
+
"Orange",
|
|
112
|
+
"OrangeRed",
|
|
113
|
+
"Orchid",
|
|
114
|
+
"PaleGoldenRod",
|
|
115
|
+
"PaleGreen",
|
|
116
|
+
"PaleTurquoise",
|
|
117
|
+
"PaleVioletRed",
|
|
118
|
+
"PapayaWhip",
|
|
119
|
+
"PeachPuff",
|
|
120
|
+
"Peru",
|
|
121
|
+
"Pink",
|
|
122
|
+
"Plum",
|
|
123
|
+
"PowderBlue",
|
|
124
|
+
"Purple",
|
|
125
|
+
"RebeccaPurple",
|
|
126
|
+
"Red",
|
|
127
|
+
"RosyBrown",
|
|
128
|
+
"RoyalBlue",
|
|
129
|
+
"SaddleBrown",
|
|
130
|
+
"Salmon",
|
|
131
|
+
"SandyBrown",
|
|
132
|
+
"SeaGreen",
|
|
133
|
+
"SeaShell",
|
|
134
|
+
"Sienna",
|
|
135
|
+
"Silver",
|
|
136
|
+
"SkyBlue",
|
|
137
|
+
"SlateBlue",
|
|
138
|
+
"SlateGray",
|
|
139
|
+
"SlateGrey",
|
|
140
|
+
"Snow",
|
|
141
|
+
"SpringGreen",
|
|
142
|
+
"SteelBlue",
|
|
143
|
+
"Tan",
|
|
144
|
+
"Teal",
|
|
145
|
+
"Thistle",
|
|
146
|
+
"Tomato",
|
|
147
|
+
"Turquoise",
|
|
148
|
+
"Violet",
|
|
149
|
+
"Wheat",
|
|
150
|
+
"White",
|
|
151
|
+
"WhiteSmoke",
|
|
152
|
+
"Yellow",
|
|
153
|
+
"YellowGreen",
|
|
154
154
|
]);
|
package/src/Command.mjs
CHANGED
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
import { Static } from "./Static.mjs";
|
|
4
4
|
|
|
5
5
|
export const Command = Static.makeEnum([
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
6
|
+
"UP",
|
|
7
|
+
"DOWN",
|
|
8
|
+
"LEFT",
|
|
9
|
+
"RIGHT",
|
|
10
|
+
"A",
|
|
11
|
+
"B",
|
|
12
|
+
"X",
|
|
13
|
+
"Y",
|
|
14
|
+
"SELECT",
|
|
15
|
+
"START",
|
|
16
16
|
]);
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
export const CompositeOperations = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
4
|
+
COPY: "copy",
|
|
5
|
+
DESTINATION_ATOP: "destination-atop",
|
|
6
|
+
DESTINATION_IN: "destination-in",
|
|
7
|
+
DESTINATION_OUT: "destination-out",
|
|
8
|
+
DESTINATION_OVER: "destination-over",
|
|
9
|
+
LIGHTER: "lighter",
|
|
10
|
+
SOURCE_ATOP: "source-atop",
|
|
11
|
+
SOURCE_IN: "source-in",
|
|
12
|
+
SOURCE_OUT: "source-out",
|
|
13
|
+
SOURCE_OVER: "source-over",
|
|
14
|
+
XOR: "xor",
|
|
15
15
|
};
|
package/src/Controller.mjs
CHANGED
|
@@ -6,97 +6,97 @@ import { Command } from "./Command.mjs";
|
|
|
6
6
|
* Represents a controller, which can be a gamepad or a keyboard.
|
|
7
7
|
*/
|
|
8
8
|
export class Controller {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Creates a new Controller.
|
|
11
|
+
*/
|
|
12
|
+
constructor() {
|
|
13
|
+
/**
|
|
14
|
+
* The tolerance for the command sequence.
|
|
15
|
+
* @type {number}
|
|
16
|
+
*/
|
|
17
|
+
this.tolerance = 0;
|
|
18
|
+
this._active = {};
|
|
19
|
+
this._device = null;
|
|
20
|
+
this._hold = {};
|
|
21
|
+
this._sequence = [];
|
|
22
|
+
this._tick = 0;
|
|
23
|
+
}
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Checks if a sequence of commands was performed.
|
|
27
|
+
* @param {Command[]} commands The sequence of commands.
|
|
28
|
+
* @returns {boolean} Whether the sequence of commands was performed.
|
|
29
|
+
*/
|
|
30
|
+
didPerform(commands) {
|
|
31
|
+
for (let i = 1; i <= commands.length; ++i) {
|
|
32
|
+
if (
|
|
33
|
+
this._sequence[this._sequence.length - i] !=
|
|
34
|
+
commands[commands.length - i]
|
|
35
|
+
) {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
this._sequence = [];
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
44
|
+
/**
|
|
45
|
+
* Checks if a command is being held down.
|
|
46
|
+
* @param {Command} command The command to check.
|
|
47
|
+
* @returns {boolean} Whether the command is being held down.
|
|
48
|
+
*/
|
|
49
|
+
keyDown(command) {
|
|
50
|
+
return this._active[command];
|
|
51
|
+
}
|
|
52
52
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
53
|
+
/**
|
|
54
|
+
* Checks if a command was just pushed.
|
|
55
|
+
* @param {Command} command The command to check.
|
|
56
|
+
* @returns {boolean} Whether the command was just pushed.
|
|
57
|
+
*/
|
|
58
|
+
keyPush(command) {
|
|
59
|
+
return this._active[command] && !this._hold[command];
|
|
60
|
+
}
|
|
61
61
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
62
|
+
/**
|
|
63
|
+
* Sets the device of the controller.
|
|
64
|
+
* @param {object} device The device.
|
|
65
|
+
*/
|
|
66
|
+
setDevice(device) {
|
|
67
|
+
this._device = device;
|
|
68
|
+
}
|
|
69
69
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
70
|
+
/**
|
|
71
|
+
* Updates the controller.
|
|
72
|
+
*/
|
|
73
|
+
update() {
|
|
74
|
+
if (!this._device) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
77
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
78
|
+
this._hold = {};
|
|
79
|
+
const LAST = this._active;
|
|
80
|
+
this._active = this._device.commands;
|
|
81
81
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
82
|
+
for (let i in this._active) {
|
|
83
|
+
if (LAST[i]) {
|
|
84
|
+
this._hold[i] = true;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
87
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
88
|
+
if (this.tolerance && ++this._tick > this.tolerance) {
|
|
89
|
+
this._sequence = [];
|
|
90
|
+
this._tick = 0;
|
|
91
|
+
}
|
|
92
92
|
|
|
93
|
-
|
|
94
|
-
|
|
93
|
+
for (let i in Command) {
|
|
94
|
+
const COMMAND = Command[i];
|
|
95
95
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
96
|
+
if (this.keyPush(COMMAND)) {
|
|
97
|
+
this._sequence.push(COMMAND);
|
|
98
|
+
this._tick = 0;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
102
|
}
|