react-simple-game-engine 0.1.62 → 0.1.63
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/lib/classes/animations/animation.d.ts +14 -0
- package/lib/classes/animations/avatar.animation.d.ts +16 -0
- package/lib/classes/animations/color.animation.d.ts +9 -0
- package/lib/classes/entities/circle.entity.d.ts +15 -0
- package/lib/classes/entities/entity-sult.d.ts +34 -0
- package/lib/classes/entities/entity.d.ts +55 -0
- package/lib/classes/entities/rect.entity.d.ts +17 -0
- package/lib/classes/sprites/avatar.sprite.d.ts +20 -0
- package/lib/classes/sprites/color.sprite.d.ts +7 -0
- package/lib/classes/sprites/sprite.d.ts +26 -0
- package/package.json +2 -1
@@ -0,0 +1,14 @@
|
|
1
|
+
import { Sprite } from "../sprites/sprite";
|
2
|
+
export declare abstract class AnimationSprite<S extends Sprite<any>> {
|
3
|
+
protected currentFrame: number;
|
4
|
+
protected _isRunning: boolean;
|
5
|
+
protected timeCounter: number;
|
6
|
+
delatime: number;
|
7
|
+
sprite: S;
|
8
|
+
set isRunning(_isRunning: boolean);
|
9
|
+
abstract initial(params: any): void;
|
10
|
+
draw(): void;
|
11
|
+
protected abstract checkFrameMax(): boolean;
|
12
|
+
protected abstract onDraw(): void;
|
13
|
+
}
|
14
|
+
//# sourceMappingURL=animation.d.ts.map
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import { AvatarSprite } from "../sprites/avatar.sprite";
|
2
|
+
import { AnimationSprite } from "./animation";
|
3
|
+
declare type Offset = {
|
4
|
+
x: number;
|
5
|
+
y: number;
|
6
|
+
width: number;
|
7
|
+
height: number;
|
8
|
+
};
|
9
|
+
export declare class AvatarAnimationSprite extends AnimationSprite<AvatarSprite> {
|
10
|
+
private offset;
|
11
|
+
initial({ x, y, width, height }: Partial<Offset>): void;
|
12
|
+
protected checkFrameMax(): boolean;
|
13
|
+
onDraw(): void;
|
14
|
+
}
|
15
|
+
export {};
|
16
|
+
//# sourceMappingURL=avatar.animation.d.ts.map
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import { ColorSprite } from "../sprites/color.sprite";
|
2
|
+
import { AnimationSprite } from "./animation";
|
3
|
+
export declare class ColorAnimationSprite extends AnimationSprite<ColorSprite> {
|
4
|
+
private colors;
|
5
|
+
initial(colors: ColorSprite["source"][]): void;
|
6
|
+
protected checkFrameMax(): boolean;
|
7
|
+
protected onDraw(): void;
|
8
|
+
}
|
9
|
+
//# sourceMappingURL=color.animation.d.ts.map
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import { Body } from "matter-js";
|
2
|
+
import { CreateBodyDefine, EntityInitial } from "../../export-types";
|
3
|
+
import { Entity } from "./entity";
|
4
|
+
export declare class CircleEntity<P extends Record<string, any> = Record<string, any>> extends Entity<P> {
|
5
|
+
radius: number;
|
6
|
+
onSpriteWidthHeightBinding(): {
|
7
|
+
width: number;
|
8
|
+
height: number;
|
9
|
+
};
|
10
|
+
protected onInitial(): EntityInitial<this>;
|
11
|
+
protected onCreateBody({ x, y, ...transform }: NonNullable<CreateBodyDefine<{
|
12
|
+
radius: number;
|
13
|
+
}>["transform"]>, options?: CreateBodyDefine["bodyOptions"]): Body;
|
14
|
+
}
|
15
|
+
//# sourceMappingURL=circle.entity.d.ts.map
|
@@ -0,0 +1,34 @@
|
|
1
|
+
import { Initialler } from "../../export-interfaces";
|
2
|
+
import { Camera } from "../camera";
|
3
|
+
import { LogicComponent } from "../logic-component";
|
4
|
+
import { Scene } from "../scene";
|
5
|
+
import { WorldManagement } from "../world-management";
|
6
|
+
export declare abstract class EntitySult<P = any> implements Initialler<P> {
|
7
|
+
camera: Camera;
|
8
|
+
readonly id: string;
|
9
|
+
private _layerIndex;
|
10
|
+
private _name;
|
11
|
+
private _scene;
|
12
|
+
private _worldManagement;
|
13
|
+
private _children;
|
14
|
+
private _parent?;
|
15
|
+
abstract update(): void;
|
16
|
+
abstract draw(): void;
|
17
|
+
get children(): EntitySult<any>[];
|
18
|
+
get layerIndex(): number;
|
19
|
+
get name(): string;
|
20
|
+
set layerIndex(_layerIndex: number);
|
21
|
+
set name(_name: string);
|
22
|
+
get parent(): EntitySult<any> | undefined;
|
23
|
+
get scene(): Scene<any>;
|
24
|
+
get worldManagement(): WorldManagement;
|
25
|
+
addChild(target: EntitySult | LogicComponent<EntitySult>): void;
|
26
|
+
removeChild(entity: EntitySult): void;
|
27
|
+
unChild(entity: EntitySult): void;
|
28
|
+
getProperty<T>(name: string): T;
|
29
|
+
preInitial(worldManagement: WorldManagement): void;
|
30
|
+
active(worldManagement: WorldManagement): void;
|
31
|
+
onActive(): void;
|
32
|
+
initial(params: P): void;
|
33
|
+
}
|
34
|
+
//# sourceMappingURL=entity-sult.d.ts.map
|
@@ -0,0 +1,55 @@
|
|
1
|
+
import Matter from "matter-js";
|
2
|
+
import { Sprite } from "../sprites/sprite";
|
3
|
+
import { CreateBodyDefine, EntityInitial, EntityPrepare, MasterBody } from "../../export-types";
|
4
|
+
import { EntitySult } from "./entity-sult";
|
5
|
+
import { LogicComponent } from "../logic-component";
|
6
|
+
import { Sound } from "../sound";
|
7
|
+
declare type TimerJobListener = () => void;
|
8
|
+
declare type TerminateOptions = {
|
9
|
+
duration?: number;
|
10
|
+
effect: EntitySult | LogicComponent<EntitySult>;
|
11
|
+
};
|
12
|
+
export declare abstract class Entity<P extends Record<string, any> = Record<string, any>> extends EntitySult<EntityInitial<Entity>> {
|
13
|
+
private _body;
|
14
|
+
private _sprite;
|
15
|
+
private _props;
|
16
|
+
private timerJobListeners;
|
17
|
+
private isTerminate;
|
18
|
+
enabledGravity: boolean;
|
19
|
+
sound?: Sound;
|
20
|
+
set sprite(sprite: Sprite<any>);
|
21
|
+
get sprite(): Sprite<any>;
|
22
|
+
get position(): Matter.Vector;
|
23
|
+
get body(): MasterBody;
|
24
|
+
get props(): P;
|
25
|
+
/**
|
26
|
+
* @param {TerminateOptions} options
|
27
|
+
* #duration: time to disappear from the world in seconds, default: 0.2 seconds
|
28
|
+
* #effect: effect to showing on duration time
|
29
|
+
* @void
|
30
|
+
*/
|
31
|
+
terminate(options?: TerminateOptions): void;
|
32
|
+
/**
|
33
|
+
* @param {number} interval in seconds
|
34
|
+
* @param {TimerJobListener} job function that run per #interval
|
35
|
+
* @void
|
36
|
+
*/
|
37
|
+
onTimer(interval: number, job: TimerJobListener, defaultRun?: boolean): () => void;
|
38
|
+
createBody(transform: CreateBodyDefine["transform"], options?: CreateBodyDefine["bodyOptions"]): MasterBody;
|
39
|
+
protected abstract onCreateBody(transform: CreateBodyDefine["transform"], options?: CreateBodyDefine["bodyOptions"]): Matter.Body;
|
40
|
+
initial({ transform, sprite: spriteComponent, bodyOptions, props, ...params }: EntityInitial<this>): void;
|
41
|
+
protected abstract onInitial(): EntityInitial<this>;
|
42
|
+
protected onPrepare(): EntityPrepare<this>;
|
43
|
+
update(): void;
|
44
|
+
onUpdate(): void;
|
45
|
+
draw(): void;
|
46
|
+
abstract onSpriteWidthHeightBinding(): {
|
47
|
+
width: number;
|
48
|
+
height: number;
|
49
|
+
};
|
50
|
+
onCollision(target: Entity): void;
|
51
|
+
onCollisionEnd(target: Entity): void;
|
52
|
+
onCollisionActive(target: Entity): void;
|
53
|
+
}
|
54
|
+
export {};
|
55
|
+
//# sourceMappingURL=entity.d.ts.map
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import { Body } from "matter-js";
|
2
|
+
import { CreateBodyDefine, EntityInitial } from "../../export-types";
|
3
|
+
import { Entity } from "./entity";
|
4
|
+
export declare class RectEntity<P extends Record<string, any> = any> extends Entity<P> {
|
5
|
+
width: number;
|
6
|
+
height: number;
|
7
|
+
onSpriteWidthHeightBinding(): {
|
8
|
+
width: number;
|
9
|
+
height: number;
|
10
|
+
};
|
11
|
+
protected onInitial(): EntityInitial<this>;
|
12
|
+
protected onCreateBody({ x, y, ...transform }: NonNullable<CreateBodyDefine<{
|
13
|
+
width?: number;
|
14
|
+
height?: number;
|
15
|
+
}>["transform"]>, options?: CreateBodyDefine["bodyOptions"]): Body;
|
16
|
+
}
|
17
|
+
//# sourceMappingURL=rect.entity.d.ts.map
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import { Avatar } from "../../export-types";
|
2
|
+
import { GetInitialParams, Sprite } from "./sprite";
|
3
|
+
declare type SpriteOffet = {
|
4
|
+
x: number;
|
5
|
+
y: number;
|
6
|
+
width: number;
|
7
|
+
height: number;
|
8
|
+
index: number;
|
9
|
+
};
|
10
|
+
declare type AvatarGetInitialParams<S extends AvatarSprite> = GetInitialParams<S> & {
|
11
|
+
offset?: Partial<SpriteOffet>;
|
12
|
+
};
|
13
|
+
export declare class AvatarSprite extends Sprite<Avatar | undefined | null> {
|
14
|
+
private _offset;
|
15
|
+
get offset(): SpriteOffet;
|
16
|
+
onDraw(): void;
|
17
|
+
initial(params?: AvatarGetInitialParams<this>): void;
|
18
|
+
}
|
19
|
+
export {};
|
20
|
+
//# sourceMappingURL=avatar.sprite.d.ts.map
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import { Avatar, Color } from "../../export-types";
|
2
|
+
import { AnimationSprite } from "../animations/animation";
|
3
|
+
import { Entity } from "../entities/entity";
|
4
|
+
import { LogicComponent } from "../logic-component";
|
5
|
+
export declare type SourceType = Avatar | Color | undefined | null;
|
6
|
+
export declare type GetInitialParams<S extends Sprite<any> = any> = {
|
7
|
+
source?: S["source"];
|
8
|
+
animation?: LogicComponent<AnimationSprite<S>>;
|
9
|
+
};
|
10
|
+
export declare abstract class Sprite<SpriteType extends SourceType> {
|
11
|
+
source: SpriteType;
|
12
|
+
private _entity;
|
13
|
+
private _width;
|
14
|
+
private _height;
|
15
|
+
private _animation;
|
16
|
+
set animation(ani: AnimationSprite<this>);
|
17
|
+
get animation(): AnimationSprite<this>;
|
18
|
+
set entity(entity: Entity);
|
19
|
+
get entity(): Entity;
|
20
|
+
get width(): number;
|
21
|
+
get height(): number;
|
22
|
+
draw(): void;
|
23
|
+
abstract onDraw(): void;
|
24
|
+
initial(params?: GetInitialParams<this>): void;
|
25
|
+
}
|
26
|
+
//# sourceMappingURL=sprite.d.ts.map
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "react-simple-game-engine",
|
3
|
-
"version": "0.1.
|
3
|
+
"version": "0.1.63",
|
4
4
|
"description": "",
|
5
5
|
"main": "lib/index.js",
|
6
6
|
"types": "lib",
|
@@ -22,6 +22,7 @@
|
|
22
22
|
},
|
23
23
|
"files": [
|
24
24
|
"/lib/index.js",
|
25
|
+
"/lib/*/**/***.d.ts",
|
25
26
|
"/lib/*/**.d.ts",
|
26
27
|
"/lib/*.d.ts"
|
27
28
|
],
|