diff --git a/js/exportGame.js b/js/exportGame.js index 8b13789..a2630c6 100644 --- a/js/exportGame.js +++ b/js/exportGame.js @@ -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;