Refactor detail scene elements to single class
This commit is contained in:
parent
85214fad3f
commit
d084511c6b
11 changed files with 162 additions and 335 deletions
11
src/area.ts
11
src/area.ts
|
|
@ -1,19 +1,16 @@
|
|||
import { BehaviorSubject, Subject } from 'rxjs';
|
||||
import { mp5 } from '../main';
|
||||
import { Area } from './types';
|
||||
|
||||
export const playerHead$ = new Subject<{ x: number; y: number; w: number }>();
|
||||
export const playerHead$ = new Subject<Area>();
|
||||
|
||||
export const revealedArea$ = new BehaviorSubject<{ x: number; y: number; w: number }>({
|
||||
export const revealedArea$ = new BehaviorSubject<Area>({
|
||||
x: 0,
|
||||
y: 0,
|
||||
w: 0,
|
||||
});
|
||||
|
||||
export function areasColliding(
|
||||
areaOne: { x: number; y: number; w: number },
|
||||
areaTwo: { x: number; y: number; w: number },
|
||||
log?: boolean
|
||||
): boolean {
|
||||
export function areasColliding(areaOne: Area, areaTwo: Area): boolean {
|
||||
const distanceBetweenPoints = mp5.dist(areaOne.x, areaOne.y, areaTwo.x, areaTwo.y);
|
||||
const shapeArea = areaTwo.w / 2 + areaOne.w / 2;
|
||||
|
||||
|
|
|
|||
Reference in a new issue