fine tune
This commit is contained in:
@@ -74,6 +74,7 @@ export function createCollider(
|
||||
break;
|
||||
}
|
||||
case POLYGON: {
|
||||
// TODO
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -144,6 +145,7 @@ function collideWithCirle(
|
||||
other: Collider,
|
||||
) {
|
||||
collision.cid = cid;
|
||||
// TODO
|
||||
}
|
||||
|
||||
function collideWithRect(
|
||||
@@ -173,6 +175,7 @@ function collideWithPolygon(
|
||||
other: Collider,
|
||||
) {
|
||||
collision.cid = cid;
|
||||
// TODO
|
||||
}
|
||||
|
||||
const circleCollide: Array<Collide> = [
|
||||
@@ -288,13 +291,14 @@ export function moveAndSlide(
|
||||
if (time === -Infinity) {
|
||||
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;
|
||||
velocity.y -= collision.normal.y * dot * rt + tsy;
|
||||
const ts = Math.min(0, time - 0.001);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ import {
|
||||
import { viewport } from "#/engine/Viewport.ts";
|
||||
import charIdle from "#/game/assets/char-idle.png";
|
||||
|
||||
const speed = 0.05;
|
||||
const speed = 0.1;
|
||||
const idleSrc = await defineSpriteSheet(charIdle, 2, 4);
|
||||
|
||||
const process = defineEntity("hero", {
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
"init": {
|
||||
"position": {
|
||||
"x": 24,
|
||||
"y": 41
|
||||
"y": 40
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user