You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
246 lines
6.8 KiB
246 lines
6.8 KiB
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>I love X Engine</title>
|
|
<style>
|
|
body {
|
|
margin: 0;
|
|
padding: 0;
|
|
background: #000;
|
|
color: #fff;
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
height: 100vh;
|
|
font-family: Arial, sans-serif;
|
|
overflow: hidden;
|
|
}
|
|
|
|
#game {
|
|
text-align: center;
|
|
}
|
|
|
|
.welcome-screen {
|
|
opacity: 1;
|
|
transition: opacity 0.5s;
|
|
}
|
|
|
|
.welcome-screen.hidden {
|
|
opacity: 0;
|
|
}
|
|
|
|
h1 {
|
|
font-size: 48px;
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
.start-message {
|
|
font-size: 24px;
|
|
color: #aaa;
|
|
}
|
|
|
|
.hidden {
|
|
display: none;
|
|
}
|
|
|
|
#gameCanvas {
|
|
border: 1px solid #333;
|
|
background: #000;
|
|
width: 100vw;
|
|
height: 100vh;
|
|
position: fixed;
|
|
top: 0;
|
|
left: 0;
|
|
}
|
|
|
|
.loader {
|
|
width: 48px;
|
|
height: 48px;
|
|
border: 5px solid #ffffff;
|
|
border-bottom-color: transparent;
|
|
border-radius: 50%;
|
|
display: inline-block;
|
|
box-sizing: border-box;
|
|
animation: rotation 1s linear infinite;
|
|
margin-bottom: 15px;
|
|
}
|
|
|
|
@keyframes rotation {
|
|
0% { transform: rotate(0deg); }
|
|
100% { transform: rotate(360deg); }
|
|
}
|
|
|
|
#loading {
|
|
text-align: center;
|
|
}
|
|
|
|
#loading p {
|
|
font-size: 18px;
|
|
color: #aaa;
|
|
}
|
|
|
|
#pauseMenu {
|
|
position: fixed;
|
|
top: 50%;
|
|
left: 50%;
|
|
transform: translate(-50%, -50%);
|
|
background: rgba(0, 0, 0, 0.9);
|
|
padding: 30px;
|
|
border-radius: 10px;
|
|
border: 1px solid #333;
|
|
text-align: center;
|
|
z-index: 1000;
|
|
}
|
|
|
|
#pauseMenu h2 {
|
|
font-size: 32px;
|
|
margin-bottom: 20px;
|
|
color: #fff;
|
|
}
|
|
|
|
.menu-buttons {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 10px;
|
|
}
|
|
|
|
.menu-buttons button {
|
|
background: #333;
|
|
color: #fff;
|
|
border: none;
|
|
padding: 15px 30px;
|
|
font-size: 18px;
|
|
border-radius: 5px;
|
|
cursor: pointer;
|
|
transition: background-color 0.3s;
|
|
}
|
|
|
|
.menu-buttons button:hover {
|
|
background: #444;
|
|
}
|
|
|
|
.menu-buttons button:active {
|
|
background: #555;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div id="game">
|
|
<div id="welcome" class="welcome-screen">
|
|
<h1>Welkom bij I love X!</h1>
|
|
<p class="start-message">Druk op SPATIE om te beginnen</p>
|
|
</div>
|
|
<canvas id="gameCanvas" class="hidden"></canvas>
|
|
<div id="loading" class="hidden">
|
|
<div class="loader"></div>
|
|
<p>Loading... <span id="progress">0%</span></p>
|
|
</div>
|
|
<div id="pauseMenu" class="hidden">
|
|
<h2>Pauze</h2>
|
|
<div class="menu-buttons">
|
|
<button onclick="resumeGame()">Doorgaan</button>
|
|
<button onclick="restartGame()">Opnieuw</button>
|
|
<button onclick="quitGame()">Afsluiten</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
const { ipcRenderer } = require('electron');
|
|
|
|
// Game states
|
|
const STATES = {
|
|
WELCOME: 'welcome',
|
|
LOADING: 'loading',
|
|
PLAYING: 'playing',
|
|
PAUSED: 'paused',
|
|
ERROR: 'error'
|
|
};
|
|
|
|
let gameState = STATES.WELCOME;
|
|
let loadingProgress = 0;
|
|
|
|
// Error handling
|
|
window.onerror = function(msg, url, line) {
|
|
console.error(`Error: ${msg}\nAt: ${url}:${line}`);
|
|
gameState = STATES.ERROR;
|
|
ipcRenderer.send('error:occurred', { msg, url, line });
|
|
};
|
|
|
|
// Handle keyboard input
|
|
document.addEventListener('keydown', (event) => {
|
|
if (event.code === 'Space' && gameState === STATES.WELCOME) {
|
|
startGame();
|
|
} else if (event.code === 'Escape' && gameState === STATES.PLAYING) {
|
|
pauseGame();
|
|
}
|
|
});
|
|
|
|
// Start game
|
|
function startGame() {
|
|
gameState = STATES.LOADING;
|
|
document.getElementById('welcome').classList.add('hidden');
|
|
document.getElementById('loading').classList.remove('hidden');
|
|
// Start met een korte vertraging om de engine tijd te geven
|
|
setTimeout(() => {
|
|
document.getElementById('loading').classList.add('hidden');
|
|
document.getElementById('gameCanvas').classList.remove('hidden');
|
|
gameState = STATES.PLAYING;
|
|
}, 1000); // 1 seconde loading screen
|
|
}
|
|
|
|
function pauseGame() {
|
|
gameState = STATES.PAUSED;
|
|
document.getElementById('pauseMenu').classList.remove('hidden');
|
|
ipcRenderer.send('game:pause');
|
|
}
|
|
|
|
function resumeGame() {
|
|
gameState = STATES.PLAYING;
|
|
document.getElementById('pauseMenu').classList.add('hidden');
|
|
ipcRenderer.send('game:resume');
|
|
}
|
|
|
|
function restartGame() {
|
|
gameState = STATES.PLAYING;
|
|
document.getElementById('pauseMenu').classList.add('hidden');
|
|
ipcRenderer.send('game:restart');
|
|
}
|
|
|
|
function quitGame() {
|
|
// Reset game state
|
|
gameState = STATES.WELCOME;
|
|
loadingProgress = 0;
|
|
|
|
// Verberg game canvas en pauze menu
|
|
document.getElementById('gameCanvas').classList.add('hidden');
|
|
document.getElementById('pauseMenu').classList.add('hidden');
|
|
|
|
// Toon welkomstscherm
|
|
document.getElementById('welcome').classList.remove('hidden');
|
|
|
|
// Stuur event naar main process
|
|
ipcRenderer.send('game:return-to-welcome');
|
|
}
|
|
|
|
// Listen for engine events
|
|
ipcRenderer.on('engine:ready', (event, data) => {
|
|
console.log('Engine ready:', data);
|
|
});
|
|
|
|
ipcRenderer.on('game:started', () => {
|
|
console.log('Game started');
|
|
});
|
|
|
|
ipcRenderer.on('game:paused', () => {
|
|
console.log('Game paused');
|
|
});
|
|
|
|
ipcRenderer.on('error:engine', (event, error) => {
|
|
console.error('Engine error:', error);
|
|
gameState = STATES.ERROR;
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|