Merge branch entity-center-fix #4
8
lib/index.d.ts
vendored
8
lib/index.d.ts
vendored
@ -600,9 +600,13 @@ export class Sound {
|
|||||||
stop(): void;
|
stop(): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface NumericalEntity {pos: Coordinates, w: number, h: number}
|
interface NumericalEntityBase {pos: Coordinates}
|
||||||
|
interface NumericalSprite {w: number, h: number}
|
||||||
|
interface NumericalTileSprite {tileW: number, tileH: number}
|
||||||
|
|
||||||
interface NumericalEntityWithHitbox extends NumericalEntity {hitBox: NumericalEntity}
|
type NumericalEntity = NumericalSprite | NumericalTileSprite
|
||||||
|
|
||||||
|
type NumericalEntityWithHitbox = {hitBox: NumericalEntity} & NumericalEntity
|
||||||
|
|
||||||
export namespace deadInTracks {
|
export namespace deadInTracks {
|
||||||
/**
|
/**
|
||||||
|
@ -31,7 +31,15 @@ function bounds(entity) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function center(entity) {
|
function center(entity) {
|
||||||
const { pos, w, h } = entity;
|
let pos, w, h;
|
||||||
|
|
||||||
|
// Object.prototype.hasOwnProperty.call is needed because of eslint
|
||||||
|
if (Object.prototype.hasOwnProperty.call(entity, "tileW") && Object.prototype.hasOwnProperty.call(entity, "tileH")) {
|
||||||
|
({pos, w, h} = {pos: entity.pos, w: entity.tileW, h: entity.tileH});
|
||||||
|
} else {
|
||||||
|
({pos, w, h} = entity);
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
x: pos.x + w / 2,
|
x: pos.x + w / 2,
|
||||||
y: pos.y + h / 2
|
y: pos.y + h / 2
|
||||||
|
Loading…
Reference in New Issue
Block a user