Skip to content

Commit

Permalink
Add welcome message for player in main menu and adjust rendering opac…
Browse files Browse the repository at this point in the history
…ity (#138)
  • Loading branch information
MiguelRipoll23 authored Jan 4, 2025
1 parent 70f5d32 commit 230bda3
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
29 changes: 29 additions & 0 deletions src/screens/main-screen/main-menu-screen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ export class MainMenuScreen extends BaseGameScreen {
}

public override render(context: CanvasRenderingContext2D): void {
context.globalAlpha = this.opacity;
this.showWelcomePlayerName(context);
context.globalAlpha = 1;
super.render(context);
}

Expand Down Expand Up @@ -229,4 +232,30 @@ export class MainMenuScreen extends BaseGameScreen {
}
});
}

private showWelcomePlayerName(context: CanvasRenderingContext2D): void {
const playerName = this.gameController
.getGameState()
.getGamePlayer()
.getName();

// Draw text that says Hello
context.font = "bold 28px system-ui";
context.fillStyle = "white";
context.textAlign = "center";

context.fillText(
"HEY, YOU!",
this.canvas.width / 2,
this.canvas.height - 140
);

context.fillStyle = "#7ed321";

context.fillText(
`${playerName}`,
this.canvas.width / 2,
this.canvas.height - 100
);
}
}
5 changes: 0 additions & 5 deletions src/utils/player-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,4 @@ export class PlayerUtils {

return animal;
}

public static getColorByPingTime(_ping: number): string {
// TODO: implement logic to return color based on ping time
return "white";
}
}

0 comments on commit 230bda3

Please sign in to comment.