Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions agent-test/templates/core3d/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="icon" href="./favicon.svg" type="image/svg+xml" />
<title>OpenGame 3D</title>
</head>
<body>
Expand Down
5 changes: 5 additions & 0 deletions agent-test/templates/core3d/public/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion agent-test/templates/core3d/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@ class GameApp {
private readonly gameOverUi = new GameOverUIScene();
private game?: GameScene;
private lastFrame = performance.now();
private ended = false;

async boot(): Promise<void> {
if (!this.container) throw new Error('Missing #game-container');
await this.preloader.load();
this.title.show(() => this.start());
window.addEventListener('resize', () => this.game?.resize());
window.addEventListener('keydown', (event) => {
if (event.code === 'Escape' && this.game) {
if (event.code === 'Escape' && this.game && !event.repeat && !this.ended) {
if (this.game.isPaused()) this.resume('GameScene');
else this.pause('GameScene');
}
Expand All @@ -45,10 +46,12 @@ class GameApp {
{
onProgress: (collected, total) => this.ui.update(collected, total),
onComplete: () => {
this.ended = true;
this.game?.setPaused(true);
this.completeUi.show(() => location.reload());
},
onGameOver: () => {
this.ended = true;
this.game?.setPaused(true);
this.gameOverUi.show(() => location.reload());
},
Expand Down