WIP WIP WIP
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
import type { Polygon } from "#/engine/Polygon.ts";
|
||||
import type { Vector } from "#/engine/Vector.ts";
|
||||
|
||||
export function drawPoint(
|
||||
ctx: CanvasRenderingContext2D,
|
||||
position: Vector,
|
||||
radius: number = 1,
|
||||
color: string = "#fff",
|
||||
): void {
|
||||
ctx.beginPath();
|
||||
ctx.arc(position.x, position.y, radius, 0, 2 * Math.PI);
|
||||
ctx.fillStyle = color;
|
||||
ctx.fill();
|
||||
}
|
||||
|
||||
export function drawPolygon(
|
||||
ctx: CanvasRenderingContext2D,
|
||||
polygon: Polygon,
|
||||
color: string = "#fff",
|
||||
): void {
|
||||
drawPoint(ctx, polygon.position);
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(
|
||||
polygon.points[0].x + polygon.position.x,
|
||||
polygon.points[0].y + polygon.position.y,
|
||||
);
|
||||
|
||||
for (let i = polygon.points.length - 1; i >= 0; i--) {
|
||||
ctx.lineTo(
|
||||
polygon.points[i].x + polygon.position.x,
|
||||
polygon.points[i].y + polygon.position.y,
|
||||
);
|
||||
}
|
||||
|
||||
ctx.strokeStyle = color;
|
||||
ctx.stroke();
|
||||
}
|
||||
@@ -3,6 +3,7 @@ import { type Component, createEffect, createSignal, onMount } from "solid-js";
|
||||
import { render } from "solid-js/web";
|
||||
import $, {
|
||||
currentScene,
|
||||
type SceneChange,
|
||||
type SceneData,
|
||||
sceneChangeSet,
|
||||
sceneGraph,
|
||||
@@ -121,6 +122,17 @@ const DevTools: Component<{ gameContainer: HTMLElement }> = ({
|
||||
|
||||
document.addEventListener("mousemove", handleMouseMove);
|
||||
document.addEventListener("mouseup", stopResizing);
|
||||
|
||||
if (location.hash) {
|
||||
const callback: SceneChange = (sceneData) => {
|
||||
const name = location.hash.substring(1);
|
||||
if (sceneData.name !== name) {
|
||||
setScene(name).catch(console.error);
|
||||
}
|
||||
sceneChangeSet.delete(callback);
|
||||
};
|
||||
sceneChangeSet.add(callback);
|
||||
}
|
||||
});
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user