@hi-ashleyj/llama 0.9.0 → 0.10.0
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/README.md +29 -0
- package/dist/Game.svelte +123 -0
- package/{components → dist}/Game.svelte.d.ts +4 -4
- package/dist/GameObject.svelte +38 -0
- package/{components → dist}/GameObject.svelte.d.ts +2 -2
- package/dist/Layer.svelte +58 -0
- package/{components → dist}/Layer.svelte.d.ts +3 -2
- package/dist/controllers/MouseClickable.svelte +50 -0
- package/{components/mouse → dist/controllers}/MouseClickable.svelte.d.ts +2 -2
- package/dist/controllers/MouseEventArea.svelte +58 -0
- package/{components/mouse → dist/controllers}/MouseEventArea.svelte.d.ts +7 -3
- package/{components/controller.d.ts → dist/controllers/keyboard.d.ts} +6 -6
- package/{components/controller.js → dist/controllers/keyboard.js} +9 -9
- package/{components → dist/controllers}/mouse.d.ts +5 -1
- package/{components → dist/controllers}/mouse.js +24 -6
- package/dist/core-contexts.d.ts +48 -0
- package/{setup.js → dist/core-contexts.js} +7 -19
- package/dist/drawable.d.ts +14 -0
- package/dist/drawable.js +13 -0
- package/dist/drawables/Arc.svelte +31 -0
- package/{components → dist}/drawables/Arc.svelte.d.ts +2 -2
- package/dist/drawables/Circle.svelte +25 -0
- package/{components → dist}/drawables/Circle.svelte.d.ts +2 -2
- package/dist/drawables/DisplayImage.svelte +17 -0
- package/{components → dist}/drawables/DisplayImage.svelte.d.ts +2 -2
- package/dist/drawables/MultiLineText.svelte +43 -0
- package/{components → dist}/drawables/MultiLineText.svelte.d.ts +4 -4
- package/dist/drawables/Rectangle.svelte +22 -0
- package/{components → dist}/drawables/Rectangle.svelte.d.ts +2 -2
- package/dist/drawables/RoundedRectangle.svelte +24 -0
- package/{components → dist}/drawables/RoundedRectangle.svelte.d.ts +2 -2
- package/dist/drawables/Text.svelte +37 -0
- package/{components → dist}/drawables/Text.svelte.d.ts +4 -4
- package/dist/extras/Empty.svelte +0 -0
- package/dist/extras/Empty.svelte.d.ts +18 -0
- package/dist/extras/LayerPortal.svelte +24 -0
- package/dist/extras/LayerPortal.svelte.d.ts +18 -0
- package/dist/extras/Rotate.svelte +25 -0
- package/dist/extras/Rotate.svelte.d.ts +22 -0
- package/dist/extras/SceneSwitcher.svelte +20 -0
- package/dist/extras/SceneSwitcher.svelte.d.ts +16 -0
- package/dist/extras/SceneTransition.svelte +40 -0
- package/dist/extras/SceneTransition.svelte.d.ts +21 -0
- package/dist/extras/SensibleDefaultStyles.svelte +22 -0
- package/dist/extras/SensibleDefaultStyles.svelte.d.ts +20 -0
- package/dist/extras/Tweened.svelte +9 -0
- package/dist/extras/Tweened.svelte.d.ts +21 -0
- package/dist/extras/scenes.d.ts +6 -0
- package/dist/extras/scenes.js +22 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +24 -0
- package/package.json +26 -29
- package/components/Game.svelte +0 -116
- package/components/GameObject.svelte +0 -40
- package/components/Layer.svelte +0 -47
- package/components/drawables/Arc.svelte +0 -29
- package/components/drawables/Circle.svelte +0 -25
- package/components/drawables/DisplayImage.svelte +0 -17
- package/components/drawables/MultiLineText.svelte +0 -45
- package/components/drawables/Rectangle.svelte +0 -22
- package/components/drawables/RoundedRectangle.svelte +0 -24
- package/components/drawables/Text.svelte +0 -36
- package/components/mouse/MouseClickable.svelte +0 -49
- package/components/mouse/MouseEventArea.svelte +0 -55
- package/components/mouse/MouseLeftClick.svelte +0 -33
- package/components/mouse/MouseLeftClick.svelte.d.ts +0 -16
- package/drawables.d.ts +0 -1
- package/drawables.js +0 -1
- package/index.d.ts +0 -12
- package/index.js +0 -11
- package/resources.d.ts +0 -1
- package/resources.js +0 -1
- package/setup.d.ts +0 -12
- package/types/contexts.d.ts +0 -35
- package/types/index.d.ts +0 -1
- /package/{components → dist/controllers}/motions.d.ts +0 -0
- /package/{components → dist/controllers}/motions.js +0 -0
- /package/{components → dist}/drawables/index.d.ts +0 -0
- /package/{components → dist}/drawables/index.js +0 -0
- /package/{components → dist}/resources/images.d.ts +0 -0
- /package/{components → dist}/resources/images.js +0 -0
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { getContext, setContext } from 'svelte';
|
|
2
|
+
import { setupDrawable } from './drawable';
|
|
2
3
|
const GAME = Symbol();
|
|
3
|
-
const LAYER = Symbol();
|
|
4
|
-
const DRAWABLE = Symbol();
|
|
5
|
-
const BOX = Symbol();
|
|
6
4
|
export const setupGame = function (context) {
|
|
7
5
|
if (getContext(GAME)) {
|
|
8
6
|
throw new Error("Cannot Mount Game inside a Game");
|
|
9
7
|
}
|
|
10
8
|
setContext(GAME, context);
|
|
11
9
|
};
|
|
10
|
+
export const getGame = function () {
|
|
11
|
+
return getContext(GAME);
|
|
12
|
+
};
|
|
13
|
+
const LAYER = Symbol();
|
|
12
14
|
export const setupLayer = function (context) {
|
|
13
15
|
if (getContext(LAYER)) {
|
|
14
16
|
throw new Error("Cannot Mount Layer inside a Layer");
|
|
@@ -18,8 +20,8 @@ export const setupLayer = function (context) {
|
|
|
18
20
|
throw new Error("Layers must be inside a Game");
|
|
19
21
|
setContext(LAYER, context);
|
|
20
22
|
setupDrawable({ assign: context.assign });
|
|
21
|
-
return (
|
|
22
|
-
return game.assign(
|
|
23
|
+
return (obj) => {
|
|
24
|
+
return game.assign(context, obj);
|
|
23
25
|
};
|
|
24
26
|
};
|
|
25
27
|
export const getLayer = function () {
|
|
@@ -32,17 +34,3 @@ export const getTriggerLayerRender = function () {
|
|
|
32
34
|
let layer = getLayer();
|
|
33
35
|
return layer.requestFrame;
|
|
34
36
|
};
|
|
35
|
-
export const setupDrawable = function ({ assign }) {
|
|
36
|
-
let parent = getContext(DRAWABLE);
|
|
37
|
-
if (assign) {
|
|
38
|
-
setContext(DRAWABLE, { assign });
|
|
39
|
-
}
|
|
40
|
-
return (ctx) => {
|
|
41
|
-
if (!parent)
|
|
42
|
-
return () => { };
|
|
43
|
-
return parent.assign(ctx);
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
export const getGame = function () {
|
|
47
|
-
return getContext(GAME);
|
|
48
|
-
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { RegisterFunction } from "./core-contexts.d.ts";
|
|
2
|
+
export type DrawableContext<Options> = {
|
|
3
|
+
assign?: RegisterFunction<DrawableObject<Options>>;
|
|
4
|
+
};
|
|
5
|
+
export type DrawableObject<Options> = {
|
|
6
|
+
draw: DrawFunction<Options>;
|
|
7
|
+
};
|
|
8
|
+
export type CoreLayerOptions = {
|
|
9
|
+
width: number;
|
|
10
|
+
height: number;
|
|
11
|
+
ctx: CanvasRenderingContext2D;
|
|
12
|
+
};
|
|
13
|
+
export type DrawFunction<Options> = Options extends null ? (core: CoreLayerOptions) => void | any : (core: CoreLayerOptions, more: Options) => void | any;
|
|
14
|
+
export declare const setupDrawable: <TParent, TChildren>({ assign }: DrawableContext<TChildren>) => RegisterFunction<DrawableObject<TParent>>;
|
package/dist/drawable.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { getContext, setContext } from "svelte";
|
|
2
|
+
const DRAWABLE = Symbol();
|
|
3
|
+
export const setupDrawable = function ({ assign }) {
|
|
4
|
+
let parent = getContext(DRAWABLE);
|
|
5
|
+
if (assign) {
|
|
6
|
+
setContext(DRAWABLE, { assign });
|
|
7
|
+
}
|
|
8
|
+
return (obj) => {
|
|
9
|
+
if (!parent)
|
|
10
|
+
return () => { };
|
|
11
|
+
return parent.assign(obj);
|
|
12
|
+
};
|
|
13
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<script>import { setupDrawable } from "../drawable.js";
|
|
2
|
+
import { onMount } from "svelte";
|
|
3
|
+
export let fill = null;
|
|
4
|
+
export let stroke = null;
|
|
5
|
+
export let strokeWidth = null;
|
|
6
|
+
export let startAngle;
|
|
7
|
+
export let endAngle;
|
|
8
|
+
$:
|
|
9
|
+
sd = (startAngle - 90) * Math.PI / 180;
|
|
10
|
+
$:
|
|
11
|
+
ed = (endAngle - 90) * Math.PI / 180;
|
|
12
|
+
const draw = function({ ctx }, { x, y, w, h }) {
|
|
13
|
+
let r = (w + h) / 4;
|
|
14
|
+
ctx.beginPath();
|
|
15
|
+
ctx.arc(x + r, y + r, r, sd, ed);
|
|
16
|
+
ctx.lineTo(x + r, y + r);
|
|
17
|
+
if (fill) {
|
|
18
|
+
ctx.fillStyle = fill;
|
|
19
|
+
ctx.fill();
|
|
20
|
+
}
|
|
21
|
+
if (stroke && strokeWidth) {
|
|
22
|
+
ctx.strokeStyle = stroke;
|
|
23
|
+
ctx.lineWidth = strokeWidth;
|
|
24
|
+
ctx.stroke();
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
let register = setupDrawable({});
|
|
28
|
+
onMount(() => {
|
|
29
|
+
return register({ draw });
|
|
30
|
+
});
|
|
31
|
+
</script>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
2
|
declare const __propDef: {
|
|
3
3
|
props: {
|
|
4
4
|
fill?: string | null | undefined;
|
|
@@ -15,6 +15,6 @@ declare const __propDef: {
|
|
|
15
15
|
export type ArcProps = typeof __propDef.props;
|
|
16
16
|
export type ArcEvents = typeof __propDef.events;
|
|
17
17
|
export type ArcSlots = typeof __propDef.slots;
|
|
18
|
-
export default class Arc extends
|
|
18
|
+
export default class Arc extends SvelteComponent<ArcProps, ArcEvents, ArcSlots> {
|
|
19
19
|
}
|
|
20
20
|
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<script>import { setupDrawable } from "../drawable.js";
|
|
2
|
+
import { onMount } from "svelte";
|
|
3
|
+
export let fill = null;
|
|
4
|
+
export let stroke = null;
|
|
5
|
+
export let strokeWidth = null;
|
|
6
|
+
const TWO_PI = Math.PI * 2;
|
|
7
|
+
const draw = function({ ctx }, { x, y, w, h }) {
|
|
8
|
+
let r = (w + h) / 4;
|
|
9
|
+
ctx.beginPath();
|
|
10
|
+
ctx.arc(x + r, y + r, r, 0, TWO_PI);
|
|
11
|
+
if (fill) {
|
|
12
|
+
ctx.fillStyle = fill;
|
|
13
|
+
ctx.fill();
|
|
14
|
+
}
|
|
15
|
+
if (stroke && strokeWidth) {
|
|
16
|
+
ctx.strokeStyle = stroke;
|
|
17
|
+
ctx.lineWidth = strokeWidth;
|
|
18
|
+
ctx.stroke();
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
let register = setupDrawable({});
|
|
22
|
+
onMount(() => {
|
|
23
|
+
return register({ draw });
|
|
24
|
+
});
|
|
25
|
+
</script>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
2
|
declare const __propDef: {
|
|
3
3
|
props: {
|
|
4
4
|
fill?: string | null | undefined;
|
|
@@ -13,6 +13,6 @@ declare const __propDef: {
|
|
|
13
13
|
export type CircleProps = typeof __propDef.props;
|
|
14
14
|
export type CircleEvents = typeof __propDef.events;
|
|
15
15
|
export type CircleSlots = typeof __propDef.slots;
|
|
16
|
-
export default class Circle extends
|
|
16
|
+
export default class Circle extends SvelteComponent<CircleProps, CircleEvents, CircleSlots> {
|
|
17
17
|
}
|
|
18
18
|
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<script>import { setupDrawable } from "../drawable.js";
|
|
2
|
+
import { onMount } from "svelte";
|
|
3
|
+
export let image = null;
|
|
4
|
+
export let crop = null;
|
|
5
|
+
const draw = function({ ctx }, { x, y, w, h }) {
|
|
6
|
+
if (!image)
|
|
7
|
+
return;
|
|
8
|
+
if (crop) {
|
|
9
|
+
return ctx.drawImage(image, crop.x, crop.y, crop.w, crop.h, x, y, w, h);
|
|
10
|
+
}
|
|
11
|
+
ctx.drawImage(image, x, y, w, h);
|
|
12
|
+
};
|
|
13
|
+
let register = setupDrawable({});
|
|
14
|
+
onMount(() => {
|
|
15
|
+
return register({ draw });
|
|
16
|
+
});
|
|
17
|
+
</script>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
2
|
declare const __propDef: {
|
|
3
3
|
props: {
|
|
4
4
|
image?: HTMLImageElement | null | undefined;
|
|
@@ -17,6 +17,6 @@ declare const __propDef: {
|
|
|
17
17
|
export type DisplayImageProps = typeof __propDef.props;
|
|
18
18
|
export type DisplayImageEvents = typeof __propDef.events;
|
|
19
19
|
export type DisplayImageSlots = typeof __propDef.slots;
|
|
20
|
-
export default class DisplayImage extends
|
|
20
|
+
export default class DisplayImage extends SvelteComponent<DisplayImageProps, DisplayImageEvents, DisplayImageSlots> {
|
|
21
21
|
}
|
|
22
22
|
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<script>import { setupDrawable } from "../drawable.js";
|
|
2
|
+
import { onMount } from "svelte";
|
|
3
|
+
export let text;
|
|
4
|
+
export let size;
|
|
5
|
+
export let spacing = 1.4;
|
|
6
|
+
export let font;
|
|
7
|
+
export let style = void 0;
|
|
8
|
+
export let fill = void 0;
|
|
9
|
+
export let stroke = void 0;
|
|
10
|
+
export let strokeWidth = null;
|
|
11
|
+
export let alignH = "left";
|
|
12
|
+
export let alignV = "top";
|
|
13
|
+
$:
|
|
14
|
+
computedFont = (style ? style + " " : "") + size + "px " + font;
|
|
15
|
+
$:
|
|
16
|
+
splits = text?.split("\n") || [];
|
|
17
|
+
$:
|
|
18
|
+
offset = alignV === "bottom" ? ((splits?.length || 1) - 1) * size * spacing : alignV === "middle" ? ((splits?.length || 1) - 1) * size * spacing * 0.5 : 0;
|
|
19
|
+
const draw = function({ ctx }, { x, y }) {
|
|
20
|
+
if (!splits)
|
|
21
|
+
return;
|
|
22
|
+
for (let i = 0; i < splits.length; i++) {
|
|
23
|
+
const line = splits[i];
|
|
24
|
+
ctx.beginPath();
|
|
25
|
+
ctx.textAlign = alignH;
|
|
26
|
+
ctx.textBaseline = alignV;
|
|
27
|
+
ctx.font = computedFont;
|
|
28
|
+
if (fill) {
|
|
29
|
+
ctx.fillStyle = fill;
|
|
30
|
+
ctx.fillText(line, x, y + size * spacing * i - offset);
|
|
31
|
+
}
|
|
32
|
+
if (stroke && strokeWidth) {
|
|
33
|
+
ctx.strokeStyle = stroke;
|
|
34
|
+
ctx.lineWidth = strokeWidth;
|
|
35
|
+
ctx.strokeText(line, x, y + size * spacing * i - offset);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
let register = setupDrawable({});
|
|
40
|
+
onMount(() => {
|
|
41
|
+
return register({ draw });
|
|
42
|
+
});
|
|
43
|
+
</script>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
2
|
declare const __propDef: {
|
|
3
3
|
props: {
|
|
4
4
|
text: string;
|
|
@@ -9,8 +9,8 @@ declare const __propDef: {
|
|
|
9
9
|
fill?: string | undefined;
|
|
10
10
|
stroke?: string | undefined;
|
|
11
11
|
strokeWidth?: number | null | undefined;
|
|
12
|
-
alignH?: "
|
|
13
|
-
alignV?: "
|
|
12
|
+
alignH?: "center" | "left" | "right" | undefined;
|
|
13
|
+
alignV?: "alphabetic" | "bottom" | "middle" | "top" | undefined;
|
|
14
14
|
};
|
|
15
15
|
events: {
|
|
16
16
|
[evt: string]: CustomEvent<any>;
|
|
@@ -20,6 +20,6 @@ declare const __propDef: {
|
|
|
20
20
|
export type MultiLineTextProps = typeof __propDef.props;
|
|
21
21
|
export type MultiLineTextEvents = typeof __propDef.events;
|
|
22
22
|
export type MultiLineTextSlots = typeof __propDef.slots;
|
|
23
|
-
export default class MultiLineText extends
|
|
23
|
+
export default class MultiLineText extends SvelteComponent<MultiLineTextProps, MultiLineTextEvents, MultiLineTextSlots> {
|
|
24
24
|
}
|
|
25
25
|
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<script>import { setupDrawable } from "../drawable.js";
|
|
2
|
+
import { onMount } from "svelte";
|
|
3
|
+
export let fill = null;
|
|
4
|
+
export let stroke = null;
|
|
5
|
+
export let strokeWidth = null;
|
|
6
|
+
const draw = function({ ctx }, { x, y, w, h }) {
|
|
7
|
+
ctx.beginPath();
|
|
8
|
+
ctx.rect(x, y, w, h);
|
|
9
|
+
if (fill) {
|
|
10
|
+
ctx.fillStyle = fill;
|
|
11
|
+
ctx.fill();
|
|
12
|
+
}
|
|
13
|
+
if (stroke && strokeWidth) {
|
|
14
|
+
ctx.strokeStyle = stroke;
|
|
15
|
+
ctx.stroke();
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
let register = setupDrawable({});
|
|
19
|
+
onMount(() => {
|
|
20
|
+
return register({ draw });
|
|
21
|
+
});
|
|
22
|
+
</script>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
2
|
declare const __propDef: {
|
|
3
3
|
props: {
|
|
4
4
|
fill?: string | null | undefined;
|
|
@@ -13,6 +13,6 @@ declare const __propDef: {
|
|
|
13
13
|
export type RectangleProps = typeof __propDef.props;
|
|
14
14
|
export type RectangleEvents = typeof __propDef.events;
|
|
15
15
|
export type RectangleSlots = typeof __propDef.slots;
|
|
16
|
-
export default class Rectangle extends
|
|
16
|
+
export default class Rectangle extends SvelteComponent<RectangleProps, RectangleEvents, RectangleSlots> {
|
|
17
17
|
}
|
|
18
18
|
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<script>import { setupDrawable } from "../drawable.js";
|
|
2
|
+
import { onMount } from "svelte";
|
|
3
|
+
export let fill = null;
|
|
4
|
+
export let stroke = null;
|
|
5
|
+
export let strokeWidth = null;
|
|
6
|
+
export let radius = 0;
|
|
7
|
+
const draw = function({ ctx }, { x, y, w, h }) {
|
|
8
|
+
ctx.beginPath();
|
|
9
|
+
ctx.roundRect(x, y, w, h, radius);
|
|
10
|
+
if (fill) {
|
|
11
|
+
ctx.fillStyle = fill;
|
|
12
|
+
ctx.fill();
|
|
13
|
+
}
|
|
14
|
+
if (stroke && strokeWidth) {
|
|
15
|
+
ctx.strokeStyle = stroke;
|
|
16
|
+
ctx.lineWidth = strokeWidth;
|
|
17
|
+
ctx.stroke();
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
let register = setupDrawable({});
|
|
21
|
+
onMount(() => {
|
|
22
|
+
return register({ draw });
|
|
23
|
+
});
|
|
24
|
+
</script>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
2
|
declare const __propDef: {
|
|
3
3
|
props: {
|
|
4
4
|
fill?: string | null | undefined;
|
|
@@ -14,6 +14,6 @@ declare const __propDef: {
|
|
|
14
14
|
export type RoundedRectangleProps = typeof __propDef.props;
|
|
15
15
|
export type RoundedRectangleEvents = typeof __propDef.events;
|
|
16
16
|
export type RoundedRectangleSlots = typeof __propDef.slots;
|
|
17
|
-
export default class RoundedRectangle extends
|
|
17
|
+
export default class RoundedRectangle extends SvelteComponent<RoundedRectangleProps, RoundedRectangleEvents, RoundedRectangleSlots> {
|
|
18
18
|
}
|
|
19
19
|
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<script>import { setupDrawable } from "../drawable.js";
|
|
2
|
+
import { onMount } from "svelte";
|
|
3
|
+
export let text;
|
|
4
|
+
export let size;
|
|
5
|
+
export let font;
|
|
6
|
+
export let style = void 0;
|
|
7
|
+
export let fill = void 0;
|
|
8
|
+
export let stroke = void 0;
|
|
9
|
+
export let strokeWidth = null;
|
|
10
|
+
export let alignH = "left";
|
|
11
|
+
export let alignV = "top";
|
|
12
|
+
$:
|
|
13
|
+
computedFont = (style ? style + " " : "") + size + "px " + font;
|
|
14
|
+
const draw = function({ ctx }, { x, y, w, h }) {
|
|
15
|
+
if (!text)
|
|
16
|
+
return;
|
|
17
|
+
ctx.beginPath();
|
|
18
|
+
ctx.textAlign = alignH;
|
|
19
|
+
ctx.textBaseline = alignV;
|
|
20
|
+
ctx.font = computedFont;
|
|
21
|
+
let actualX = x + (alignH === "right" ? w : alignH === "center" ? w / 2 : 0);
|
|
22
|
+
let actualY = y + (alignV === "bottom" ? h : alignV === "middle" ? h / 2 + size * 0.1 : 0);
|
|
23
|
+
if (fill) {
|
|
24
|
+
ctx.fillStyle = fill;
|
|
25
|
+
ctx.fillText(text, actualX, actualY);
|
|
26
|
+
}
|
|
27
|
+
if (stroke && strokeWidth) {
|
|
28
|
+
ctx.strokeStyle = stroke;
|
|
29
|
+
ctx.lineWidth = strokeWidth;
|
|
30
|
+
ctx.strokeText(text, actualX, actualY);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
let register = setupDrawable({});
|
|
34
|
+
onMount(() => {
|
|
35
|
+
return register({ draw });
|
|
36
|
+
});
|
|
37
|
+
</script>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
2
|
declare const __propDef: {
|
|
3
3
|
props: {
|
|
4
4
|
text: string;
|
|
@@ -8,8 +8,8 @@ declare const __propDef: {
|
|
|
8
8
|
fill?: string | undefined;
|
|
9
9
|
stroke?: string | undefined;
|
|
10
10
|
strokeWidth?: number | null | undefined;
|
|
11
|
-
alignH?: "
|
|
12
|
-
alignV?: "
|
|
11
|
+
alignH?: "center" | "left" | "right" | undefined;
|
|
12
|
+
alignV?: "alphabetic" | "bottom" | "middle" | "top" | undefined;
|
|
13
13
|
};
|
|
14
14
|
events: {
|
|
15
15
|
[evt: string]: CustomEvent<any>;
|
|
@@ -19,6 +19,6 @@ declare const __propDef: {
|
|
|
19
19
|
export type TextProps = typeof __propDef.props;
|
|
20
20
|
export type TextEvents = typeof __propDef.events;
|
|
21
21
|
export type TextSlots = typeof __propDef.slots;
|
|
22
|
-
export default class Text extends
|
|
22
|
+
export default class Text extends SvelteComponent<TextProps, TextEvents, TextSlots> {
|
|
23
23
|
}
|
|
24
24
|
export {};
|
|
File without changes
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** @typedef {typeof __propDef.props} EmptyProps */
|
|
2
|
+
/** @typedef {typeof __propDef.events} EmptyEvents */
|
|
3
|
+
/** @typedef {typeof __propDef.slots} EmptySlots */
|
|
4
|
+
export default class Empty {
|
|
5
|
+
}
|
|
6
|
+
export type EmptyProps = typeof __propDef.props;
|
|
7
|
+
export type EmptyEvents = typeof __propDef.events;
|
|
8
|
+
export type EmptySlots = typeof __propDef.slots;
|
|
9
|
+
declare const __propDef: {
|
|
10
|
+
props: {
|
|
11
|
+
[x: string]: never;
|
|
12
|
+
};
|
|
13
|
+
events: {
|
|
14
|
+
[evt: string]: CustomEvent<any>;
|
|
15
|
+
};
|
|
16
|
+
slots: {};
|
|
17
|
+
};
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<script>import { getGame } from "../core-contexts";
|
|
2
|
+
import { setupDrawable } from "../drawable";
|
|
3
|
+
import { onMount } from "svelte";
|
|
4
|
+
const game = getGame();
|
|
5
|
+
export let name;
|
|
6
|
+
const targets = /* @__PURE__ */ new Set();
|
|
7
|
+
const draw = (core) => {
|
|
8
|
+
targets.forEach((t) => t.draw(core));
|
|
9
|
+
};
|
|
10
|
+
setupDrawable({
|
|
11
|
+
assign: (obj) => {
|
|
12
|
+
targets.add(obj);
|
|
13
|
+
return () => targets.delete(obj);
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
onMount(() => {
|
|
17
|
+
const context = game.getLayerByName(name);
|
|
18
|
+
if (!context)
|
|
19
|
+
return;
|
|
20
|
+
return context.assign({ draw });
|
|
21
|
+
});
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
<slot />
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
name: string;
|
|
5
|
+
};
|
|
6
|
+
events: {
|
|
7
|
+
[evt: string]: CustomEvent<any>;
|
|
8
|
+
};
|
|
9
|
+
slots: {
|
|
10
|
+
default: {};
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export type LayerPortalProps = typeof __propDef.props;
|
|
14
|
+
export type LayerPortalEvents = typeof __propDef.events;
|
|
15
|
+
export type LayerPortalSlots = typeof __propDef.slots;
|
|
16
|
+
export default class LayerPortal extends SvelteComponent<LayerPortalProps, LayerPortalEvents, LayerPortalSlots> {
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<script>import { setupDrawable } from "../drawable";
|
|
2
|
+
import { onMount } from "svelte";
|
|
3
|
+
export let centered = false;
|
|
4
|
+
export let degrees = 0;
|
|
5
|
+
const targets = /* @__PURE__ */ new Set();
|
|
6
|
+
const draw = function({ width, height, ctx }, { x, y, w, h }) {
|
|
7
|
+
ctx.translate(x, y);
|
|
8
|
+
ctx.rotate(degrees * Math.PI / 180);
|
|
9
|
+
targets.forEach((f) => f.draw({ width, height, ctx }, { x: centered ? w * -0.5 : 0, y: centered ? h * -0.5 : 0, w, h }));
|
|
10
|
+
ctx.resetTransform();
|
|
11
|
+
};
|
|
12
|
+
let register = setupDrawable({
|
|
13
|
+
assign: (ctx) => {
|
|
14
|
+
targets.add(ctx);
|
|
15
|
+
return () => {
|
|
16
|
+
targets.delete(ctx);
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
onMount(() => {
|
|
21
|
+
return register({ draw });
|
|
22
|
+
});
|
|
23
|
+
</script>
|
|
24
|
+
|
|
25
|
+
<slot/>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
/**
|
|
5
|
+
* FALSE = ANCHOR TOP LEFT
|
|
6
|
+
* TRUE = ANCHOR CENTER
|
|
7
|
+
*/ centered?: boolean | undefined;
|
|
8
|
+
degrees?: number | undefined;
|
|
9
|
+
};
|
|
10
|
+
events: {
|
|
11
|
+
[evt: string]: CustomEvent<any>;
|
|
12
|
+
};
|
|
13
|
+
slots: {
|
|
14
|
+
default: {};
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export type RotateProps = typeof __propDef.props;
|
|
18
|
+
export type RotateEvents = typeof __propDef.events;
|
|
19
|
+
export type RotateSlots = typeof __propDef.slots;
|
|
20
|
+
export default class Rotate extends SvelteComponent<RotateProps, RotateEvents, RotateSlots> {
|
|
21
|
+
}
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<script>import { jumpSignal, effectiveScene } from "./scenes.js";
|
|
2
|
+
import { SvelteComponent, onMount } from "svelte";
|
|
3
|
+
import { getTriggerLayerRender } from "@hi-ashleyj/llama";
|
|
4
|
+
const triggerRender = getTriggerLayerRender();
|
|
5
|
+
let scene;
|
|
6
|
+
const changeScene = (_signal) => {
|
|
7
|
+
scene = $effectiveScene;
|
|
8
|
+
triggerRender();
|
|
9
|
+
};
|
|
10
|
+
$:
|
|
11
|
+
changeScene($jumpSignal);
|
|
12
|
+
onMount(() => {
|
|
13
|
+
scene = $effectiveScene;
|
|
14
|
+
});
|
|
15
|
+
export let scenes = {};
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
{#if scene && scenes[scene]}
|
|
19
|
+
<svelte:component this={scenes[scene]}></svelte:component>
|
|
20
|
+
{/if}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
scenes?: Record<string, typeof SvelteComponent> | undefined;
|
|
5
|
+
};
|
|
6
|
+
events: {
|
|
7
|
+
[evt: string]: CustomEvent<any>;
|
|
8
|
+
};
|
|
9
|
+
slots: {};
|
|
10
|
+
};
|
|
11
|
+
export type SceneSwitcherProps = typeof __propDef.props;
|
|
12
|
+
export type SceneSwitcherEvents = typeof __propDef.events;
|
|
13
|
+
export type SceneSwitcherSlots = typeof __propDef.slots;
|
|
14
|
+
export default class SceneSwitcher extends SvelteComponent<SceneSwitcherProps, SceneSwitcherEvents, SceneSwitcherSlots> {
|
|
15
|
+
}
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
<script>import { jumpSignal, sceneAnimating } from "./scenes";
|
|
2
|
+
import { getGame, getTriggerLayerRender } from "@hi-ashleyj/llama";
|
|
3
|
+
import { onDestroy } from "svelte";
|
|
4
|
+
const context = getGame();
|
|
5
|
+
export let duration = 1e3;
|
|
6
|
+
let burst = context.createBurst({ duration });
|
|
7
|
+
let triggerRender = getTriggerLayerRender();
|
|
8
|
+
onDestroy(burst.stop);
|
|
9
|
+
let halfAnimationTriggered = false;
|
|
10
|
+
const startAnimation = () => {
|
|
11
|
+
burst.trigger();
|
|
12
|
+
halfAnimationTriggered = false;
|
|
13
|
+
};
|
|
14
|
+
const halfAnimation = () => {
|
|
15
|
+
halfAnimationTriggered = true;
|
|
16
|
+
$jumpSignal = !$jumpSignal;
|
|
17
|
+
};
|
|
18
|
+
const completeAnimation = () => {
|
|
19
|
+
$sceneAnimating = false;
|
|
20
|
+
};
|
|
21
|
+
$: {
|
|
22
|
+
if ($sceneAnimating)
|
|
23
|
+
startAnimation();
|
|
24
|
+
}
|
|
25
|
+
$: {
|
|
26
|
+
if ($burst > 0.5 && !halfAnimationTriggered)
|
|
27
|
+
halfAnimation();
|
|
28
|
+
if ($burst == 1)
|
|
29
|
+
completeAnimation();
|
|
30
|
+
}
|
|
31
|
+
$:
|
|
32
|
+
normalized = 1 - Math.abs($burst - 0.5) * 2;
|
|
33
|
+
$: {
|
|
34
|
+
triggerRender($burst);
|
|
35
|
+
}
|
|
36
|
+
</script>
|
|
37
|
+
|
|
38
|
+
{#if $burst > 0 && $burst < 1}
|
|
39
|
+
<slot progress={$burst} normalized={normalized} />
|
|
40
|
+
{/if}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
duration?: number | undefined;
|
|
5
|
+
};
|
|
6
|
+
events: {
|
|
7
|
+
[evt: string]: CustomEvent<any>;
|
|
8
|
+
};
|
|
9
|
+
slots: {
|
|
10
|
+
default: {
|
|
11
|
+
progress: any;
|
|
12
|
+
normalized: number;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export type SceneTransitionProps = typeof __propDef.props;
|
|
17
|
+
export type SceneTransitionEvents = typeof __propDef.events;
|
|
18
|
+
export type SceneTransitionSlots = typeof __propDef.slots;
|
|
19
|
+
export default class SceneTransition extends SvelteComponent<SceneTransitionProps, SceneTransitionEvents, SceneTransitionSlots> {
|
|
20
|
+
}
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<div class="game-wrapper">
|
|
2
|
+
<slot />
|
|
3
|
+
</div>
|
|
4
|
+
|
|
5
|
+
<style>
|
|
6
|
+
* {
|
|
7
|
+
box-sizing: border-box;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
:global(html, body) {
|
|
11
|
+
width: 100%;
|
|
12
|
+
height: 100%;
|
|
13
|
+
background: black;
|
|
14
|
+
padding: 0;
|
|
15
|
+
margin: 0;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.game-wrapper {
|
|
19
|
+
width: 100%;
|
|
20
|
+
height: 100%;
|
|
21
|
+
}
|
|
22
|
+
</style>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** @typedef {typeof __propDef.props} SensibleDefaultStylesProps */
|
|
2
|
+
/** @typedef {typeof __propDef.events} SensibleDefaultStylesEvents */
|
|
3
|
+
/** @typedef {typeof __propDef.slots} SensibleDefaultStylesSlots */
|
|
4
|
+
export default class SensibleDefaultStyles {
|
|
5
|
+
}
|
|
6
|
+
export type SensibleDefaultStylesProps = typeof __propDef.props;
|
|
7
|
+
export type SensibleDefaultStylesEvents = typeof __propDef.events;
|
|
8
|
+
export type SensibleDefaultStylesSlots = typeof __propDef.slots;
|
|
9
|
+
declare const __propDef: {
|
|
10
|
+
props: {
|
|
11
|
+
[x: string]: never;
|
|
12
|
+
};
|
|
13
|
+
events: {
|
|
14
|
+
[evt: string]: CustomEvent<any>;
|
|
15
|
+
};
|
|
16
|
+
slots: {
|
|
17
|
+
default: {};
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export {};
|