Skip to content
This repository was archived by the owner on Nov 12, 2024. It is now read-only.

Commit abead06

Browse files
committed
addIsometricLevel: Mirror width and height property names from addLevel
1 parent 8946d47 commit abead06

3 files changed

Lines changed: 13 additions & 13 deletions

File tree

demo/isometricLevel.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ const level = addIsometricLevel([
3131
'@@@@@@@@@@@@@@@',
3232
], {
3333
// The size of each grid
34-
tileWidth: 144,
35-
tileHeight: 71,
34+
width: 144,
35+
height: 71,
3636
// Define what each symbol means (in components)
3737
'@': () => [
3838
sprite('grass'),
@@ -56,8 +56,8 @@ const level2 = addIsometricLevel([
5656
'@@@@@@@@@@@@@@@',
5757
'@@@@@@@@@@@@@@@',
5858
], {
59-
tileWidth: 144,
60-
tileHeight: 71,
59+
width: 144,
60+
height: 71,
6161
'@': () => [
6262
sprite('grass'),
6363
],

src/kaboom.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2479,15 +2479,15 @@ function addLevel(map: string[], opt: LevelOpt): Level {
24792479
}
24802480

24812481
function addIsometricLevel(map: string[], options: IsometricLevelOpt): IsometricLevel {
2482-
if (!options.tileWidth || !options.tileHeight) {
2482+
if (!options.width || !options.height) {
24832483
throw new Error("Must provide isometric level tile width & height.");
24842484
}
24852485

24862486
const objects: GameObj[] = [];
24872487
const offset = vec2(options.pos || vec2(0));
24882488

2489-
const halfTileWidth = Math.floor(options.tileWidth / 2);
2490-
const halfTileHeight = Math.floor(options.tileHeight / 2);
2489+
const halfTileWidth = Math.floor(options.width / 2);
2490+
const halfTileHeight = Math.floor(options.height / 2);
24912491

24922492
const maxWidthInTiles = map.reduce((width, row): number => Math.max(width, row.length), 0)
24932493
const heightInTiles = map.length;
@@ -2498,11 +2498,11 @@ function addIsometricLevel(map: string[], options: IsometricLevelOpt): Isometric
24982498
},
24992499

25002500
gridWidth() {
2501-
return options.tileWidth;
2501+
return options.width;
25022502
},
25032503

25042504
gridHeight() {
2505-
return options.tileHeight;
2505+
return options.height;
25062506
},
25072507

25082508
fromIsometricCoordsToWorldPos: (row: number, col: number): Vec2 => {
@@ -2553,11 +2553,11 @@ function addIsometricLevel(map: string[], options: IsometricLevelOpt): Isometric
25532553
},
25542554

25552555
width() {
2556-
return maxWidthInTiles * options.tileWidth;
2556+
return maxWidthInTiles * options.width;
25572557
},
25582558

25592559
height() {
2560-
return heightInTiles * options.tileHeight;
2560+
return heightInTiles * options.height;
25612561
},
25622562

25632563
destroy() {

src/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3814,11 +3814,11 @@ export interface IsometricLevelOpt {
38143814
/**
38153815
* Width of each block.
38163816
*/
3817-
tileWidth: number,
3817+
width: number,
38183818
/**
38193819
* Height of each block.
38203820
*/
3821-
tileHeight: number,
3821+
height: number,
38223822
/**
38233823
* Position of the first block.
38243824
*/

0 commit comments

Comments
 (0)