fine tune

This commit is contained in:
Schluffe
2026-03-30 23:14:52 +02:00
parent 25d0f950e6
commit bc9bdc3624
3 changed files with 13 additions and 9 deletions
+11 -7
View File
@@ -74,6 +74,7 @@ export function createCollider(
break; break;
} }
case POLYGON: { case POLYGON: {
// TODO
break; break;
} }
} }
@@ -144,6 +145,7 @@ function collideWithCirle(
other: Collider, other: Collider,
) { ) {
collision.cid = cid; collision.cid = cid;
// TODO
} }
function collideWithRect( function collideWithRect(
@@ -173,6 +175,7 @@ function collideWithPolygon(
other: Collider, other: Collider,
) { ) {
collision.cid = cid; collision.cid = cid;
// TODO
} }
const circleCollide: Array<Collide> = [ const circleCollide: Array<Collide> = [
@@ -288,13 +291,14 @@ export function moveAndSlide(
if (time === -Infinity) { if (time === -Infinity) {
continue; // TODO continue; // TODO
} }
const dot = getDotProduct(velocity, collision.normal);
const ts = Math.min(0, time - 0.001);
const tsx = velocity.x * ts;
const tsy = velocity.y * ts;
const rt = 1 - time;
velocity.x -= collision.normal.x * dot * rt + tsx; const ts = Math.min(0, time - 0.001);
velocity.y -= collision.normal.y * dot * rt + tsy; velocity.x += velocity.x * ts;
velocity.y += velocity.y * ts;
const dot = getDotProduct(velocity, collision.normal);
const rt = 1 - time + 0.001;
velocity.x -= collision.normal.x * dot * rt;
velocity.y -= collision.normal.y * dot * rt;
} }
} }
+1 -1
View File
@@ -23,7 +23,7 @@ import {
import { viewport } from "#/engine/Viewport.ts"; import { viewport } from "#/engine/Viewport.ts";
import charIdle from "#/game/assets/char-idle.png"; import charIdle from "#/game/assets/char-idle.png";
const speed = 0.05; const speed = 0.1;
const idleSrc = await defineSpriteSheet(charIdle, 2, 4); const idleSrc = await defineSpriteSheet(charIdle, 2, 4);
const process = defineEntity("hero", { const process = defineEntity("hero", {
+1 -1
View File
@@ -17,7 +17,7 @@
"init": { "init": {
"position": { "position": {
"x": 24, "x": 24,
"y": 41 "y": 40
} }
} }
}, },