react-simple-game-engine 0.2.27 → 0.2.29

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.
Files changed (22) hide show
  1. package/lib/ui-components/control.d.ts +1 -1
  2. package/lib/ui-components/control.d.ts.map +1 -1
  3. package/lib/ui-components/control.js +1 -1
  4. package/lib/ui-components/react-joystick-component/Joystick.d.ts +112 -0
  5. package/lib/ui-components/react-joystick-component/Joystick.js +320 -0
  6. package/lib/ui-components/react-joystick-component/Joystick.js.map +1 -0
  7. package/lib/ui-components/react-joystick-component/Joystick.stories.d.ts +1 -0
  8. package/lib/ui-components/react-joystick-component/Joystick.stories.js +123 -0
  9. package/lib/ui-components/react-joystick-component/Joystick.stories.js.map +1 -0
  10. package/lib/ui-components/react-joystick-component/enums/shape.enum.d.ts +4 -0
  11. package/lib/ui-components/react-joystick-component/enums/shape.enum.js +9 -0
  12. package/lib/ui-components/react-joystick-component/enums/shape.enum.js.map +1 -0
  13. package/lib/ui-components/react-joystick-component/index.d.ts +2 -0
  14. package/lib/ui-components/react-joystick-component/index.js +8 -0
  15. package/lib/ui-components/react-joystick-component/index.js.map +1 -0
  16. package/lib/ui-components/react-joystick-component/shapes/shape.bounds.factory.d.ts +5 -0
  17. package/lib/ui-components/react-joystick-component/shapes/shape.bounds.factory.js +30 -0
  18. package/lib/ui-components/react-joystick-component/shapes/shape.bounds.factory.js.map +1 -0
  19. package/lib/ui-components/react-joystick-component/shapes/shape.factory.d.ts +4 -0
  20. package/lib/ui-components/react-joystick-component/shapes/shape.factory.js +18 -0
  21. package/lib/ui-components/react-joystick-component/shapes/shape.factory.js.map +1 -0
  22. package/package.json +3 -4
@@ -1,6 +1,6 @@
1
1
  import { ReactElement, ReactNode } from "react";
2
- import { IJoystickProps } from "react-joystick-component/build/lib/Joystick";
3
2
  import { Scene } from "../classes/scene";
