Skip to content

Commit

Permalink
Update exportGame.js
Browse files Browse the repository at this point in the history
  • Loading branch information
CleanCode-developer authored Dec 31, 2024
1 parent d50325a commit db5beeb
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions js/exportGame.js
Original file line number Diff line number Diff line change
@@ -1 +1,21 @@
import SceneManager from './sceneManager.js';

class ExportGame {
constructor(sceneManager) {
this.sceneManager = sceneManager;
document.getElementById('exportGame').addEventListener('click', () => this.export());
}

export() {
const gameState = JSON.stringify(this.sceneManager);
const blob = new Blob([gameState], { type: 'application/json' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'game.json';
a.click();
URL.revokeObjectURL(url);
}
}

export default ExportGame;

0 comments on commit db5beeb

Please sign in to comment.