diff --git a/engine/system/physics.ts b/engine/system/physics.ts index ce42069..41d13ba 100644 --- a/engine/system/physics.ts +++ b/engine/system/physics.ts @@ -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 = [ @@ -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; } } diff --git a/game/entities/hero/entity.ts b/game/entities/hero/entity.ts index de1ae9a..c90c524 100644 --- a/game/entities/hero/entity.ts +++ b/game/entities/hero/entity.ts @@ -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", { diff --git a/game/scenes/testScene/data.json b/game/scenes/testScene/data.json index 8396e84..764bc27 100644 --- a/game/scenes/testScene/data.json +++ b/game/scenes/testScene/data.json @@ -17,7 +17,7 @@ "init": { "position": { "x": 24, - "y": 41 + "y": 40 } } },