kaplay 3001.0.1 → 3001.0.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.
Files changed (34) hide show
  1. package/README.md +3 -1
  2. package/dist/declaration/audio/playMusic.d.ts.map +1 -1
  3. package/dist/declaration/components/draw/ellipse.d.ts +32 -0
  4. package/dist/declaration/components/draw/ellipse.d.ts.map +1 -0
  5. package/dist/declaration/components/misc/fakeMouse.d.ts +37 -0
  6. package/dist/declaration/components/misc/fakeMouse.d.ts.map +1 -0
  7. package/dist/declaration/gfx/classes/FrameBuffer.d.ts +22 -0
  8. package/dist/declaration/gfx/classes/FrameBuffer.d.ts.map +1 -0
  9. package/dist/declaration/gfx/classes/TexPacker.d.ts +20 -0
  10. package/dist/declaration/gfx/classes/TexPacker.d.ts.map +1 -0
  11. package/dist/declaration/gfx/formatText.d.ts.map +1 -1
  12. package/dist/declaration/math/gjk.d.ts +27 -0
  13. package/dist/declaration/math/gjk.d.ts.map +1 -0
  14. package/dist/declaration/math/sat.d.ts +7 -0
  15. package/dist/declaration/math/sat.d.ts.map +1 -0
  16. package/dist/declaration/math/spatial/hashgrid.d.ts +2 -0
  17. package/dist/declaration/math/spatial/hashgrid.d.ts.map +1 -0
  18. package/dist/declaration/math/spatial/sweepandprune.d.ts +40 -0
  19. package/dist/declaration/math/spatial/sweepandprune.d.ts.map +1 -0
  20. package/dist/declaration/math/vec3.d.ts +9 -0
  21. package/dist/declaration/math/vec3.d.ts.map +1 -0
  22. package/dist/kaboom.cjs +1 -1
  23. package/dist/kaboom.cjs.map +2 -2
  24. package/dist/kaboom.js +1 -1
  25. package/dist/kaboom.js.map +2 -2
  26. package/dist/kaboom.mjs +1 -1
  27. package/dist/kaboom.mjs.map +2 -2
  28. package/dist/kaplay.cjs +1 -1
  29. package/dist/kaplay.cjs.map +2 -2
  30. package/dist/kaplay.js +1 -1
  31. package/dist/kaplay.js.map +2 -2
  32. package/dist/kaplay.mjs +1 -1
  33. package/dist/kaplay.mjs.map +2 -2
  34. package/package.json +1 -1
package/README.md CHANGED
@@ -189,7 +189,9 @@ Collections of games made with KAPLAY (and Kaboom), selected by KAPLAY:
189
189
  Kaboom.js
