alt-r to redraw graphics

This commit is contained in:
evanpelle
2024-12-25 16:33:59 -08:00
parent 99e5a62ba6
commit fbdf26cff8
7 changed files with 52 additions and 15 deletions
+6 -6
View File
@@ -44,14 +44,9 @@ export class UnitLayer implements Layer {
}
init(game: Game) {
this.canvas = document.createElement('canvas');
this.context = this.canvas.getContext("2d");
this.canvas.width = this.game.width();
this.canvas.height = this.game.height();
this.eventBus.on(UnitEvent, e => this.onUnitEvent(e));
this.eventBus.on(AlternateViewEvent, e => this.onAlternativeViewEvent(e))
this.redraw()
}
renderLayer(context: CanvasRenderingContext2D) {
@@ -71,6 +66,11 @@ export class UnitLayer implements Layer {
redraw() {
this.canvas = document.createElement('canvas');
this.context = this.canvas.getContext("2d");
this.canvas.width = this.game.width();
this.canvas.height = this.game.height();
for (const unit of this.game.units()) {
this.onUnitEvent(new UnitEvent(unit, unit.tile()))
}