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

Commit 04b7ead

Browse files
committed
addIsometricLevel: Mirror width and height property names from addLevel
1 parent cbd9166 commit 04b7ead

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
@@ -2473,15 +2473,15 @@ function addLevel(map: string[], opt: LevelOpt): Level {
24732473
}
24742474

24752475
function addIsometricLevel(map: string[], options: IsometricLevelOpt): IsometricLevel {
2476-
if (!options.tileWidth || !options.tileHeight) {
2476+
if (!options.width || !options.height) {
24772477
throw new Error("Must provide isometric level tile width & height.");
24782478
}
24792479

24802480
const objects: GameObj[] = [];
24812481
const offset = vec2(options.pos || vec2(0));
24822482

2483-
const halfTileWidth = Math.floor(options.tileWidth / 2);
2484-
const halfTileHeight = Math.floor(options.tileHeight / 2);
2483+
const halfTileWidth = Math.floor(options.width / 2);
2484+
const halfTileHeight = Math.floor(options.height / 2);
24852485

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

24942494
gridWidth() {
2495-
return options.tileWidth;
2495+
return options.width;
24962496
},
24972497

24982498
gridHeight() {
2499-
return options.tileHeight;
2499+
return options.height;
25002500
},
25012501

25022502
fromIsometricCoordsToWorldPos: (row: number, col: number): Vec2 => {
@@ -2547,11 +2547,11 @@ function addIsometricLevel(map: string[], options: IsometricLevelOpt): Isometric
25472547
},
25482548

25492549
width() {
2550-
return maxWidthInTiles * options.tileWidth;
2550+
return maxWidthInTiles * options.width;
25512551
},
25522552

25532553
height() {
2554-
return heightInTiles * options.tileHeight;
2554+
return heightInTiles * options.height;
25552555
},
25562556

25572557
destroy() {

src/types.ts

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

0 commit comments

Comments
 (0)