The great move >.<
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "barScene",
|
||||
"width": 240,
|
||||
"height": 160,
|
||||
"entities": [
|
||||
{
|
||||
"name": "hero",
|
||||
"position": {
|
||||
"x": 0,
|
||||
"y": 0
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import { defineScene } from "#/engine/Scene.ts";
|
||||
import data from "./data.json";
|
||||
|
||||
const { process, linkScenes } = defineScene(data);
|
||||
|
||||
linkScenes(["testScene"] as const);
|
||||
|
||||
process((_ctx, _delta) => {});
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"name": "fooScene",
|
||||
"width": 80,
|
||||
"height": 48,
|
||||
"entities": [
|
||||
{
|
||||
"name": "hero",
|
||||
"position": {
|
||||
"x": 0,
|
||||
"y": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "testEntity",
|
||||
"position": {
|
||||
"x": 24,
|
||||
"y": 16
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import { defineScene } from "#/engine/Scene.ts";
|
||||
import data from "./data.json";
|
||||
|
||||
const { process, linkScenes } = defineScene(data);
|
||||
|
||||
linkScenes(["barScene"] as const);
|
||||
|
||||
process((_ctx, _delta) => {});
|
||||
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"name": "testScene",
|
||||
"width": 80,
|
||||
"height": 48,
|
||||
"entities": [
|
||||
{
|
||||
"name": "hero",
|
||||
"position": {
|
||||
"x": 0,
|
||||
"y": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "portal",
|
||||
"position": {
|
||||
"x": 16,
|
||||
"y": 16
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "testEntity",
|
||||
"position": {
|
||||
"x": 32,
|
||||
"y": 32
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
import { pointer } from "#/engine/Pointer.ts";
|
||||
import { defineScene } from "#/engine/Scene.ts";
|
||||
import type { Vector } from "#/engine/Vector.ts";
|
||||
import data from "./data.json";
|
||||
|
||||
const { process, preProcess, linkScenes } = defineScene(data);
|
||||
|
||||
linkScenes(["fooScene"] as const);
|
||||
|
||||
preProcess((entityInstanceMap) => {
|
||||
const entity = entityInstanceMap.get(data.entities[0].name);
|
||||
const instance = entity!.instances[0];
|
||||
|
||||
instance.position.x = data.width - 16;
|
||||
instance.position.y = data.height - 16;
|
||||
});
|
||||
|
||||
function drawPoint(
|
||||
ctx: CanvasRenderingContext2D,
|
||||
position: Vector,
|
||||
radius: number = 4,
|
||||
): void {
|
||||
ctx.beginPath();
|
||||
ctx.arc(position.x, position.y, radius, 0, 2 * Math.PI);
|
||||
ctx.strokeStyle = "#ff9000";
|
||||
ctx.stroke();
|
||||
}
|
||||
|
||||
process((ctx, delta) => {
|
||||
if (!pointer.isDown) {
|
||||
drawPoint(ctx, pointer.position);
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user