190
190
  - Thanks to [mulfok](https://twitter.com/MulfoK) for the amazing
191
191
  [mulfok32](https://lospec.com/palette-list/mulfok32) color palette, used in
192
- KAPLAY sprites
192
+ KAPLAY sprites and art in general
193
+ - Thansk to [Kenney](https://kenney.nl/) for all used assets for examples
194
+ - [Impact Sound Pack](https://kenney.nl/assets/impact-sounds)
193
195
  - Thanks to [abrudz](https://github.com/abrudz) for the amazing
194
196
  [APL386 font](https://abrudz.github.io/APL386/)
195
197
  - Thanks to [Polyducks](http://polyducks.co.uk/) for the amazing
@@ -1 +1 @@
1
- {"version":3,"file":"playMusic.d.ts","sourceRoot":"","sources":["../../../src/audio/playMusic.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtD,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,GAAE,YAAiB,GAAG,SAAS,CAoGxE"}
1
+ {"version":3,"file":"playMusic.d.ts","sourceRoot":"","sources":["../../../src/audio/playMusic.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtD,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,GAAE,YAAiB,GAAG,SAAS,CAqGxE"}
@@ -0,0 +1,32 @@
1
+ import { Ellipse } from "../../math/math";
2
+ import type { Comp } from "../../types";
3
+ /**
4
+ * The {@link ellipse `ellipse()`} component.
5
+ *
6
+ * @group Component Types
7
+ */
8
+ export interface EllipseComp extends Comp {
9
+ draw: Comp["draw"];
10
+ /** Semi-major axis of ellipse. */
11
+ radiusX: number;
12
+ /** Semi-minor axis of ellipse. */
13
+ radiusY: number;
14
+ /**
15
+ * Render area of the ellipse.
16
+ */
17
+ renderArea(): Ellipse;
18
+ }
19
+ /**
20
+ * Options for the {@link ellipse `ellipse()``} component.
21
+ *
22
+ * @group Component Types
23
+ */
24
+ export interface EllipseCompOpt {
25
+ /**
26
+ * If fill is false, the ellipse is not filled (useful if you only want to render outline with
27
+ * {@link outline `outline()`} component).
28
+ */
29
+ fill?: boolean;
30
+ }
31
+ export declare function ellipse(radiusX: number, radiusY: number, opt?: EllipseCompOpt): EllipseComp;
32
+ //# sourceMappingURL=ellipse.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ellipse.d.ts","sourceRoot":"","sources":["../../../../src/components/draw/ellipse.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAc,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EAAE,IAAI,EAAW,MAAM,aAAa,CAAC;AAIjD;;;;GAIG;AACH,MAAM,WAAW,WAAY,SAAQ,IAAI;IACrC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IACnB,kCAAkC;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,kCAAkC;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,UAAU,IAAI,OAAO,CAAC;CACzB;AAED;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC3B;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,wBAAgB,OAAO,CACnB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,GAAG,GAAE,cAAmB,GACzB,WAAW,CAyBb"}
@@ -0,0 +1,37 @@
1
+ import type { Comp } from "../../types";
2
+ /**
3
+ * The {@link fakeMouse `fakeMouse()`} component.
4
+ */
5
+ export interface FakeMouseComp extends Comp {
6
+ /**
7
+ * Whether the fake mouse is pressed.
8
+ */
9
+ get isPressed(): boolean;
10
+ /**
11
+ * Trigger press (onClick).
12
+ */
13
+ press(): void;
14
+ /**
15
+ * Trigger release.
16
+ */
17
+ release(): void;
18
+ /**
19
+ * Register an event that runs when the fake mouse performs a click.
20
+ */
21
+ onPress(action: () => void): void;
22
+ /**
23
+ * Register an event that runs when the fake mouse releases.
24
+ */
25
+ onRelease(action: () => void): void;
26
+ }
27
+ /**
28
+ * Options for the {@link fakeMouse `fakeMouse()`} component.
29
+ */
30
+ export type FakeMouseOpt = {
31
+ /**
32
+ * Whether the fake mouse should follow the real mouse. Defaults to `true`.
33
+ */
34
+ followMouse?: boolean;
35
+ };
36
+ export declare const fakeMouse: (opt?: FakeMouseOpt) => FakeMouseComp;
37
+ //# sourceMappingURL=fakeMouse.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fakeMouse.d.ts","sourceRoot":"","sources":["../../../../src/components/misc/fakeMouse.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAW,MAAM,aAAa,CAAC;AAGjD;;GAEG;AACH,MAAM,WAAW,aAAc,SAAQ,IAAI;IACvC;;OAEG;IACH,IAAI,SAAS,IAAI,OAAO,CAAC;IACzB;;OAEG;IACH,KAAK,IAAI,IAAI,CAAC;IACd;;OAEG;IACH,OAAO,IAAI,IAAI,CAAC;IAChB;;OAEG;IACH,OAAO,CAAC,MAAM,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;IAClC;;OAEG;IACH,SAAS,CAAC,MAAM,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;CACvC;AAED;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG;IACvB;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAIF,eAAO,MAAM,SAAS,SAAS,YAAY,KAEvC,aA+BH,CAAC"}
@@ -0,0 +1,22 @@
1
+ import type { TextureOpt } from "../../types";
2
+ import { type GfxCtx, Texture } from "../gfx";
3
+ /**
4
+ * @group GFX
5
+ */
6
+ export declare class FrameBuffer {
7
+ ctx: GfxCtx;
8
+ tex: Texture;
9
+ glFramebuffer: WebGLFramebuffer;
10
+ glRenderbuffer: WebGLRenderbuffer;
11
+ constructor(ctx: GfxCtx, w: number, h: number, opt?: TextureOpt);
12
+ get width(): number;
13
+ get height(): number;
14
+ toImageData(): ImageData;
15
+ toDataURL(): string;
16
+ clear(): void;
17
+ draw(action: () => void): void;
18
+ bind(): void;
19
+ unbind(): void;
20
+ free(): void;
21
+ }
22
+ //# sourceMappingURL=FrameBuffer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FrameBuffer.d.ts","sourceRoot":"","sources":["../../../../src/gfx/classes/FrameBuffer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,KAAK,MAAM,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAE9C;;GAEG;AAEH,qBAAa,WAAW;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,OAAO,CAAC;IACb,aAAa,EAAE,gBAAgB,CAAC;IAChC,cAAc,EAAE,iBAAiB,CAAC;gBAEtB,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,GAAG,GAAE,UAAe;IAkCnE,IAAI,KAAK,WAER;IAED,IAAI,MAAM,WAET;IAED,WAAW;IA+BX,SAAS;IAYT,KAAK;IAKL,IAAI,CAAC,MAAM,EAAE,MAAM,IAAI;IAMvB,IAAI;IAMJ,MAAM;IAMN,IAAI;CAMP"}
@@ -0,0 +1,20 @@
1
+ import { Quad } from "../../math/math";
2
+ import type { ImageSource } from "../../types";
3
+ import { type GfxCtx, Texture } from "..";
4
+ export default class TexPacker {
5
+ private lastTextureId;
6
+ private textures;
7
+ private bigTextures;
8
+ private texturesPosition;
9
+ private canvas;
10
+ private c2d;
11
+ private x;
12
+ private y;
13
+ private curHeight;
14
+ private gfx;
15
+ constructor(gfx: GfxCtx, w: number, h: number);
16
+ add(img: ImageSource): [Texture, Quad, number];
17
+ free(): void;
18
+ remove(packerId: number): void;
19
+ }
20
+ //# sourceMappingURL=TexPacker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TexPacker.d.ts","sourceRoot":"","sources":["../../../../src/gfx/classes/TexPacker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAQ,MAAM,iBAAiB,CAAC;AAC7C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,KAAK,MAAM,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAE1C,MAAM,CAAC,OAAO,OAAO,SAAS;IAC1B,OAAO,CAAC,aAAa,CAAa;IAClC,OAAO,CAAC,QAAQ,CAAiB;IACjC,OAAO,CAAC,WAAW,CAAiB;IACpC,OAAO,CAAC,gBAAgB,CAIT;IACf,OAAO,CAAC,MAAM,CAAoB;IAClC,OAAO,CAAC,GAAG,CAA2B;IACtC,OAAO,CAAC,CAAC,CAAa;IACtB,OAAO,CAAC,CAAC,CAAa;IACtB,OAAO,CAAC,SAAS,CAAa;IAC9B,OAAO,CAAC,GAAG,CAAS;gBAER,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM;IAc7C,GAAG,CAAC,GAAG,EAAE,WAAW,GAAG,CAAC,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC;IA8D9C,IAAI;IAQJ,MAAM,CAAC,QAAQ,EAAE,MAAM;CAkB1B"}
@@ -1 +1 @@
1
- {"version":3,"file":"formatText.d.ts","sourceRoot":"","sources":["../../../src/gfx/formatText.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAER,WAAW,EAEX,aAAa,EAChB,MAAM,QAAQ,CAAC;AAsBhB,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG;IAC5C,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IACvC,IAAI,EAAE,MAAM,CAAC;CAChB,CAwDA;AAED,wBAAgB,UAAU,CAAC,GAAG,EAAE,WAAW,GAAG,aAAa,CAmS1D"}
1
+ {"version":3,"file":"formatText.d.ts","sourceRoot":"","sources":["../../../src/gfx/formatText.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAER,WAAW,EAEX,aAAa,EAChB,MAAM,QAAQ,CAAC;AAsBhB,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG;IAC5C,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IACvC,IAAI,EAAE,MAAM,CAAC;CAChB,CAgEA;AAED,wBAAgB,UAAU,CAAC,GAAG,EAAE,WAAW,GAAG,aAAa,CAwS1D"}
@@ -0,0 +1,27 @@
1
+ import type { Shape } from "../types";
2
+ import { Vec2 } from "./math";
3
+ export type GjkCollisionResult = {
4
+ /**
5
+ * The direction the first shape needs to be moved to resolve the collision
6
+ */
7
+ normal: Vec2;
8
+ /**
9
+ * The distance the first shape needs to be moved to resolve the collision
10
+ */
11
+ distance: number;
12
+ };
13
+ /**
14
+ * Returns true if the shapes collide
15
+ * @param shapeA The first shape to test
16
+ * @param shapeB The second shape to test
17
+ * @returns True if the shapes collide
18
+ */
19
+ export declare function gjkShapeIntersects(shapeA: Shape, shapeB: Shape): boolean;
20
+ /**
21
+ * Returns a collision result if there was a collision
22
+ * @param shapeA The first shape to test
23
+ * @param shapeB The second shape to test
24
+ * @returns A collision result or null
25
+ */
26
+ export declare function gjkShapeIntersection(shapeA: Shape, shapeB: Shape): GjkCollisionResult | null;
27
+ //# sourceMappingURL=gjk.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gjk.d.ts","sourceRoot":"","sources":["../../../src/math/gjk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAkC,IAAI,EAAQ,MAAM,QAAQ,CAAC;AA0QpE,MAAM,MAAM,kBAAkB,GAAG;IAC7B;;OAEG;IACH,MAAM,EAAE,IAAI,CAAC;IACb;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;CACpB,CAAC;AAqHF;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,GAAG,OAAO,CAIxE;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAChC,MAAM,EAAE,KAAK,EACb,MAAM,EAAE,KAAK,GACd,kBAAkB,GAAG,IAAI,CAI3B"}
@@ -0,0 +1,7 @@
1
+ import { type Polygon, Vec2 } from "./math";
2
+ export type SatResult = {
3
+ normal: Vec2;
4
+ distance: number;
5
+ };
6
+ export declare function sat(p1: Polygon, p2: Polygon): SatResult | null;
7
+ //# sourceMappingURL=sat.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sat.d.ts","sourceRoot":"","sources":["../../../src/math/sat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,IAAI,EAAQ,MAAM,QAAQ,CAAC;AAElD,MAAM,MAAM,SAAS,GAAG;IACpB,MAAM,EAAE,IAAI,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,wBAAgB,GAAG,CAAC,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,OAAO,GAAG,SAAS,GAAG,IAAI,CAoC9D"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=hashgrid.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hashgrid.d.ts","sourceRoot":"","sources":["../../../../src/math/spatial/hashgrid.ts"],"names":[],"mappings":""}
@@ -0,0 +1,40 @@
1
+ import type { AreaComp } from "../../components";
2
+ import type { GameObj } from "../../types";
3
+ /**
4
+ * Left or right edge of an object's bbox
5
+ */
6
+ declare class Edge {
7
+ obj: GameObj<AreaComp>;
8
+ x: number;
9
+ isLeft: boolean;
10
+ constructor(obj: GameObj<AreaComp>, isLeft: boolean);
11
+ }
12
+ /**
13
+ * One dimensional sweep and prune
14
+ */
15
+ export declare class SweepAndPrune {
16
+ edges: Array<Edge>;
17
+ objects: Map<GameObj<AreaComp>, [Edge, Edge]>;
18
+ constructor();
19
+ /**
20
+ * Add the object and its edges to the list
21
+ * @param obj The object to add
22
+ */
23
+ add(obj: GameObj<AreaComp>): void;
24
+ /**
25
+ * Remove the object and its edges from the list
26
+ * @param obj The object to remove
27
+ */
28
+ remove(obj: GameObj<AreaComp>): void;
29
+ clear(): void;
30
+ /**
31
+ * Update edges and sort
32
+ */
33
+ update(): void;
34
+ /**
35
+ * Iterates all object pairs which potentially collide
36
+ */
37
+ [Symbol.iterator](): Generator<GameObj<AreaComp>[], void, unknown>;
38
+ }
39
+ export {};
40
+ //# sourceMappingURL=sweepandprune.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sweepandprune.d.ts","sourceRoot":"","sources":["../../../../src/math/spatial/sweepandprune.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAG3C;;GAEG;AACH,cAAM,IAAI;IACN,GAAG,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;IACvB,CAAC,EAAE,MAAM,CAAC;IACV,MAAM,EAAE,OAAO,CAAC;gBAEJ,GAAG,EAAE,OAAO,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,OAAO;CAKtD;AAED;;GAEG;AACH,qBAAa,aAAa;IACtB,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;IACnB,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;;IAO9C;;;OAGG;IACH,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,QAAQ,CAAC;IAQ1B;;;OAGG;IACH,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,QAAQ,CAAC;IAS7B,KAAK;IAKL;;OAEG;IACH,MAAM;IAoBN;;OAEG;IACF,CAAC,MAAM,CAAC,QAAQ,CAAC;CAerB"}
@@ -0,0 +1,9 @@
1
+ export declare class Vec3 {
2
+ x: number;
3
+ y: number;
4
+ z: number;
5
+ constructor(x: number, y: number, z: number);
6
+ dot(other: Vec3): number;
7
+ cross(other: Vec3): Vec3;
8
+ }
9
+ //# sourceMappingURL=vec3.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vec3.d.ts","sourceRoot":"","sources":["../../../src/math/vec3.ts"],"names":[],"mappings":"AAAA,qBAAa,IAAI;IACb,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;gBACE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM;IAM3C,GAAG,CAAC,KAAK,EAAE,IAAI;IAIf,KAAK,CAAC,KAAK,EAAE,IAAI;CAOpB"}