Skip to content

Commit

Permalink
Add debug mode to draw game pointer in game loop service (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
MiguelRipoll23 authored Dec 9, 2024
1 parent cc6d4d0 commit a352262
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/services/game-loop-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,10 @@ export class GameLoopService {
this.gameFrame.getCurrentScreen()?.render(this.context);
this.gameFrame.getNextScreen()?.render(this.context);
this.gameFrame.getNotificationObject()?.render(this.context);

if (this.gameController.isDebugging()) {
this.drawGamePointer();
}
}

private listenForEvents(): void {
Expand All @@ -197,4 +201,20 @@ export class GameLoopService {
this.handleServerNotificationEvent.bind(this)
);
}

private drawGamePointer(): void {
const gamePointer = this.gameController.getGamePointer();

this.context.fillStyle = "rgba(148, 0, 211, 0.5)";
this.context.beginPath();
this.context.arc(
gamePointer.getX(),
gamePointer.getY(),
15,
0,
Math.PI * 2
);
this.context.closePath();
this.context.fill();
}
}

0 comments on commit a352262

Please sign in to comment.