react-simple-game-engine 0.0.23 → 0.0.24

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.
@@ -1,14 +1,16 @@
1
1
  import { AvatarSprite } from "../sprites/avatar.sprite";
2
2
  import { AnimationSprite } from "./animation";
3
+ declare type Offset = {
4
+ x: number;
5
+ y: number;
6
+ width: number;
7
+ height: number;
8
+ };
3
9
  export declare class AvatarAnimationSprite extends AnimationSprite<AvatarSprite> {
4
- private options;
5
- initial({ offsetX, offsetY, ...options }: {
6
- offsetX?: number;
7
- offsetY?: number;
8
- offsetWidth: number;
9
- offsetHeight: number;
10
- }): void;
10
+ private offset;
11
+ initial({ x, y, width, height }: Partial<Offset>): void;
11
12
  protected checkFrameMax(): boolean;
12
13
  onDraw(): void;
13
14
  }
15
+ export {};
14
16
  //# sourceMappingURL=avatar.animation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"avatar.animation.d.ts","sourceRoot":"","sources":["../../../src/classes/animations/avatar.animation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,qBAAa,qBAAsB,SAAQ,eAAe,CAAC,YAAY,CAAC;IACtE,OAAO,CAAC,OAAO,CAKb;IAEF,OAAO,CAAC,EACN,OAAW,EACX,OAAW,EACX,GAAG,OAAO,EACX,EAAE;QACD,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,WAAW,EAAE,MAAM,CAAC;QACpB,YAAY,EAAE,MAAM,CAAC;KACtB;IAQD,SAAS,CAAC,aAAa,IAAI,OAAO;IAOlC,MAAM;CAiBP"}
1
+ {"version":3,"file":"avatar.animation.d.ts","sourceRoot":"","sources":["../../../src/classes/animations/avatar.animation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,aAAK,MAAM,GAAG;IACZ,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,qBAAa,qBAAsB,SAAQ,eAAe,CAAC,YAAY,CAAC;IACtE,OAAO,CAAC,MAAM,CAAU;IAExB,OAAO,CAAC,EAAE,CAAK,EAAE,CAAK,EAAE,KAAS,EAAE,MAAU,EAAE,EAAE,OAAO,CAAC,MAAM,CAAC;IAShE,SAAS,CAAC,aAAa,IAAI,OAAO;IAKlC,MAAM;CAiBP"}
@@ -13,28 +13,6 @@ var __extends = (this && this.__extends) || (function () {
13
13
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
14
  };
15
15
  })();
16
- var __assign = (this && this.__assign) || function () {
17
- __assign = Object.assign || function(t) {
18
- for (var s, i = 1, n = arguments.length; i < n; i++) {
19
- s = arguments[i];
20
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
21
- t[p] = s[p];
22
- }
23
- return t;
24
- };
25
- return __assign.apply(this, arguments);
26
- };
27
- var __rest = (this && this.__rest) || function (s, e) {
28
- var t = {};
29
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
30
- t[p] = s[p];
31
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
32
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
33
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
34
- t[p[i]] = s[p[i]];
35
- }
36
- return t;
37
- };
38
16
  import { AnimationSprite } from "./animation";
39
17
  var AvatarAnimationSprite = /** @class */ (function (_super) {
40
18
  __extends(AvatarAnimationSprite, _super);
@@ -42,21 +20,26 @@ var AvatarAnimationSprite = /** @class */ (function (_super) {
42
20
  return _super !== null && _super.apply(this, arguments) || this;
43
21
  }
44
22
  AvatarAnimationSprite.prototype.initial = function (_a) {
45
- var _b = _a.offsetX, offsetX = _b === void 0 ? 0 : _b, _c = _a.offsetY, offsetY = _c === void 0 ? 0 : _c, options = __rest(_a, ["offsetX", "offsetY"]);
46
- this.options = __assign({ offsetX: offsetX, offsetY: offsetY }, options);
23
+ var _b = _a.x, x = _b === void 0 ? 0 : _b, _c = _a.y, y = _c === void 0 ? 0 : _c, _d = _a.width, width = _d === void 0 ? 0 : _d, _e = _a.height, height = _e === void 0 ? 0 : _e;
24
+ this.offset = {
25
+ x: x,
26
+ y: y,
27
+ width: width,
28
+ height: height,
29
+ };
47
30
  };
48
31
  AvatarAnimationSprite.prototype.checkFrameMax = function () {
49
- var _a = this.options, offsetWidth = _a.offsetWidth, offsetX = _a.offsetX;
50
- return (this.currentFrame * offsetWidth + offsetX >= this.source.sprite.width);
32
+ var _a = this.offset, width = _a.width, x = _a.x;
33
+ return this.currentFrame * width + x >= this.source.sprite.width;
51
34
  };
52
35
  AvatarAnimationSprite.prototype.onDraw = function () {
53
36
  var source = this.source;
54
- var _a = this.options, offsetWidth = _a.offsetWidth, offsetHeight = _a.offsetHeight, offsetX = _a.offsetX, offsetY = _a.offsetY;
37
+ var _a = this.offset, x = _a.x, y = _a.y, width = _a.width, height = _a.height;
55
38
  Renderer.image(source.sprite,
56
39
  // position on canvas
57
40
  0, 0, source.width, source.height,
58
41
  //crop on source image
59
- this.currentFrame * offsetWidth + offsetX, offsetY, offsetWidth, offsetHeight);
42
+ this.currentFrame * width + x, y, width, height);
60
43
  };
61
44
  return AvatarAnimationSprite;
62
45
  }(AnimationSprite));
