Run prettier
This commit is contained in:
		| @@ -165,14 +165,20 @@ export class Circle { | ||||
|     let rw = rect.size.w; | ||||
|     let rh = rect.size.h; | ||||
|  | ||||
|     if (cx < rx) { testX = rx; } | ||||
|     else if (cx > rx + rw) { testX = rx + rw; } | ||||
|     if (cy < ry) { testY = ry; } | ||||
|     else if (cy > ry + rh) { testY = ry + rh; } | ||||
|     if (cx < rx) { | ||||
|       testX = rx; | ||||
|     } else if (cx > rx + rw) { | ||||
|       testX = rx + rw; | ||||
|     } | ||||
|     if (cy < ry) { | ||||
|       testY = ry; | ||||
|     } else if (cy > ry + rh) { | ||||
|       testY = ry + rh; | ||||
|     } | ||||
|  | ||||
|     let distX = cx - testX; | ||||
|     let distY = cy - testY; | ||||
|     let sqDistance = (distX * distX) + (distY * distY); | ||||
|     let sqDistance = distX * distX + distY * distY; | ||||
|  | ||||
|     if (sqDistance <= this.radius * this.radius) { | ||||
|       return new Point(testX, testY); | ||||
| @@ -183,7 +189,7 @@ export class Circle { | ||||
|   overlappedCells(size: Size): Rect[] { | ||||
|     let meAsRect = new Rect( | ||||
|       this.center.offset(new Point(-this.radius, -this.radius)), | ||||
|       new Size(this.radius * 2, this.radius * 2) | ||||
|       new Size(this.radius * 2, this.radius * 2), | ||||
|     ); | ||||
|     let all: Rect[] = []; | ||||
|     for (let cell of meAsRect.overlappedCells(size).values()) { | ||||
|   | ||||
| @@ -1,5 +1,5 @@ | ||||
| import { BreakableBlockPickupCallbacks } from "./pickups.ts"; | ||||
| import {Circle, Point} from "./engine/datatypes.ts"; | ||||
| import { Circle, Point } from "./engine/datatypes.ts"; | ||||
| import { displace } from "./physics.ts"; | ||||
| import { getHuntMode } from "./huntmode.ts"; | ||||
| import { DrawPile } from "./drawpile.ts"; | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| import {Circle, Point, Rect, Size} from "./engine/datatypes.ts"; | ||||
| import { Circle, Point, Rect, Size } from "./engine/datatypes.ts"; | ||||
| import { DrawPile } from "./drawpile.ts"; | ||||
| import { D, I } from "./engine/public.ts"; | ||||
| import { sprThrallLore } from "./sprites.ts"; | ||||
| @@ -201,9 +201,9 @@ export class HuntMode { | ||||
|  | ||||
|     this.velocity = new Point(dx, dy); | ||||
|  | ||||
|     let bbox = new Circle( this.floatingPlayer, szX / 2); | ||||
|     let bbox = new Circle(this.floatingPlayer, szX / 2); | ||||
|     let { displacement, dxy } = displace(bbox, this.velocity, (b: Circle) => | ||||
|       this.getContact(b) | ||||
|       this.getContact(b), | ||||
|     ); | ||||
|     this.floatingPlayer = this.floatingPlayer.offset(displacement); | ||||
|     this.velocity = dxy; | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| import {Circle, lerp, Point, Rect} from "./engine/datatypes.ts"; | ||||
| import { Circle, lerp, Point, Rect } from "./engine/datatypes.ts"; | ||||
|  | ||||
| export function displace( | ||||
|   bbox: Circle, | ||||
| @@ -25,7 +25,10 @@ export function displace( | ||||
|  | ||||
|       let dot = dxy.x * nx + dxy.y * ny; | ||||
|       if (redirections < nRedirections) { | ||||
|         dxy = new Point(dxy.x - lerp(bounce, 1, 2) * dot * nx, dxy.y - lerp(bounce, 1, 2) * dot * ny); | ||||
|         dxy = new Point( | ||||
|           dxy.x - lerp(bounce, 1, 2) * dot * nx, | ||||
|           dxy.y - lerp(bounce, 1, 2) * dot * ny, | ||||
|         ); | ||||
|         i -= 1; // try again with reflection | ||||
|         redirections += 1; | ||||
|       } else { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user