Move four invocations of withCamera
This commit is contained in:
		| @@ -1,24 +1,15 @@ | ||||
| import { withCamera } from "./layout.ts"; | ||||
| import { getHuntMode } from "./huntmode.ts"; | ||||
| import { getHud } from "./hud.ts"; | ||||
|  | ||||
| export class Gameplay { | ||||
|   update() { | ||||
|     withCamera("Gameplay", () => { | ||||
|       getHuntMode().update(); | ||||
|     }); | ||||
|     withCamera("HUD", () => { | ||||
|       getHud().update(); | ||||
|     }); | ||||
|     getHuntMode().update(); | ||||
|     getHud().update(); | ||||
|   } | ||||
|  | ||||
|   draw() { | ||||
|     withCamera("Gameplay", () => { | ||||
|       getHuntMode().draw(); | ||||
|     }); | ||||
|     withCamera("HUD", () => { | ||||
|       getHud().draw(); | ||||
|     }); | ||||
|     getHuntMode().draw(); | ||||
|     getHud().draw(); | ||||
|   } | ||||
|  | ||||
|   get blocksHud(): boolean { | ||||
|   | ||||
							
								
								
									
										13
									
								
								src/hud.ts
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								src/hud.ts
									
									
									
									
									
								
							| @@ -5,15 +5,26 @@ import { ALL_STATS } from "./datatypes.ts"; | ||||
| import { getPlayerProgress } from "./playerprogress.ts"; | ||||
| import { getHuntMode } from "./huntmode.ts"; | ||||
| import { getStateManager } from "./statemanager.ts"; | ||||
| import {withCamera} from "./layout.ts"; | ||||
|  | ||||
| export class Hud { | ||||
|   get size(): Size { | ||||
|     return new Size(96, 176); | ||||
|   } | ||||
|  | ||||
|   update() {} | ||||
|  | ||||
|   update() { | ||||
|     withCamera("HUD", () => { this.#update() }); | ||||
|   } | ||||
|  | ||||
|   draw() { | ||||
|     withCamera("HUD", () => { this.#draw() }); | ||||
|   } | ||||
|  | ||||
|  | ||||
|   #update() {} | ||||
|  | ||||
|   #draw() { | ||||
|     D.fillRect(new Point(-4, -4), this.size.add(new Size(8, 8)), BG_OUTER); | ||||
|     D.drawText(getPlayerProgress().name, new Point(0, 0), FG_BOLD); | ||||
|     D.drawText(`Level ${getHuntMode().getDepth()}`, new Point(0, 16), FG_TEXT); | ||||
|   | ||||
| @@ -14,6 +14,7 @@ import { Architecture, LoadedNewMap } from "./newmap.ts"; | ||||
| import { FLOOR_CELL_SIZE, GridArt } from "./gridart.ts"; | ||||
| import { shadowcast } from "./shadowcast.ts"; | ||||
| import { getCheckModal } from "./checkmodal.ts"; | ||||
| import {withCamera} from "./layout.ts"; | ||||
|  | ||||
| export class HuntMode { | ||||
|   map: LoadedNewMap; | ||||
| @@ -88,6 +89,13 @@ export class HuntMode { | ||||
|  | ||||
|   // draw | ||||
|   update() { | ||||
|     withCamera("Gameplay", () => { this.#update() }); | ||||
|   } | ||||
|   draw() { | ||||
|     withCamera("Gameplay", () => { this.#draw() }); | ||||
|   } | ||||
|  | ||||
|   #update() { | ||||
|     this.frame += 1; | ||||
|     this.drawpile.clear(); | ||||
|  | ||||
| @@ -138,7 +146,7 @@ export class HuntMode { | ||||
|     ); | ||||
|   } | ||||
|  | ||||
|   draw() { | ||||
|   #draw() { | ||||
|     this.drawpile.draw(); | ||||
|   } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user