From abead06799802ede319b916984c66120534c5345 Mon Sep 17 00:00:00 2001 From: Gustavo Giserman Date: Thu, 11 Nov 2021 00:43:53 -0300 Subject: [PATCH] addIsometricLevel: Mirror width and height property names from addLevel --- demo/isometricLevel.js | 8 ++++---- src/kaboom.ts | 14 +++++++------- src/types.ts | 4 ++-- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/demo/isometricLevel.js b/demo/isometricLevel.js index 9ea99ded..78e4a4bf 100644 --- a/demo/isometricLevel.js +++ b/demo/isometricLevel.js @@ -31,8 +31,8 @@ const level = addIsometricLevel([ '@@@@@@@@@@@@@@@', ], { // The size of each grid - tileWidth: 144, - tileHeight: 71, + width: 144, + height: 71, // Define what each symbol means (in components) '@': () => [ sprite('grass'), @@ -56,8 +56,8 @@ const level2 = addIsometricLevel([ '@@@@@@@@@@@@@@@', '@@@@@@@@@@@@@@@', ], { - tileWidth: 144, - tileHeight: 71, + width: 144, + height: 71, '@': () => [ sprite('grass'), ], diff --git a/src/kaboom.ts b/src/kaboom.ts index e7ed200e..13d51c24 100644 --- a/src/kaboom.ts +++ b/src/kaboom.ts @@ -2479,15 +2479,15 @@ function addLevel(map: string[], opt: LevelOpt): Level { } function addIsometricLevel(map: string[], options: IsometricLevelOpt): IsometricLevel { - if (!options.tileWidth || !options.tileHeight) { + if (!options.width || !options.height) { throw new Error("Must provide isometric level tile width & height."); } const objects: GameObj[] = []; const offset = vec2(options.pos || vec2(0)); - const halfTileWidth = Math.floor(options.tileWidth / 2); - const halfTileHeight = Math.floor(options.tileHeight / 2); + const halfTileWidth = Math.floor(options.width / 2); + const halfTileHeight = Math.floor(options.height / 2); const maxWidthInTiles = map.reduce((width, row): number => Math.max(width, row.length), 0) const heightInTiles = map.length; @@ -2498,11 +2498,11 @@ function addIsometricLevel(map: string[], options: IsometricLevelOpt): Isometric }, gridWidth() { - return options.tileWidth; + return options.width; }, gridHeight() { - return options.tileHeight; + return options.height; }, fromIsometricCoordsToWorldPos: (row: number, col: number): Vec2 => { @@ -2553,11 +2553,11 @@ function addIsometricLevel(map: string[], options: IsometricLevelOpt): Isometric }, width() { - return maxWidthInTiles * options.tileWidth; + return maxWidthInTiles * options.width; }, height() { - return heightInTiles * options.tileHeight; + return heightInTiles * options.height; }, destroy() { diff --git a/src/types.ts b/src/types.ts index 8309bda2..d1e4934f 100644 --- a/src/types.ts +++ b/src/types.ts @@ -3814,11 +3814,11 @@ export interface IsometricLevelOpt { /** * Width of each block. */ - tileWidth: number, + width: number, /** * Height of each block. */ - tileHeight: number, + height: number, /** * Position of the first block. */