From 023cb7626f2f027ef9e3327d4dbdf52338f674b6 Mon Sep 17 00:00:00 2001 From: Gustavo Giserman Date: Fri, 26 Nov 2021 01:54:57 -0300 Subject: [PATCH] Rename and lint isometricLevel interface to match levels --- src/kaboom.ts | 7 ++++--- src/types.ts | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/kaboom.ts b/src/kaboom.ts index e241c104..1ab84211 100644 --- a/src/kaboom.ts +++ b/src/kaboom.ts @@ -2548,8 +2548,9 @@ function addIsometricLevel(map: string[], options: IsometricLevelOpt): Isometric return options.height; }, - fromIsometricCoordsToWorldPos: (row: number, col: number): Vec2 => { - return vec2((col - row) * halfTileWidth, (col + row) * halfTileHeight); + getPos: (...args): Vec2 => { + const p = vec2(...args); + return vec2((p.x - p.y) * halfTileWidth, (p.x + p.y) * halfTileHeight); }, spawn: (position: Vec2, symbol: string): GameObj => { @@ -2608,7 +2609,7 @@ function addIsometricLevel(map: string[], options: IsometricLevelOpt): Isometric for (let row = 0; row < heightInTiles; row++) { for (let col = 0; col < maxWidthInTiles; col++) { - const position = isometricLevel.fromIsometricCoordsToWorldPos(row, col); + const position = isometricLevel.getPos(col, row); const rowContent: string = map[row] const symbols: string[] = rowContent.split(""); const symbol = symbols[col] diff --git a/src/types.ts b/src/types.ts index c5cae02c..c4fce3df 100644 --- a/src/types.ts +++ b/src/types.ts @@ -3983,7 +3983,8 @@ export interface IsometricLevel { gridWidth(): number, gridHeight(): number, offset(): Vec2, - fromIsometricCoordsToWorldPos(row: number, col: number): Vec2, + getPos(p: Vec2): Vec2, + getPos(x: number, y: number): Vec2, width(): number, height(): number, destroy(): void,