xxxxxx
by velo_ninja
HTML
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Hexagonales Bienenwaben-Muster</title>
<style>
body {
display: flex;
justify-content: space-between;
padding: 20px;
}
#hexContainer {
width: 500px;
height: 500px;
border: 2px solid #333;
position: relative;
overflow: hidden;
}
#lifePanel {
width: 200px;
height: 500px;
border: 2px solid #333;
padding: 10px;
margin-left: 20px;
overflow-y: auto;
}
canvas {
cursor: default;
}
.lifeInfo {
margin: 10px 0;
padding: 5px;
border: 1px solid #ccc;
border-radius: 5px;
}
.orange-border {
border: 2px solid orange;
}
</style>
</head>
<body>
<div id="hexContainer"></div>
<div id="lifePanel">
<h3>Life Points</h3>
<div id="lifeDisplay">Hover over a red cell to see its life points.</div>
</div>
<script>
const hexSize = 20;
const hexWidth = 2 * hexSize;
const hexHeight = Math.sqrt(3) * hexSize;
const hexHorizontalSpacing = hexWidth * 0.95;
const hexVerticalSpacing = hexHeight;
const totalRows = 14;
const totalCols = 13;
const gridData = [];
let selectedBlueCell = null;
// Initialize grid with cell objects, each having a list of neighbors
function initializeGrid() {
for (let row = 0; row < totalRows; row++) {
gridData[row] = [];
for (let col = 0; col < totalCols; col++) {
gridData[row][col] = {
status: 'empty',
neighbors: calculateNeighbors(row, col),
lifePoints: 0
};
}
}
// Randomly assign...