Skip to content

Commit

Permalink
change: Consolidate debug geometry settings
Browse files Browse the repository at this point in the history
  • Loading branch information
eonarheim committed Jan 1, 2024
1 parent 1ae63f2 commit 1da7290
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).

### Changed

- All debug geometry settings are controlled from debug.collider now
- Removed dunder prefixed parameters from overrideable methods
- Tweaked debug draw to be less noisy by default
- Removed dependency on `ex.IsometricMap` in the `ex.IsometricEntityComponent`, this allows for greater flexibility when using the component when a map may not be known or constructed.
Expand Down
6 changes: 1 addition & 5 deletions src/engine/Debug/Debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,6 @@ export class Debug implements DebugFlags {
showSolidBounds: false,
solidBoundsColor: Color.fromHex('#8080807F'), // grayish
showColliderGeometry: true,
colliderGeometryColor: Color.Green,
showQuadTree: false
};

Expand All @@ -371,10 +370,7 @@ export class Debug implements DebugFlags {
showGrid: false,
gridColor: Color.Red,
gridWidth: 1,
showColliders: true,
colliderColor: Color.Green,
colliderLineWidth: 1,
colliderPointSize: .5
showColliderGeometry: true
};
}

Expand Down
15 changes: 9 additions & 6 deletions src/engine/TileMap/IsometricMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -443,11 +443,14 @@ export class IsometricMap extends Entity {
showGrid,
gridColor,
gridWidth,
showColliders,
colliderColor,
colliderLineWidth,
colliderPointSize
showColliderGeometry
} = debugFlags.isometric;

const {
geometryColor,
geometryLineWidth,
geometryPointSize
} = debugFlags.collider;
gfx.save();
gfx.z = this._getMaxZIndex() + 0.5;
if (showAll || showGrid) {
Expand All @@ -469,10 +472,10 @@ export class IsometricMap extends Entity {
gfx.drawCircle(this.tileToWorld(vec(tile.x, tile.y)), positionSize, positionColor);
}
}
if (showAll || showColliders) {
if (showAll || showColliderGeometry) {
for (const tile of this.tiles) {
for (const collider of tile.getColliders()) {
collider.debug(gfx, colliderColor, { lineWidth: colliderLineWidth, pointSize: colliderPointSize });
collider.debug(gfx, geometryColor, { lineWidth: geometryLineWidth, pointSize: geometryPointSize });
}
}
}
Expand Down
8 changes: 6 additions & 2 deletions src/engine/TileMap/TileMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -535,9 +535,13 @@ export class TileMap extends Entity {
showSolidBounds: showColliderBounds,
solidBoundsColor: colliderBoundsColor,
showColliderGeometry,
colliderGeometryColor,
showQuadTree
} = debugFlags.tilemap;
const {
geometryColor,
geometryLineWidth,
geometryPointSize
} = debugFlags.collider;
const width = this.tileWidth * this.columns * this.scale.x;
const height = this.tileHeight * this.rows * this.scale.y;
const pos = this.pos;
Expand Down Expand Up @@ -568,7 +572,7 @@ export class TileMap extends Entity {
gfx.restore();
if (showColliderGeometry) {
for (const collider of colliders) {
collider.debug(gfx, colliderGeometryColor);
collider.debug(gfx, geometryColor, { lineWidth: geometryLineWidth, pointSize: geometryPointSize });
}
}
}
Expand Down

0 comments on commit 1da7290

Please sign in to comment.