From e0bd8a2fc733f06668131684e99e0847fe4ac510 Mon Sep 17 00:00:00 2001 From: Schluffe Date: Sun, 5 Apr 2026 18:03:03 +0200 Subject: [PATCH] start: der ewige krueis --- engine/system/physics.ts | 6 +++--- game/entities/hero/entity.ts | 4 ++-- game/entities/portal/entity.ts | 4 ++-- main.ts | 7 +++++++ 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/engine/system/physics.ts b/engine/system/physics.ts index e0303c8..044ffb5 100644 --- a/engine/system/physics.ts +++ b/engine/system/physics.ts @@ -5,12 +5,12 @@ import $ from "#/engine/Scene.ts"; import { createVector, getDotProduct, type Vector } from "#/engine/Vector.ts"; export enum Shape { - Cirle, + Circle, Rect, Polygon, } -const CIRCLE = Shape.Cirle; +const CIRCLE = Shape.Circle; const RECT = Shape.Rect; const POLYGON = Shape.Polygon; @@ -64,7 +64,7 @@ export function createCollider( width = size; height = size; if (offset === undefined) { - offset = createVector(); + offset = createVector(-radius, -radius); } break; } diff --git a/game/entities/hero/entity.ts b/game/entities/hero/entity.ts index 4a5ae47..ace5849 100644 --- a/game/entities/hero/entity.ts +++ b/game/entities/hero/entity.ts @@ -1,8 +1,8 @@ +import { createCircle } from "#/engine/Circle.ts"; import { defineEntity } from "#/engine/Entity.ts"; import { keyboardInput } from "#/engine/Keyboard.ts"; import { createEffect, createSignal } from "#/engine/lib/Signal.ts"; import { pointer } from "#/engine/Pointer.ts"; -import { createRect } from "#/engine/Rect.ts"; import $ from "#/engine/Scene.ts"; import { createSprite, @@ -30,7 +30,7 @@ const process = defineEntity("hero", { sprite: createSprite(idleSrc, createVector(-8, -8)), animation: createSpriteAnimation(500, 2), velocity: createVector(), - collider: createCollider(Shape.Rect, createRect(24, 16)), + collider: createCollider(Shape.Circle, createCircle(8)), }); createEffect(() => { diff --git a/game/entities/portal/entity.ts b/game/entities/portal/entity.ts index f7af10e..f526f6b 100644 --- a/game/entities/portal/entity.ts +++ b/game/entities/portal/entity.ts @@ -1,5 +1,5 @@ +import { createCircle } from "#/engine/Circle.ts"; import { defineEntity } from "#/engine/Entity.ts"; -import { createRect } from "#/engine/Rect.ts"; import { createSprite, createSpriteAnimation, @@ -16,5 +16,5 @@ defineEntity("portal", { position, sprite: createSprite(portalSrc, createVector(-8, -8)), animation: createSpriteAnimation(400, 0), - collider: createCollider(Shape.Rect, createRect(16, 16)), + collider: createCollider(Shape.Circle, createCircle(8)), }); diff --git a/main.ts b/main.ts index 95f9290..6be6f3c 100644 --- a/main.ts +++ b/main.ts @@ -39,6 +39,13 @@ function debug(ctx: CanvasRenderingContext2D) { 2, 2, ); + + if (collider.value.shape === 0) { + // @ts-ignore + ctx.arc(pos.x, pos.y, collider.value.body.radius, 0, 2 * Math.PI); + ctx.strokeStyle = "white"; + ctx.stroke(); + } } }