diff --git a/configs/default.json b/configs/default.json index e69de29..bd2af15 100644 --- a/configs/default.json +++ b/configs/default.json @@ -0,0 +1,5 @@ +{ + "name": "I love X (default)", + "assetsDir": "../assets/default", + "tickRate": 2 +} diff --git a/index.html b/index.html index c6f705b..3eb2b4f 100644 --- a/index.html +++ b/index.html @@ -1,10 +1,88 @@ - - I Love X Engine + I love X Engine + -

I Love X Engine (Electron)

+
+
+

Welkom bij I love X!

+

Druk op SPATIE om te beginnen

+
+
+ + diff --git a/main.js b/main.js index ef59314..da39b36 100644 --- a/main.js +++ b/main.js @@ -1,20 +1,23 @@ -const { app, BrowserWindow } = require('electron'); +const { app, BrowserWindow } = require('electron') const path = require('path'); +function createWindow () { + const win = new BrowserWindow({ + width: 800, + height: 600, + webPreferences: { + nodeIntegration: true, + contextIsolation: false + } + }) -function createWindow() { - const win = new BrowserWindow({ - width: 1024, - height: 768, - webPreferences: { - nodeIntegration: true, - contextIsolation: false, - } - }); - win.loadFile('index.html'); + win.loadFile('index.html') } -app.whenReady().then(createWindow); +app.whenReady().then(() => { + createWindow() +}) + +app.on('window-all-closed', function () { + if (process.platform !== 'darwin') app.quit() +}) -app.on('window-all-closed', () => { - if (process.platform !== 'darwin') app.quit(); -}); diff --git a/src/core/module-loader.js b/src/core/module-loader.js new file mode 100644 index 0000000..3ace645 --- /dev/null +++ b/src/core/module-loader.js @@ -0,0 +1,34 @@ +const fs = require('fs'); +const path = require('path'); + +class ModuleLoader { + constructor(modulesDir) { + this.modulesDir = path.resolve(modulesDir); + this.modules = {}; + } + + discover() { + if (!fs.existsSync(this.modulesDir)) return []; + const entries = fs.readdirSync(this.modulesDir, { withFileTypes: true }); + return entries.filter(e => e.isDirectory()).map(d => d.name); + } + + loadAll(engineContext) { + const names = this.discover(); + names.forEach(name => { + const modPath = path.join(this.modulesDir, name); + try { + const mod = require(modPath); + if (typeof mod.init === 'function') { + mod.init(engineContext); + } + this.modules[name] = mod; + } catch (err) { + console.error(`Failed to load module ${name}:`, err && err.stack ? err.stack : err); + } + }); + return this.modules; + } +} + +module.exports = ModuleLoader; diff --git a/src/index.js b/src/index.js index d4097de..e69de29 100644 --- a/src/index.js +++ b/src/index.js @@ -1,26 +0,0 @@ -const ConfigLoader = require('./core/config-loader'); -const AssetManager = require('./core/asset-manager'); -const EventBus = require('./core/event-bus'); -const GameLoop = require('./core/game-loop'); - -// Config pad kan via argumenten komen, standaard default.json -const configPath = process.argv[2] || '../configs/default.json'; -const config = ConfigLoader.load(configPath); - -const assetManager = new AssetManager(config.assetsDir || '../assets/default'); -assetManager.loadAssets(); - -const eventBus = new EventBus(); - -const gameLoop = new GameLoop({ - onUpdate: () => { - // Hier komt de game logica per tick - console.log('Game update'); - }, - onEnd: () => { - console.log('Game ended'); - } -}); - -console.log('Engine gestart met config:', configPath); -gameLoop.start(); diff --git a/src/main.js b/src/main.js new file mode 100644 index 0000000..e69de29 diff --git a/src/modules/finale/index.js b/src/modules/finale/index.js new file mode 100644 index 0000000..e69de29 diff --git a/src/modules/intro/index.js b/src/modules/intro/index.js new file mode 100644 index 0000000..139ce7c --- /dev/null +++ b/src/modules/intro/index.js @@ -0,0 +1,23 @@ +class IntroScreen { + constructor(engine) { + this.engine = engine; + this.state = 'welcome'; + } + + init() { + // Intro screen is now handled by renderer process (HTML/CSS) + this.engine.events.emit('intro:ready'); + } +} + +module.exports = { + init(engine) { + console.log('[module:intro] Initializing...'); + const intro = new IntroScreen(engine); + intro.init(); + + engine.events.on('intro:complete', () => { + console.log('[module:intro] Complete'); + }); + } +}; diff --git a/src/modules/levels/index.js b/src/modules/levels/index.js new file mode 100644 index 0000000..e69de29 diff --git a/src/renderer/index.html b/src/renderer/index.html new file mode 100644 index 0000000..e69de29