Skip to content

Commit

Permalink
Rename and lint isometricLevel interface to match levels
Browse files Browse the repository at this point in the history
  • Loading branch information
gugiserman committed Nov 26, 2021
1 parent 35bfd03 commit 023cb76
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/kaboom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down Expand Up @@ -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]
Expand Down
3 changes: 2 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 023cb76

Please sign in to comment.