diff --git a/engine/Vector.ts b/engine/Vector.ts index 840e509..2e78f62 100644 --- a/engine/Vector.ts +++ b/engine/Vector.ts @@ -87,3 +87,5 @@ export function isBelowAbs(vector: Vector, abs: number): boolean { export function equals(a: Vector, b: Vector): boolean { return a.x === b.x && a.y === b.y; } + +export const ZERO = createVector(); diff --git a/engine/system/physics.ts b/engine/system/physics.ts index 1042d68..d17c61f 100644 --- a/engine/system/physics.ts +++ b/engine/system/physics.ts @@ -20,6 +20,8 @@ const CIRCLE = Shape.Circle; const RECT = Shape.Rect; const POLYGON = Shape.Polygon; +const EPSILON = 0.0001; + type CollisionBuffer = { size: number; mask: number; @@ -528,7 +530,7 @@ export function moveAndSlide( break; } - const scalar = Math.max(0, time - 0.001) * delta * timeLeft; + const scalar = Math.max(0, time - EPSILON) * delta * timeLeft; position.x += velocity.x * scalar; position.y += velocity.y * scalar; diff --git a/game/entities/portal/entity.ts b/game/entities/portal/entity.ts index 9126d74..b8599c4 100644 --- a/game/entities/portal/entity.ts +++ b/game/entities/portal/entity.ts @@ -13,7 +13,6 @@ const portalSrc = await defineSpriteSheet(portal, 3, 1); defineEntity("portal", { position: createVector(), - velocity: createVector(), collider: createCollider(Shape.Circle, createCircle(8)), sprite: createSprite(portalSrc, createVector(-8, -8)), animation: createSpriteAnimation(400, 0),