blob: 4da7af8e2c3139379d8bf2866a282d29440230e7 (
plain) (
tree)
blob is binary.
<elioat@tilde.institute> 2024-07-07 09:57:36 -0400
committer elioat <elioat@tilde.institute> 2024-07-07 09:57:36 -0400
*' href='/elioat/tour/commit/js/puzzle-dungeon/index.html?id=9ccf05179c946355646de2a94cab14b54bc6d87f'>9ccf051
^
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Puzzle Dungeon</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body, html {
font-size: 22px;
background-color: #f0f0f0;
margin: 0;
padding: 0 1em;
max-width: 100%;
overflow-x: hidden; /* a stupid hack to say "no no no" to horizontal scrolling */
display: block;
}
canvas {
border: 1px solid #2d2d2d;
display: block;
margin: 0 auto;
}
form#commandForm {
padding: 0 1em;
display: block;
margin: 0 auto;
max-width: 28em;
width: 100%;
}
textarea#commands {
display: block;
margin: 0 auto;
width: 100%;
font-size: 16px;
}
</style>
</head>
<body>
<p>
<span id="playerHealth">Health: 10</span> /
<span id="playerPower">Power: 10</span> /
<span id="playerLevel">Level: 0</span> /
<span id="playerPosition">(0, 0)</span> /
<a href="about.html">About</a>
</p>
<canvas id="gameCanvas"></canvas>
<p id="par">Par:</p>
<p id="playerInventory">Inventory: []</p>
<form id="commandForm">
<textarea id="commands" rows="7" cols="30"></textarea><br>
<button type="submit">Submit</button>
</form>
<script type="module">
import { parseCommands } from './parser.js';
import { initializeGame, resizeCanvas, player, alertGameOver, levelPar, updatePlayerStatus } from './game.js';
document.getElementById('commandForm').addEventListener('submit', function(event) {
event.preventDefault();
player.par = player.par + 1;
console.log(`Par: ${levelPar}`);
updatePlayerStatus();
const commands = document.getElementById('commands').value;
if (player.par === levelPar) {
alertGameOver();
return;
}
parseCommands(commands);
document.getElementById('commands').value = '';
});
window.addEventListener('resize', resizeCanvas);
initializeGame();
</script>
</body>
</html>
|