Skip to content

Commit

Permalink
Use bboxes instead of circles for layer visibility
Browse files Browse the repository at this point in the history
  • Loading branch information
lorgan3 committed Jan 30, 2024
1 parent 599480e commit a5ecc17
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/data/map/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ export interface ComputedLayer {
y: number;
cx: number;
cy: number;
r: number;
r2: number;
right: number;
bottom: number;
}

export interface Config {
Expand Down Expand Up @@ -68,8 +68,8 @@ export class Map {
y,
cx: x + layer.width / 2,
cy: y + layer.height / 2,
r,
r2: r * r,
right: x + layer.width,
bottom: y + layer.height,
};
});

Expand Down
8 changes: 6 additions & 2 deletions src/data/network/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { KeyboardController } from "../controller/keyboardController";
import { DisplayObject } from "pixi.js";
import { Spell } from "../spells";
import { Cursor } from "../../graphics/cursor/types";
import { getSquareDistance } from "../../util/math";
import { Element } from "../spells/types";

const TURN_GRACE_PERIOD = 3000;
Expand Down Expand Up @@ -85,7 +84,12 @@ export abstract class Manager {

for (let character of this._self.characters) {
const [x, y] = character.body.precisePosition;
if (getSquareDistance(x + 4.5, y + 8, layer.cx, layer.cy) < layer.r2) {
if (
x + 6 >= layer.x &&
x <= layer.right &&
y + 16 >= layer.y &&
y <= layer.bottom
) {
revealed = true;
break;
}
Expand Down

0 comments on commit a5ecc17

Please sign in to comment.