3
+ import { IJoystickProps } from "./react-joystick-component/Joystick";
4
4
  export declare type ControlProps = {
5
5
  scene: Scene;
6
6
  top?: number;
@@ -1 +1 @@
1
- {"version":3,"file":"control.d.ts","sourceRoot":"","sources":["../../src/ui-components/control.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,SAAS,EAAW,MAAM,OAAO,CAAC;AAEzD,OAAO,EAAE,cAAc,EAAE,MAAM,6CAA6C,CAAC;AAC7E,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAIzC,oBAAY,YAAY,GAAG;IACzB,KAAK,EAAE,KAAK,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,CAAC,EAAE,EAAE,YAAY,KAAK,SAAS,CAAC;IACzC,KAAK,EAAE,cAAc,CAAC;CACvB,CAAC;AAEF,wBAAgB,OAAO,CAAC,EACtB,KAAK,EACL,MAAM,EACN,GAAG,EACH,IAAS,EACT,KAAK,EACL,MAAW,EACX,KAAK,GACN,EAAE,YAAY,eA4Bd"}
1
+ {"version":3,"file":"control.d.ts","sourceRoot":"","sources":["../../src/ui-components/control.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,SAAS,EAAW,MAAM,OAAO,CAAC;AACzD,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAIzC,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAErE,oBAAY,YAAY,GAAG;IACzB,KAAK,EAAE,KAAK,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,CAAC,EAAE,EAAE,YAAY,KAAK,SAAS,CAAC;IACzC,KAAK,EAAE,cAAc,CAAC;CACvB,CAAC;AAEF,wBAAgB,OAAO,CAAC,EACtB,KAAK,EACL,MAAM,EACN,GAAG,EACH,IAAS,EACT,KAAK,EACL,MAAW,EACX,KAAK,GACN,EAAE,YAAY,eA4Bd"}
@@ -11,9 +11,9 @@ var __assign = (this && this.__assign) || function () {
11
11
  };
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
13
  import { useMemo } from "react";
14
- import { Joystick } from "react-joystick-component";
15
14
  import { Watcher } from "../utilities";
16
15
  import { FloatContainer } from "./float-container";
16
+ import { Joystick } from "./react-joystick-component";
17
17
  export function Control(_a) {
18
18
  var scene = _a.scene, render = _a.render, top = _a.top, _b = _a.left, left = _b === void 0 ? 50 : _b, right = _a.right, _c = _a.bottom, bottom = _c === void 0 ? 50 : _c, props = _a.props;
19
19
  var el = useMemo(function () {
@@ -0,0 +1,112 @@
1
+ import * as React from 'react';
2
+ import { JoystickShape } from "./enums/shape.enum";
3
+ export interface IJoystickProps {
4
+ size?: number;
5
+ baseColor?: string;
6
+ stickColor?: string;
7
+ throttle?: number;
8
+ disabled?: boolean;
9
+ sticky?: boolean;
10
+ move?: (event: IJoystickUpdateEvent) => void;
11
+ stop?: (event: IJoystickUpdateEvent) => void;
12
+ start?: (event: IJoystickUpdateEvent) => void;
13
+ stickImage?: string;
14
+ baseImage?: string;
15
+ followCursor?: boolean;
16
+ baseShape?: JoystickShape;
17
+ stickShape?: JoystickShape;
18
+ controlPlaneShape?: JoystickShape;
19
+ minDistance?: number;
20
+ }
21
+ export interface IJoystickUpdateEvent {
22
+ type: "move" | "stop" | "start";
23
+ x: number | null;
24
+ y: number | null;
25
+ direction: JoystickDirection | null;
26
+ distance: number | null;
27
+ }
28
+ export interface IJoystickState {
29
+ dragging: boolean;
30
+ coordinates?: IJoystickCoordinates;
31
+ }
32
+ declare type JoystickDirection = "FORWARD" | "RIGHT" | "LEFT" | "BACKWARD";
33
+ export interface IJoystickCoordinates {
34
+ relativeX: number;
35
+ relativeY: number;
36
+ axisX: number;
37
+ axisY: number;
38
+ direction: JoystickDirection;
39
+ distance: number;
40
+ }
41
+ declare class Joystick extends React.Component<IJoystickProps, IJoystickState> {
42
+ private readonly _stickRef;
43
+ private readonly _baseRef;
44
+ private readonly _throttleMoveCallback;
45
+ private _baseSize;
46
+ private _radius;
47
+ private _parentRect;
48
+ private _pointerId;
49
+ constructor(props: IJoystickProps);
50
+ componentWillUnmount(): void;
51
+ componentDidMount(): void;
52
+ /**
53
+ * Update position of joystick - set state and trigger DOM manipulation
54
+ * @param coordinates
55
+ * @private
56
+ */
57
+ private _updatePos;
58
+ /**
59
+ * Handle pointerdown event
60
+ * @param e PointerEvent
61
+ * @private
62
+ */
63
+ private _pointerDown;
64
+ /**
65
+ * Use ArcTan2 (4 Quadrant inverse tangent) to identify the direction the joystick is pointing
66
+ * https://docs.oracle.com/cd/B12037_01/olap.101/b10339/x_arcsin003.htm
67
+ * @param atan2: number
68
+ * @private
69
+ */
70
+ private _getDirection;
71
+ /**
72
+ * Hypotenuse distance calculation
73
+ * @param x: number
74
+ * @param y: number
75
+ * @private
76
+ */
77
+ private _distance;
78
+ private _distanceToPercentile;
79
+ /**
80
+ * Calculate X/Y and ArcTan within the bounds of the joystick
81
+ * @param event
82
+ * @private
83
+ */
84
+ private _pointerMove;
85
+ /**
86
+ * Handle pointer up and de-register listen events
87
+ * @private
88
+ */
89
+ private _pointerUp;
90
+ /**
91
+ * Get the shape stylings for the base
92
+ * @private
93
+ */
94
+ private getBaseShapeStyle;
95
+ /**
96
+ * Get the shape stylings for the stick
97
+ * @private
98
+ */
99
+ private getStickShapeStyle;
100
+ /**
101
+ * Calculate base styles for pad
102
+ * @private
103
+ */
104
+ private _getBaseStyle;
105
+ /**
106
+ * Calculate base styles for joystick and translate
107
+ * @private
108
+ */
109
+ private _getStickStyle;
110
+ render(): JSX.Element;
111
+ }
112
+ export { Joystick };
@@ -0,0 +1,320 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ var __assign = (this && this.__assign) || function () {
18
+ __assign = Object.assign || function(t) {
19
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
20
+ s = arguments[i];
21
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
22
+ t[p] = s[p];
23
+ }
24
+ return t;
25
+ };
26
+ return __assign.apply(this, arguments);
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.Joystick = void 0;
30
+ var React = require("react");
31
+ var shape_enum_1 = require("./enums/shape.enum");
32
+ var shape_factory_1 = require("./shapes/shape.factory");
33
+ var shape_bounds_factory_1 = require("./shapes/shape.bounds.factory");
34
+ var InteractionEvents;
35
+ (function (InteractionEvents) {
36
+ InteractionEvents["PointerDown"] = "pointerdown";
37
+ InteractionEvents["PointerMove"] = "pointermove";
38
+ InteractionEvents["PointerUp"] = "pointerup";
39
+ })(InteractionEvents || (InteractionEvents = {}));
40
+ /**
41
+ * Radians identifying the direction of the joystick
42
+ */
43
+ var RadianQuadrantBinding;
44
+ (function (RadianQuadrantBinding) {
45
+ RadianQuadrantBinding[RadianQuadrantBinding["TopRight"] = 2.35619449] = "TopRight";
46
+ RadianQuadrantBinding[RadianQuadrantBinding["TopLeft"] = -2.35619449] = "TopLeft";
47
+ RadianQuadrantBinding[RadianQuadrantBinding["BottomRight"] = 0.785398163] = "BottomRight";
48
+ RadianQuadrantBinding[RadianQuadrantBinding["BottomLeft"] = -0.785398163] = "BottomLeft";
49
+ })(RadianQuadrantBinding || (RadianQuadrantBinding = {}));
50
+ var Joystick = /** @class */ (function (_super) {
51
+ __extends(Joystick, _super);
52
+ function Joystick(props) {
53
+ var _this = _super.call(this, props) || this;
54
+ _this._stickRef = React.createRef();
55
+ _this._baseRef = React.createRef();
56
+ _this._pointerId = null;
57
+ _this.state = {
58
+ dragging: false
59
+ };
60
+ _this._throttleMoveCallback = (function () {
61
+ var lastCall = 0;
62
+ return function (event) {
63
+ var now = new Date().getTime();
64
+ var throttleAmount = _this.props.throttle || 0;
65
+ if (now - lastCall < throttleAmount) {
66
+ return;
67
+ }
68
+ lastCall = now;
69
+ if (_this.props.move) {
70
+ return _this.props.move(event);
71
+ }
72
+ };
73
+ })();
74
+ return _this;
75
+ }
76
+ Joystick.prototype.componentWillUnmount = function () {
77
+ var _this = this;
78
+ if (this.props.followCursor) {
79
+ window.removeEventListener(InteractionEvents.PointerMove, function (event) { return _this._pointerMove(event); });
80
+ }
81
+ };
82
+ Joystick.prototype.componentDidMount = function () {
83
+ var _this = this;
84
+ if (this.props.followCursor) {
85
+ //@ts-ignore
86
+ this._parentRect = this._baseRef.current.getBoundingClientRect();
87
+ this.setState({
88
+ dragging: true
89
+ });
90
+ window.addEventListener(InteractionEvents.PointerMove, function (event) { return _this._pointerMove(event); });
91
+ if (this.props.start) {
92
+ this.props.start({
93
+ type: "start",
94
+ x: null,
95
+ y: null,
96
+ distance: null,
97
+ direction: null
98
+ });
99
+ }
100
+ }
101
+ };
102
+ /**
103
+ * Update position of joystick - set state and trigger DOM manipulation
104
+ * @param coordinates
105
+ * @private
106
+ */
107
+ Joystick.prototype._updatePos = function (coordinates) {
108
+ var _this = this;
109
+ window.requestAnimationFrame(function () {
110
+ _this.setState({
111
+ coordinates: coordinates
112
+ });
113
+ });
114
+ if (typeof this.props.minDistance === 'number') {
115
+ if (coordinates.distance < this.props.minDistance) {
116
+ return;
117
+ }
118
+ }
119
+ this._throttleMoveCallback({
120
+ type: "move",
121
+ x: coordinates.relativeX,
122
+ y: -coordinates.relativeY,
123
+ direction: coordinates.direction,
124
+ distance: coordinates.distance
125
+ });
126
+ };
127
+ /**
128
+ * Handle pointerdown event
129
+ * @param e PointerEvent
130
+ * @private
131
+ */
132
+ Joystick.prototype._pointerDown = function (e) {
133
+ var _this = this;
134
+ if (this.props.disabled || this.props.followCursor) {
135
+ return;
136
+ }
137
+ //@ts-ignore
138
+ this._parentRect = this._baseRef.current.getBoundingClientRect();
139
+ this.setState({
140
+ dragging: true
141
+ });
142
+ window.addEventListener(InteractionEvents.PointerUp, function (event) { return _this._pointerUp(event); });
143
+ window.addEventListener(InteractionEvents.PointerMove, function (event) { return _this._pointerMove(event); });
144
+ this._pointerId = e.pointerId;
145
+ //@ts-ignore
146
+ this._stickRef.current.setPointerCapture(e.pointerId);
147
+ if (this.props.start) {
148
+ this.props.start({
149
+ type: "start",
150
+ x: null,
151
+ y: null,
152
+ distance: null,
153
+ direction: null
154
+ });
155
+ }
156
+ };
157
+ /**
158
+ * Use ArcTan2 (4 Quadrant inverse tangent) to identify the direction the joystick is pointing
159
+ * https://docs.oracle.com/cd/B12037_01/olap.101/b10339/x_arcsin003.htm
160
+ * @param atan2: number
161
+ * @private
162
+ */
163
+ Joystick.prototype._getDirection = function (atan2) {
164
+ if (atan2 > RadianQuadrantBinding.TopRight || atan2 < RadianQuadrantBinding.TopLeft) {
165
+ return "FORWARD";
166
+ }
167
+ else if (atan2 < RadianQuadrantBinding.TopRight && atan2 > RadianQuadrantBinding.BottomRight) {
168
+ return "RIGHT";
169
+ }
170
+ else if (atan2 < RadianQuadrantBinding.BottomLeft) {
171
+ return "LEFT";
172
+ }
173
+ return "BACKWARD";
174
+ };
175
+ /**
176
+ * Hypotenuse distance calculation
177
+ * @param x: number
178
+ * @param y: number
179
+ * @private
180
+ */
181
+ Joystick.prototype._distance = function (x, y) {
182
+ return Math.hypot(x, y);
183
+ };
184
+ Joystick.prototype._distanceToPercentile = function (distance) {
185
+ var percentageBaseSize = distance / (this._baseSize / 2) * 100;
186
+ if (percentageBaseSize > 100) {
187
+ return 100;
188
+ }
189
+ return percentageBaseSize;
190
+ };
191
+ /**
192
+ * Calculate X/Y and ArcTan within the bounds of the joystick
193
+ * @param event
194
+ * @private
195
+ */
196
+ Joystick.prototype._pointerMove = function (event) {
197
+ event.preventDefault();
198
+ if (this.state.dragging) {
199
+ if (!this.props.followCursor && event.pointerId !== this._pointerId)
200
+ return;
201
+ var absoluteX = event.clientX;
202
+ var absoluteY = event.clientY;
203
+ var relativeX = absoluteX - this._parentRect.left - this._radius;
204
+ var relativeY = absoluteY - this._parentRect.top - this._radius;
205
+ var dist = this._distance(relativeX, relativeY);
206
+ // @ts-ignore
207
+ var bounded = (0, shape_bounds_factory_1.shapeBoundsFactory)(
208
+ //@ts-ignore
209
+ this.props.controlPlaneShape || this.props.baseShape, absoluteX, absoluteY, relativeX, relativeY, dist, this._radius, this._baseSize, this._parentRect);
210
+ relativeX = bounded.relativeX;
211
+ relativeY = bounded.relativeY;
212
+ var atan2 = Math.atan2(relativeX, relativeY);
213
+ this._updatePos({
214
+ relativeX: relativeX,
215
+ relativeY: relativeY,
216
+ distance: this._distanceToPercentile(dist),
217
+ direction: this._getDirection(atan2),
218
+ axisX: absoluteX - this._parentRect.left,
219
+ axisY: absoluteY - this._parentRect.top
220
+ });
221
+ }
222
+ };
223
+ /**
224
+ * Handle pointer up and de-register listen events
225
+ * @private
226
+ */
227
+ Joystick.prototype._pointerUp = function (event) {
228
+ var _this = this;
229
+ if (event.pointerId !== this._pointerId)
230
+ return;
231
+ var stateUpdate = {
232
+ dragging: false,
233
+ };
234
+ if (!this.props.sticky) {
235
+ stateUpdate.coordinates = undefined;
236
+ }
237
+ window.requestAnimationFrame(function () {
238
+ _this.setState(stateUpdate);
239
+ });
240
+ window.removeEventListener(InteractionEvents.PointerUp, function (event) { return _this._pointerUp(event); });
241
+ window.removeEventListener(InteractionEvents.PointerMove, function (event) { return _this._pointerMove(event); });
242
+ this._pointerId = null;
243
+ if (this.props.stop) {
244
+ this.props.stop({
245
+ type: "stop",
246
+ // @ts-ignore
247
+ x: this.props.sticky ? this.state.coordinates.relativeX : null,
248
+ // @ts-ignore
249
+ y: this.props.sticky ? this.state.coordinates.relativeY : null,
250
+ // @ts-ignore
251
+ direction: this.props.sticky ? this.state.coordinates.direction : null,
252
+ // @ts-ignore
253
+ distance: this.props.sticky ? this.state.coordinates.distance : null
254
+ });
255
+ }
256
+ };
257
+ /**
258
+ * Get the shape stylings for the base
259
+ * @private
260
+ */
261
+ Joystick.prototype.getBaseShapeStyle = function () {
262
+ var shape = this.props.baseShape || shape_enum_1.JoystickShape.Circle;
263
+ return (0, shape_factory_1.shapeFactory)(shape, this._baseSize);
264
+ };
265
+ /**
266
+ * Get the shape stylings for the stick
267
+ * @private
268
+ */
269
+ Joystick.prototype.getStickShapeStyle = function () {
270
+ var shape = this.props.stickShape || shape_enum_1.JoystickShape.Circle;
271
+ return (0, shape_factory_1.shapeFactory)(shape, this._baseSize);
272
+ };
273
+ /**
274
+ * Calculate base styles for pad
275
+ * @private
276
+ */
277
+ Joystick.prototype._getBaseStyle = function () {
278
+ var baseColor = this.props.baseColor !== undefined ? this.props.baseColor : "#000033";
279
+ var baseSizeString = "".concat(this._baseSize, "px");
280
+ var padStyle = __assign(__assign({}, this.getBaseShapeStyle()), { height: baseSizeString, width: baseSizeString, background: baseColor, display: 'flex', justifyContent: 'center', alignItems: 'center' });
281
+ if (this.props.baseImage) {
282
+ padStyle.background = "url(".concat(this.props.baseImage, ")");
283
+ padStyle.backgroundSize = '100%';
284
+ }
285
+ return padStyle;
286
+ };
287
+ /**
288
+ * Calculate base styles for joystick and translate
289
+ * @private
290
+ */
291
+ Joystick.prototype._getStickStyle = function () {
292
+ var stickColor = this.props.stickColor !== undefined ? this.props.stickColor : "#3D59AB";
293
+ var stickSize = "".concat(this._baseSize / 1.5, "px");
294
+ var stickStyle = __assign(__assign({}, this.getStickShapeStyle()), { background: stickColor, cursor: "move", height: stickSize, width: stickSize, border: 'none', flexShrink: 0, touchAction: 'none' });
295
+ if (this.props.stickImage) {
296
+ stickStyle.background = "url(".concat(this.props.stickImage, ")");
297
+ stickStyle.backgroundSize = '100%';
298
+ }
299
+ if (this.state.coordinates !== undefined) {
300
+ stickStyle = Object.assign({}, stickStyle, {
301
+ position: 'absolute',
302
+ transform: "translate3d(".concat(this.state.coordinates.relativeX, "px, ").concat(this.state.coordinates.relativeY, "px, 0)")
303
+ });
304
+ }
305
+ return stickStyle;
306
+ };
307
+ Joystick.prototype.render = function () {
308
+ var _this = this;
309
+ this._baseSize = this.props.size || 100;
310
+ this._radius = this._baseSize / 2;
311
+ var baseStyle = this._getBaseStyle();
312
+ var stickStyle = this._getStickStyle();
313
+ //@ts-ignore
314
+ return (React.createElement("div", { className: this.props.disabled ? 'joystick-base-disabled' : '', ref: this._baseRef, style: baseStyle },
315
+ React.createElement("button", { ref: this._stickRef, disabled: this.props.disabled, onPointerDown: function (event) { return _this._pointerDown(event); }, className: this.props.disabled ? 'joystick-disabled' : '', style: stickStyle })));
316
+ };
317
+ return Joystick;
318
+ }(React.Component));
319
+ exports.Joystick = Joystick;
320
+ //# sourceMappingURL=Joystick.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Joystick.js","sourceRoot":"","sources":["../../src/Joystick.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6BAA+B;AAC/B,iDAAiD;AACjD,wDAAoD;AACpD,sEAAiE;AAqBjE,IAAK,iBAIJ;AAJD,WAAK,iBAAiB;IAClB,gDAA2B,CAAA;IAC3B,gDAA2B,CAAA;IAC3B,4CAAuB,CAAA;AAC3B,CAAC,EAJI,iBAAiB,KAAjB,iBAAiB,QAIrB;AA4BD;;GAEG;AACH,IAAK,qBAKJ;AALD,WAAK,qBAAqB;IACtB,kFAAqB,CAAA;IACrB,iFAAqB,CAAA;IACrB,yFAAyB,C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AAC,mBAAmB,CAAC,CAAC,CAAC,EAAE,EACzD,KAAK,EAAE,UAAU,GAAG,CAC1B,CACT,CAAA;IACL,CAAC;IACL,eAAC;AAAD,CAAC,AA5UD,CAAuB,KAAK,CAAC,SAAS,GA4UrC;AAGG,4BAAQ"}
@@ -0,0 +1 @@
1
+ import './stories.css';
@@ -0,0 +1,123 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ var React = require("react");
19
+ var ReactDOM = require("react-dom");
20
+ var react_1 = require("@storybook/react");
21
+ var addon_actions_1 = require("@storybook/addon-actions");
22
+ var react_parallax_tilt_1 = require("react-parallax-tilt");
23
+ var Joystick_1 = require("./Joystick");
24
+ var shape_enum_1 = require("./enums/shape.enum");
25
+ var react_2 = require("react");
26
+ require("./stories.css");
27
+ var joystickStories = (0, react_1.storiesOf)('Joystick Examples', module);
28
+ joystickStories.add("Default joystick", function () { return React.createElement(Joystick_1.Joystick, { start: (0, addon_actions_1.action)("Started"), move: (0, addon_actions_1.action)("Moved"), stop: (0, addon_actions_1.action)("Stopped") }); });
29
+ joystickStories.add("Default joystick with 50% minDistance", function () { return React.createElement(Joystick_1.Joystick, { minDistance: 50, start: (0, addon_actions_1.action)("Started"), move: (0, addon_actions_1.action)("Moved"), stop: (0, addon_actions_1.action)("Stopped") }); });
30
+ joystickStories.add("Control plane override", function () { return React.createElement(Joystick_1.Joystick, { start: (0, addon_actions_1.action)("Started"), controlPlaneShape: shape_enum_1.JoystickShape.Square, move: (0, addon_actions_1.action)("Moved"), stop: (0, addon_actions_1.action)("Stopped") }); });
31
+ joystickStories.add("Square joystick", function () { return React.createElement("div", { style: { display: 'flex', justifyContent: 'space-around', padding: '25px' } },
32
+ React.createElement(Joystick_1.Joystick, { throttle: 100, start: (0, addon_actions_1.action)("Started"), baseShape: shape_enum_1.JoystickShape.Square, stickShape: shape_enum_1.JoystickShape.Square, move: (0, addon_actions_1.action)("Moved"), stop: (0, addon_actions_1.action)("Stopped") }),
33
+ React.createElement(Joystick_1.Joystick, { throttle: 100, start: (0, addon_actions_1.action)("Started"), baseShape: shape_enum_1.JoystickShape.Square, move: (0, addon_actions_1.action)("Moved"), stop: (0, addon_actions_1.action)("Stopped") })); });
34
+ joystickStories.add("Yellow (custom colors) joystick", function () { return React.createElement(Joystick_1.Joystick, { start: (0, addon_actions_1.action)("Started"), baseColor: "#FFFF99", stickColor: "#FFD300", move: (0, addon_actions_1.action)("Moved"), stop: (0, addon_actions_1.action)("Stopped") }); });
35
+ joystickStories.add("50ms throttled joystick", function () { return React.createElement(Joystick_1.Joystick, { start: (0, addon_actions_1.action)("Started"), throttle: 50, move: (0, addon_actions_1.action)("Moved"), stop: (0, addon_actions_1.action)("Stopped") }); });
36
+ joystickStories.add("100ms throttled joystick", function () { return React.createElement(Joystick_1.Joystick, { start: (0, addon_actions_1.action)("Started"), throttle: 100, move: (0, addon_actions_1.action)("Moved"), stop: (0, addon_actions_1.action)("Stopped") }); });
37
+ joystickStories.add("200ms throttled joystick", function () { return React.createElement(Joystick_1.Joystick, { start: (0, addon_actions_1.action)("Started"), throttle: 200, move: (0, addon_actions_1.action)("Moved"), stop: (0, addon_actions_1.action)("Stopped") }); });
38
+ joystickStories.add("500ms throttled joystick", function () { return React.createElement(Joystick_1.Joystick, { start: (0, addon_actions_1.action)("Started"), throttle: 500, move: (0, addon_actions_1.action)("Moved"), stop: (0, addon_actions_1.action)("Stopped") }); });
39
+ joystickStories.add("Sticky joystick", function () { return React.createElement(Joystick_1.Joystick, { sticky: true, start: (0, addon_actions_1.action)("Started"), throttle: 50, move: (0, addon_actions_1.action)("Moved"), stop: (0, addon_actions_1.action)("Stopped") }); });
40
+ joystickStories.add("Images", function () { return React.createElement(Joystick_1.Joystick, { baseImage: "http://s3.amazonaws.com/pix.iemoji.com/images/emoji/apple/ios-12/256/fire.png", stickImage: "https://i.imgflip.com/1cf8by.jpg", start: (0, addon_actions_1.action)("Started"), throttle: 50, move: (0, addon_actions_1.action)("Moved"), stop: (0, addon_actions_1.action)("Stopped") }); });
41
+ joystickStories.add("Follow Cursor", function () { return (React.createElement("div", { style: { padding: "50px", display: 'flex' } },
42
+ React.createElement(Joystick_1.Joystick, { followCursor: true, start: (0, addon_actions_1.action)("Started"), baseColor: 'grey', stickColor: 'black', throttle: 50, move: (0, addon_actions_1.action)("Moved"), stop: (0, addon_actions_1.action)("Stopped") }),
43
+ React.createElement(Joystick_1.Joystick, { followCursor: true, start: (0, addon_actions_1.action)("Started"), baseColor: 'grey', stickColor: 'black', throttle: 50, move: (0, addon_actions_1.action)("Moved"), stop: (0, addon_actions_1.action)("Stopped") }))); });
44
+ joystickStories.add("Many follow Cursor", function () { return (React.createElement("div", { style: { padding: "50px", display: 'flex' } },
45
+ React.createElement(Joystick_1.Joystick, { followCursor: true, start: (0, addon_actions_1.action)("Started"), baseColor: 'grey', stickColor: 'black', throttle: 50, move: (0, addon_actions_1.action)("Moved"), stop: (0, addon_actions_1.action)("Stopped") }),
46
+ React.createElement(Joystick_1.Joystick, { followCursor: true, start: (0, addon_actions_1.action)("Started"), baseColor: 'grey', stickColor: 'black', throttle: 50, move: (0, addon_actions_1.action)("Moved"), stop: (0, addon_actions_1.action)("Stopped") }),
47
+ React.createElement(Joystick_1.Joystick, { followCursor: true, start: (0, addon_actions_1.action)("Started"), baseColor: 'grey', stickColor: 'black', throttle: 50, move: (0, addon_actions_1.action)("Moved"), stop: (0, addon_actions_1.action)("Stopped") }),
48
+ " ",
49
+ React.createElement(Joystick_1.Joystick, { followCursor: true, start: (0, addon_actions_1.action)("Started"), baseColor: 'grey', stickColor: 'black', throttle: 50, move: (0, addon_actions_1.action)("Moved"), stop: (0, addon_actions_1.action)("Stopped") }),
50
+ " ",
51
+ React.createElement(Joystick_1.Joystick, { followCursor: true, start: (0, addon_actions_1.action)("Started"), baseColor: 'grey', stickColor: 'black', throttle: 50, move: (0, addon_actions_1.action)("Moved"), stop: (0, addon_actions_1.action)("Stopped") }),
52
+ " ",
53
+ React.createElement(Joystick_1.Joystick, { followCursor: true, start: (0, addon_actions_1.action)("Started"), baseColor: 'grey', stickColor: 'black', throttle: 50, move: (0, addon_actions_1.action)("Moved"), stop: (0, addon_actions_1.action)("Stopped") }),
54
+ React.createElement(Joystick_1.Joystick, { followCursor: true, start: (0, addon_actions_1.action)("Started"), baseColor: 'grey', stickColor: 'black', throttle: 50, move: (0, addon_actions_1.action)("Moved"), stop: (0, addon_actions_1.action)("Stopped") }))); });
55
+ joystickStories.add("HUGE joystick", function () { return React.createElement(Joystick_1.Joystick, { start: (0, addon_actions_1.action)("Started"), move: (0, addon_actions_1.action)("Moved"), stop: (0, addon_actions_1.action)("Stopped"), size: 500 }); });
56
+ joystickStories.add("Tiny joystick", function () { return React.createElement(Joystick_1.Joystick, { start: (0, addon_actions_1.action)("Started"), move: (0, addon_actions_1.action)("Moved"), stop: (0, addon_actions_1.action)("Stopped"), size: 50 }); });
57
+ joystickStories.add("Disabled joystick", function () { return React.createElement(Joystick_1.Joystick, { start: (0, addon_actions_1.action)("Started"), move: (0, addon_actions_1.action)("Moved"), stop: (0, addon_actions_1.action)("Stopped"), disabled: true }); });
58
+ joystickStories.add("Controlling a react-parallax-tilt ", function () {
59
+ var _a = (0, react_2.useState)([0, 0]), _b = _a[0], manualTiltAngleX = _b[0], manualTiltAngleY = _b[1], setManualTiltAngle = _a[1];
60
+ var onMove = function (stick) {
61
+ setManualTiltAngle([stick.y, stick.x]);
62
+ };
63
+ var onStop = function () {
64
+ setManualTiltAngle([0, 0]);
65
+ };
66
+ return React.createElement(React.Fragment, null,
67
+ React.createElement("div", { className: "tilt-manual-input" },
68
+ React.createElement(react_parallax_tilt_1.default, { tiltAngleXManual: manualTiltAngleX, tiltAngleYManual: manualTiltAngleY, glareEnable: true },
69
+ React.createElement("div", { className: "react-parallax-tilt" },
70
+ React.createElement("div", null,
71
+ "Axis x: ", manualTiltAngleX === null || manualTiltAngleX === void 0 ? void 0 :
72
+ manualTiltAngleX.toFixed(0),
73
+ "\u00B0"),
74
+ React.createElement("div", null,
75
+ "Axis y: ", manualTiltAngleY === null || manualTiltAngleY === void 0 ? void 0 :
76
+ manualTiltAngleY.toFixed(0),
77
+ "\u00B0"))),
78
+ React.createElement("div", { className: "manual-input" },
79
+ React.createElement(Joystick_1.Joystick, { baseColor: "darkgreen", stickColor: "black", move: onMove, stop: onStop })),
80
+ React.createElement("h3", null,
81
+ "Thanks to ",
82
+ React.createElement("a", { href: "https://github.com/mkosir/react-parallax-tilt" }, "react-parallax-tilt"))));
83
+ });
84
+ var DirectionComponent = /** @class */ (function (_super) {
85
+ __extends(DirectionComponent, _super);
86
+ function DirectionComponent(props) {
87
+ var _this = _super.call(this, props) || this;
88
+ _this.state = {
89
+ direction: "Stopped"
90
+ };
91
+ return _this;
92
+ }
93
+ DirectionComponent.prototype._handleMove = function (data) {
94
+ this.setState({
95
+ direction: data.direction
96
+ });
97
+ };
98
+ DirectionComponent.prototype._handleStop = function () {
99
+ this.setState({
100
+ direction: "Stopped"
101
+ });
102
+ };
103
+ DirectionComponent.prototype.render = function () {
104
+ return (React.createElement("div", null,
105
+ React.createElement(Joystick_1.Joystick, { move: this._handleMove.bind(this), stop: this._handleStop.bind(this) }),
106
+ React.createElement("p", null, this.state.direction)));
107
+ };
108
+ return DirectionComponent;
109
+ }(React.Component));
110
+ joystickStories.add("Default with direction text", function () { return React.createElement(DirectionComponent, null); });
111
+ var Modal = function (_a) {
112
+ var isOpen = _a.isOpen;
113
+ if (!isOpen)
114
+ return null;
115
+ return ReactDOM.createPortal(React.createElement(Joystick_1.Joystick, null), document.body);
116
+ };
117
+ joystickStories.add("Default with portal", function () {
118
+ var _a = (0, react_2.useState)(false), isOpen = _a[0], setIsOpen = _a[1];
119
+ return React.createElement(React.Fragment, null,
120
+ React.createElement("button", { onClick: function () { return setIsOpen(!isOpen); } }, "Open"),
121
+ React.createElement(Modal, { isOpen: isOpen }));
122
+ });
123
+ //# sourceMappingURL=Joystick.stories.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Joystick.stories.js","sourceRoot":"","sources":["../../src/Joystick.stories.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,6BAA+B;AAC/B,oCAAsC;AACtC,0CAA2C;AAC3C,0DAAgD;AAChD,2DAAuC;AAEvC,uCAA0D;AAC1D,iDAAiD;AACjD,+BAA+B;AAC/B,yBAAuB;AAEvB,IAAM,eAAe,GAAG,IAAA,iBAAS,EAAC,mBAAmB,EAAE,MAAM,CAAC,CAAC;AAG/D,eAAe,CAAC,GAAG,CAAC,kBAAkB,EAAE,cAAM,OAAA,oBAAC,mBAAQ,IAAC,KAAK,EAAE,IAAA,sBAAM,EAAC,SAAS,CAAC,EAAE,IAAI,EAAE,IAAA,sBAAM,EAAC,OAAO,CAAC,EAC/C,IAAI,EAAE,IAAA,sBAAM,EAAC,SAAS,CAAC,GAAG,EADpC,CACoC,CAAC,CAAC;AACpF,eAAe,CAAC,GAAG,CAAC,uCAAuC,EAAE,cAAM,OAAA,oBAAC,mBAAQ,IAAC,WAAW,EAAE,EAAE,EAAE,KAAK,EAAE,IAAA,sBAAM,EAAC,SAAS,CAAC,EAAE,IAAI,EAAE,IAAA,sBAAM,EAAC,OAAO,CAAC,EACrF,IAAI,EAAE,IAAA,sBAAM,EAAC,SAAS,CAAC,GAAG,EADf,CACe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AC,CAAA;AAE/E,IAAM,KAAK,GAAE,UAAC,EAA4B;QAAzB,MAAM,YAAA;IACnB,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAA;IACxB,OAAO,QAAQ,CAAC,YAAY,CACpB,oBAAC,mBAAQ,OAAG,EAEhB,QAAQ,CAAC,IAAI,CAAC,CAAA;AACtB,CAAC,CAAA;AAGD,eAAe,CAAC,GAAG,CAAC,qBAAqB,EAAE;IACjC,IAAA,KAAsB,IAAA,gBAAQ,EAAC,KAAK,CAAQ,EAA3C,MAAM,QAAA,EAAE,SAAS,QAA0B,CAAC;IACnD,OAAO;QACH,gCAAQ,OAAO,EAAE,cAAK,OAAA,SAAS,CAAC,CAAC,MAAM,CAAC,EAAlB,CAAkB,WAAe;QACvD,oBAAC,KAAK,IAAC,MAAM,EAAE,MAAM,GAAU,CAAG,CAAA;AAC1C,CAAC,CAAC,CAAA"}
@@ -0,0 +1,4 @@
1
+ export declare enum JoystickShape {
2
+ Circle = "circle",
3
+ Square = "square"
4
+ }
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.JoystickShape = void 0;
4
+ var JoystickShape;
5
+ (function (JoystickShape) {
6
+ JoystickShape["Circle"] = "circle";
7
+ JoystickShape["Square"] = "square";
8
+ })(JoystickShape = exports.JoystickShape || (exports.JoystickShape = {}));
9
+ //# sourceMappingURL=shape.enum.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shape.enum.js","sourceRoot":"","sources":["../../../src/enums/shape.enum.ts"],"names":[],"mappings":";;;AAAA,IAAY,aAGX;AAHD,WAAY,aAAa;IACrB,kCAAiB,CAAA;IACjB,kCAAiB,CAAA;AACrB,CAAC,EAHW,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAGxB"}
@@ -0,0 +1,2 @@
1
+ export { Joystick } from "./Joystick";
2
+ export { JoystickShape } from './enums/shape.enum';
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.JoystickShape = exports.Joystick = void 0;
4
+ var Joystick_1 = require("./Joystick");
5
+ Object.defineProperty(exports, "Joystick", { enumerable: true, get: function () { return Joystick_1.Joystick; } });
6
+ var shape_enum_1 = require("./enums/shape.enum");
7
+ Object.defineProperty(exports, "JoystickShape", { enumerable: true, get: function () { return shape_enum_1.JoystickShape; } });
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":";;;AAAA,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA;AACjB,iDAAmD;AAA1C,2GAAA,aAAa,OAAA"}
@@ -0,0 +1,5 @@
1
+ import { JoystickShape } from "../enums/shape.enum";
2
+ export declare const shapeBoundsFactory: (shape: JoystickShape, absoluteX: number, absoluteY: number, relativeX: number, relativeY: number, dist: number, radius: number, baseSize: number, parentRect: DOMRect) => {
3
+ relativeX: number;
4
+ relativeY: number;
5
+ };
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.shapeBoundsFactory = void 0;
4
+ var shape_enum_1 = require("../enums/shape.enum");
5
+ var shapeBoundsFactory = function (shape, absoluteX, absoluteY, relativeX, relativeY, dist, radius, baseSize, parentRect) {
6
+ switch (shape) {
7
+ case shape_enum_1.JoystickShape.Square:
8
+ relativeX = getWithinBounds(absoluteX - parentRect.left - (baseSize / 2), baseSize);
9
+ relativeY = getWithinBounds(absoluteY - parentRect.top - (baseSize / 2), baseSize);
10
+ return { relativeX: relativeX, relativeY: relativeY };
11
+ default:
12
+ if (dist > radius) {
13
+ relativeX *= radius / dist;
14
+ relativeY *= radius / dist;
15
+ }
16
+ return { relativeX: relativeX, relativeY: relativeY };
17
+ }
18
+ };
19
+ exports.shapeBoundsFactory = shapeBoundsFactory;
20
+ var getWithinBounds = function (value, baseSize) {
21
+ var halfBaseSize = baseSize / 2;
22
+ if (value > halfBaseSize) {
23
+ return halfBaseSize;
24
+ }
25
+ if (value < -(halfBaseSize)) {
26
+ return halfBaseSize * -1;
27
+ }
28
+ return value;
29
+ };
30
+ //# sourceMappingURL=shape.bounds.factory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shape.bounds.factory.js","sourceRoot":"","sources":["../../../src/shapes/shape.bounds.factory.ts"],"names":[],"mappings":";;;AAAA,kDAAkD;AAE3C,IAAM,kBAAkB,GAAG,UAC9B,KAAoB,EACpB,SAAgB,EAChB,SAAiB,EACjB,SAAgB,EAChB,SAAgB,EAChB,IAAW,EACX,MAAa,EACb,QAAgB,EAChB,UAAmB;IACnB,QAAQ,KAAK,EAAC;QACV,KAAK,0BAAa,CAAC,MAAM;YACrB,SAAS,GAAG,eAAe,CAAC,SAAS,GAAG,UAAU,CAAC,IAAI,GAAG,CAAC,QAAQ,GAAG,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;YACpF,SAAS,GAAG,eAAe,CAAC,SAAS,GAAG,UAAU,CAAC,GAAG,GAAG,CAAC,QAAQ,GAAG,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;YACnF,OAAO,EAAC,SAAS,WAAA,EAAE,SAAS,WAAA,EAAC,CAAC;QAElC;YACI,IAAI,IAAI,GAAG,MAAM,EAAE;gBACf,SAAS,IAAI,MAAM,GAAG,IAAI,CAAC;gBAC3B,SAAS,IAAI,MAAM,GAAG,IAAI,CAAC;aAC9B;YACD,OAAO,EAAC,SAAS,WAAA,EAAE,SAAS,WAAA,EAAC,CAAC;KAErC;AAEL,CAAC,CAAA;AAzBY,QAAA,kBAAkB,sBAyB9B;AAED,IAAM,eAAe,GAAG,UAAC,KAAY,EAAE,QAAe;IAClD,IAAM,YAAY,GAAG,QAAQ,GAAG,CAAC,CAAC;IAClC,IAAG,KAAK,GAAG,YAAY,EAAC;QACpB,OAAO,YAAY,CAAC;KACvB;IACD,IAAG,KAAK,GAAG,CAAC,CAAC,YAAY,CAAC,EAAC;QACvB,OAAO,YAAY,GAAG,CAAC,CAAC,CAAC;KAC5B;IACD,OAAO,KAAK,CAAA;AAChB,CAAC,CAAA"}
@@ -0,0 +1,4 @@
1
+ import { JoystickShape } from "../enums/shape.enum";
2
+ export declare const shapeFactory: (shape: JoystickShape, size: number) => {
3
+ borderRadius: number;
4
+ };
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.shapeFactory = void 0;
4
+ var shape_enum_1 = require("../enums/shape.enum");
5
+ var shapeFactory = function (shape, size) {
6
+ switch (shape) {
7
+ case shape_enum_1.JoystickShape.Circle:
8
+ return {
9
+ borderRadius: size,
10
+ };
11
+ case shape_enum_1.JoystickShape.Square:
12
+ return {
13
+ borderRadius: Math.sqrt(size)
14
+ };
15
+ }
16
+ };
17
+ exports.shapeFactory = shapeFactory;
18
+ //# sourceMappingURL=shape.factory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shape.factory.js","sourceRoot":"","sources":["../../../src/shapes/shape.factory.ts"],"names":[],"mappings":";;;AAAA,kDAAkD;AAE3C,IAAM,YAAY,GAAG,UAAC,KAAoB,EAAE,IAAY;IAC3D,QAAQ,KAAK,EAAC;QACV,KAAK,0BAAa,CAAC,MAAM;YACrB,OAAO;gBACH,YAAY,EAAC,IAAI;aACpB,CAAC;QACN,KAAK,0BAAa,CAAC,MAAM;YACrB,OAAQ;gBACJ,YAAY,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;aAChC,CAAA;KACR;AACL,CAAC,CAAA;AAXY,QAAA,YAAY,gBAWxB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-simple-game-engine",
3
- "version": "0.2.27",
3
+ "version": "0.2.29",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib",
@@ -9,8 +9,7 @@
9
9
  "@types/matter-js": "^0.17.7",
10
10
  "@types/p5": "^1.4.2",
11
11
  "matter-js": "^0.18.0",
12
- "p5": "^1.4.1",
13
- "react-joystick-component": "^4.0.1"
12
+ "p5": "^1.4.1"
14
13
  },
15
14
  "devDependencies": {
16
15
  "@types/node": "^16.7.13",
@@ -19,7 +18,7 @@
19
18
  "typescript": "^4.4.2"
20
19
  },
21
20
  "scripts": {
22
- "build": "rm -rf lib && tsc -p ."
21
+ "build": "rm -rf lib && tsc -p . && cp -R src/ui-components/react-joystick-component lib/ui-components/react-joystick-component"
23
22
  },
24
23
  "files": [
25
24
  "/lib"