@@ -11,7 +11,8 @@ declare type AvatarGetInitialParams<S extends AvatarSprite> = GetInitialParams<S
11
11
  offset?: Partial<SpriteOffet>;
12
12
  };
13
13
  export declare class AvatarSprite extends Sprite<Avatar | undefined | null> {
14
- private offset;
14
+ private _offset;
15
+ get offset(): SpriteOffet;
15
16
  onDraw(): void;
16
17
  initial(params?: AvatarGetInitialParams<this>): void;
17
18
  }
@@ -1 +1 @@
1
- {"version":3,"file":"avatar.sprite.d.ts","sourceRoot":"","sources":["../../../src/classes/sprites/avatar.sprite.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEpD,aAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,aAAK,sBAAsB,CAAC,CAAC,SAAS,YAAY,IAAI,gBAAgB,CAAC,CAAC,CAAC,GAAG;IAE1E,MAAM,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;CAC/B,CAAC;AAEF,qBAAa,YAAa,SAAQ,MAAM,CAAC,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC;IACjE,OAAO,CAAC,MAAM,CAMZ;IAEF,MAAM;IAwBN,OAAO,CAAC,MAAM,CAAC,EAAE,sBAAsB,CAAC,IAAI,CAAC;CAe9C"}
1
+ {"version":3,"file":"avatar.sprite.d.ts","sourceRoot":"","sources":["../../../src/classes/sprites/avatar.sprite.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEpD,aAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,aAAK,sBAAsB,CAAC,CAAC,SAAS,YAAY,IAAI,gBAAgB,CAAC,CAAC,CAAC,GAAG;IAE1E,MAAM,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;CAC/B,CAAC;AAEF,qBAAa,YAAa,SAAQ,MAAM,CAAC,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC;IACjE,OAAO,CAAC,OAAO,CAMb;IAEF,IAAI,MAAM,gBAET;IAED,MAAM;IAuBN,OAAO,CAAC,MAAM,CAAC,EAAE,sBAAsB,CAAC,IAAI,CAAC;CAc9C"}
@@ -41,7 +41,7 @@ var AvatarSprite = /** @class */ (function (_super) {
41
41
  __extends(AvatarSprite, _super);
42
42
  function AvatarSprite() {
43
43
  var _this = _super !== null && _super.apply(this, arguments) || this;
44
- _this.offset = {
44
+ _this._offset = {
45
45
  x: 0,
46
46
  y: 0,
47
47
  index: 0,
@@ -50,14 +50,20 @@ var AvatarSprite = /** @class */ (function (_super) {
50
50
  };
51
51
  return _this;
52
52
  }
53
+ Object.defineProperty(AvatarSprite.prototype, "offset", {
54
+ get: function () {
55
+ return this._offset;
56
+ },
57
+ enumerable: false,
58
+ configurable: true
59
+ });
53
60
  AvatarSprite.prototype.onDraw = function () {
54
61
  if (this.sprite) {
55
62
  if (this.animation) {
56
63
  this.animation.draw();
57
64
  }
58
65
  else {
59
- var _a = this.offset, x = _a.x, y = _a.y, width = _a.width, height = _a.height, index = _a.index;
60
- console.log("draw", x, index * width + x);
66
+ var _a = this._offset, x = _a.x, y = _a.y, width = _a.width, height = _a.height, index = _a.index;
61
67
  Renderer.image(this.sprite,
62
68
  // position on canvas
63
69
  0, 0, this.width, this.height,
@@ -70,12 +76,11 @@ var AvatarSprite = /** @class */ (function (_super) {
70
76
  var _a = (params ||
71
77
  {}), offset = _a.offset, sprite = _a.sprite, _params = __rest(_a, ["offset", "sprite"]);
72
78
  if (sprite) {
73
- this.offset.width = sprite.width;
74
- this.offset.height = sprite.height;
79
+ this._offset.width = sprite.width;
80
+ this._offset.height = sprite.height;
75
81
  }
76
82
  if (offset) {
77
- copyProperties(this.offset, offset);
78
- console.log("d", this.offset, offset);
83
+ copyProperties(this._offset, offset);
79
84
  }
80
85
  _super.prototype.initial.call(this, __assign(__assign({}, _params), { sprite: sprite }));
81
86
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-simple-game-engine",
3
- "version": "0.0.23",
3
+ "version": "0.0.24",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib",