react-simple-game-engine 0.2.43 → 0.2.45

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.
@@ -5,10 +5,11 @@ declare type Offset = {
5
5
  y: number;
6
6
  width: number;
7
7
  height: number;
8
+ distancePerFrame?: number;
8
9
  };
9
10
  export declare class AvatarAnimationSprite extends AnimationSprite<AvatarSprite> {
10
11
  private offset;
11
- initial({ x, y, width, height }: Partial<Offset>): void;
12
+ initial({ x, y, width, height, distancePerFrame, }: Partial<Offset>): void;
12
13
  protected checkFrameMax(): boolean;
13
14
  onDraw(): void;
14
15
  }
@@ -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,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,CAAS;IAEvB,OAAO,CAAC,EAAE,CAAK,EAAE,CAAK,EAAE,KAAS,EAAE,MAAU,EAAE,EAAE,OAAO,CAAC,MAAM,CAAC;IAShE,SAAS,CAAC,aAAa,IAAI,OAAO;IAKlC,MAAM;CAgBP"}
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;IACf,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF,qBAAa,qBAAsB,SAAQ,eAAe,CAAC,YAAY,CAAC;IACtE,OAAO,CAAC,MAAM,CAAS;IAEvB,OAAO,CAAC,EACN,CAAK,EACL,CAAK,EACL,KAAS,EACT,MAAU,EACV,gBAAoB,GACrB,EAAE,OAAO,CAAC,MAAM,CAAC;IAUlB,SAAS,CAAC,aAAa,IAAI,OAAO;IAQlC,MAAM;CAgBP"}
@@ -20,25 +20,27 @@ var AvatarAnimationSprite = /** @class */ (function (_super) {
20
20
  return _super !== null && _super.apply(this, arguments) || this;
21
21
  }
22
22
  AvatarAnimationSprite.prototype.initial = function (_a) {
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;
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, _f = _a.distancePerFrame, distancePerFrame = _f === void 0 ? 0 : _f;
24
24
  this.offset = {
25
25
  x: x,
26
26
  y: y,
27
27
  width: width,
28
28
  height: height,
29
+ distancePerFrame: distancePerFrame,
29
30
  };
30
31
  };
31
32
  AvatarAnimationSprite.prototype.checkFrameMax = function () {
32
- var _a = this.offset, width = _a.width, x = _a.x;
33
- return this.currentFrame * width + x >= this.sprite.source.width;
33
+ var _a = this.offset, width = _a.width, x = _a.x, distancePerFrame = _a.distancePerFrame;
34
+ return (x + this.currentFrame * (width + distancePerFrame) >=
35
+ this.sprite.source.width);
34
36
  };
35
37
  AvatarAnimationSprite.prototype.onDraw = function () {
36
- var _a = this.offset, x = _a.x, y = _a.y, width = _a.width, height = _a.height;
38
+ var _a = this.offset, x = _a.x, y = _a.y, width = _a.width, height = _a.height, distancePerFrame = _a.distancePerFrame;
37
39
  Renderer.image(this.sprite.source,
38
40
  // position on canvas
39
41
  0, 0, this.sprite.width, this.sprite.height,
40
42
  //crop on source image
41
- this.currentFrame * width + x, y, width, height);
43
+ x + this.currentFrame * (width + distancePerFrame), y, width, height);
42
44
  };
43
45
  return AvatarAnimationSprite;
44
46
  }(AnimationSprite));
@@ -3,7 +3,7 @@ import { CreateBodyDefine, EntityInitial } from "../../export-types";
3
3
  import { Entity } from "./entity";
4
4
  export declare class CircleEntity<P extends Record<string, any> = Record<string, any>> extends Entity<P> {
5
5
  radius: number;
6
- onSpriteWidthHeightBinding(): {
6
+ getSpriteWidthHeight(): {
7
7
  width: number;
8
8
  height: number;
9
9
  };
@@ -1 +1 @@
1
- {"version":3,"file":"circle.entity.d.ts","sourceRoot":"","sources":["../../../src/classes/entities/circle.entity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAU,MAAM,WAAW,CAAC;AAEzC,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAErE,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,qBAAa,YAAY,CACvB,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CACnD,SAAQ,MAAM,CAAC,CAAC,CAAC;IACV,MAAM,EAAE,MAAM,CAAC;IAEtB,0BAA0B,IAAI;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE;IAO/D,SAAS,CAAC,SAAS,IAAI,aAAa,CAAC,IAAI,CAAC;IAQ1C,SAAS,CAAC,YAAY,CACpB,EACE,CAAC,EACD,CAAC,EACD,GAAG,SAAS,EACb,EAAE,WAAW,CAAC,gBAAgB,CAAC;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC,WAAW,CAAC,CAAC,EACjE,OAAO,CAAC,EAAE,gBAAgB,CAAC,aAAa,CAAC,GACxC,IAAI;CAIR"}
1
+ {"version":3,"file":"circle.entity.d.ts","sourceRoot":"","sources":["../../../src/classes/entities/circle.entity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAU,MAAM,WAAW,CAAC;AAEzC,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAErE,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,qBAAa,YAAY,CACvB,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CACnD,SAAQ,MAAM,CAAC,CAAC,CAAC;IACV,MAAM,EAAE,MAAM,CAAC;IAEtB,oBAAoB,IAAI;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE;IAOzD,SAAS,CAAC,SAAS,IAAI,aAAa,CAAC,IAAI,CAAC;IAQ1C,SAAS,CAAC,YAAY,CACpB,EACE,CAAC,EACD,CAAC,EACD,GAAG,SAAS,EACb,EAAE,WAAW,CAAC,gBAAgB,CAAC;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC,WAAW,CAAC,CAAC,EACjE,OAAO,CAAC,EAAE,gBAAgB,CAAC,aAAa,CAAC,GACxC,IAAI;CAIR"}
@@ -32,7 +32,7 @@ var CircleEntity = /** @class */ (function (_super) {
32
32
  function CircleEntity() {
33
33
  return _super !== null && _super.apply(this, arguments) || this;
34
34
  }
35
- CircleEntity.prototype.onSpriteWidthHeightBinding = function () {
35
+ CircleEntity.prototype.getSpriteWidthHeight = function () {
36
36
  return {
37
37
  width: this.radius * 2,
38
38
  height: this.radius * 2,
@@ -43,7 +43,7 @@ export declare abstract class Entity<P extends Record<string, any> = Record<stri
43
43
  update(): void;
44
44
  onUpdate(): void;
45
45
  draw(): void;
46
- abstract onSpriteWidthHeightBinding(): {
46
+ abstract getSpriteWidthHeight(): {
47
47
  width: number;
48
48
  height: number;
49
49
  };
@@ -1 +1 @@
1
- {"version":3,"file":"entity.d.ts","sourceRoot":"","sources":["../../../src/classes/entities/entity.ts"],"names":[],"mappings":"AAAA,OAAO,MAAwB,MAAM,WAAW,CAAC;AAEjD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAG3C,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,UAAU,EACX,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEjC,aAAK,gBAAgB,GAAG,MAAM,IAAI,CAAC;AAEnC,aAAK,gBAAgB,GAAG;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,UAAU,GAAG,cAAc,CAAC,UAAU,CAAC,CAAC;CACjD,CAAC;AAEF,8BAAsB,MAAM,CAC1B,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CACnD,SAAQ,UAAU,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;IACzC,OAAO,CAAC,KAAK,CAAa;IAC1B,OAAO,CAAC,OAAO,CAAc;IAC7B,OAAO,CAAC,MAAM,CAAkB;IAChC,OAAO,CAAC,iBAAiB,CAKhB;IACT,OAAO,CAAC,WAAW,CAAS;IAErB,cAAc,EAAE,OAAO,CAAQ;IAC/B,KAAK,CAAC,EAAE,KAAK,CAAC;IAErB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,EAG7B;IAED,IAAI,MAAM,IALS,MAAM,CAAC,GAAG,CAAC,CAO7B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C,aAAa,CAAC;IAO3C,SAAS,CAAC,QAAQ,CAAC,YAAY,CAC7B,SAAS,EAAE,gBAAgB,CAAC,WAAW,CAAC,EACxC,OAAO,CAAC,EAAE,gBAAgB,CAAC,aAAa,CAAC,GACxC,MAAM,CAAC,IAAI;IAEd,OAAO,CAAC,EACN,SAAS,EACT,MAAM,EAAE,eAAe,EACvB,WAAW,EACX,KAAU,EACV,GAAG,MAAM,EACV,EAAE,aAAa,CAAC,IAAI,CAAC;IAiDtB,SAAS,CAAC,QAAQ,CAAC,SAAS,IAAI,aAAa,CAAC,IAAI,CAAC;IACnD,SAAS,CAAC,SAAS,IAAI,aAAa,CAAC,IAAI,CAAC;IAI1C,MAAM;IAeN,QAAQ;IAER,IAAI;IAMJ,QAAQ,CAAC,oBAAoB,IAAI;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE;IAElE,WAAW,CAAC,MAAM,EAAE,MAAM;IAC1B,cAAc,CAAC,MAAM,EAAE,MAAM;IAC7B,iBAAiB,CAAC,MAAM,EAAE,MAAM;CACjC"}
@@ -4,7 +4,7 @@ import { Entity } from "./entity";
4
4
  export declare class RectEntity<P extends Record<string, any> = any> extends Entity<P> {
5
5
  width: number;
6
6
  height: number;
7
- onSpriteWidthHeightBinding(): {
7
+ getSpriteWidthHeight(): {
8
8
  width: number;
9
9
  height: number;
10
10
  };
@@ -1 +1 @@
1
- {"version":3,"file":"rect.entity.d.ts","sourceRoot":"","sources":["../../../src/classes/entities/rect.entity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,IAAI,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAErE,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,qBAAa,UAAU,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,CAAE,SAAQ,MAAM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C,EAAE,MAAM,CAAC;KACjB,CAAC,CAAC,WAAW,CAAC,CAChB,EACD,OAAO,CAAC,EAAE,gBAAgB,CAAC,aAAa,CAAC,GACxC,IAAI;CAIR"}
@@ -32,7 +32,7 @@ var RectEntity = /** @class */ (function (_super) {
32
32
  function RectEntity() {
33
33
  return _super !== null && _super.apply(this, arguments) || this;
34
34
  }
35
- RectEntity.prototype.onSpriteWidthHeightBinding = function () {
35
+ RectEntity.prototype.getSpriteWidthHeight = function () {
36
36
  return {
37
37
  width: this.width,
38
38
  height: this.height,
@@ -19,7 +19,7 @@ var Sprite = /** @class */ (function () {
19
19
  },
20
20
  set: function (entity) {
21
21
  this._entity = entity;
22
- var _a = this._entity.onSpriteWidthHeightBinding(), width = _a.width, height = _a.height;
22
+ var _a = entity.getSpriteWidthHeight(), width = _a.width, height = _a.height;
23
23
  this._width = width;
24
24
  this._height = height;
25
25
  },
@@ -24,7 +24,7 @@ export function Control(_a) {
24
24
  if (e.type === JoystickActionType.MOVE) {
25
25
  scene.emitJoystickAction({
26
26
  type: e.type,
27
- vector: Renderer.createVector(e.x, e.y).normalize(),
27
+ vector: Renderer.createVector(e.x, -e.y).normalize(),
28
28
  weight: e.distance / 100,
29
29
  length: e.distance, // 0 -> 100
30
30
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-simple-game-engine",
3
- "version": "0.2.43",
3
+ "version": "0.2.45",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib",