Here's a simple HTML/JS implementation of a hide-and-seek game with a push tool mechanic:
<!DOCTYPE html>
<html>
<head>
<title>Hide & Seek with Push Tool</title>
<style>
.game-grid {
display: grid;
grid-template-columns: repeat(10, 30px);
gap: 2px;
margin: 20px;
}
.cell {
width: 30px;
height: 30px;
background: #ddd;
border: 1px solid #999;
cursor: pointer;
}
.seeker { background: #6cf; }
.hider { background: #f66; }
.pushed { background: #fc6; }
.hidden { visibility: hidden; }
</style>
</head>
<body>
<div id="game"></div>
<p>Pushes left: <span id="pushes">5</span></p>
<p>History: <span id="history"></span></p>
<script>
const grid = document.getElementById('game');
const size = 10;
let hiderPos = {x: 0, y: 0};
let seekerPos = {x: 9, y: 9};
let pushesLeft = 5;
let moveHistory = [];
function createGrid() {
for(let y = 0; y < size; y++) {
for(let x = 0; x < size; x++) {
const cell = document.createElement('div');
cell.className = 'cell';
cell.onclick = () => push(x, y);
grid.appendChild(cell);
}
}
updatePositions();
}
function updatePositions() {
document.querySelectorAll('.cell').forEach(cell => {
cell.classList.remove('seeker', 'hider', 'pushed');
});
const seekerCell = document.querySelector(`.cell:nth-child(${seekerPos.y * size + seekerPos.x + 1})`);
seekerCell.classList.add('seeker');
if(!moveHistory.includes(`${hiderPos.x},${hiderPos.y}`)) {
const hiderCell = document.querySelector(`.cell:nth-child(${hiderPos.y * size + hiderPos.x + 1})`);
hiderCell.classList.add('hider');
}
}
function push(x, y) {
if(pushesLeft <= 0) return;
pushesLeft--;
document.getElementById('pushes').textContent = pushesLeft;
// Mark pushed cells
for(let i = -2; i <= 2; i++) {
for(let j = -2; j <= 2; j++) {
if(Math.abs(i) + Math.abs(j) <= 2) {
const targetX = x + i;
const targetY = y + j;
if(targetX >= 0 && targetX < size && targetY >= 0 && targetY < size) {
const cell = document.querySelector(`.cell:nth-child(${targetY * size + targetX + 1})`);
cell.classList.add('pushed');
}
}
}
}
// Check if seeker found hider
if(x === hiderPos.x && y === hiderPos.y) {
alert('Found the hider!');
resetGame();
return;
}
// Hider moves
moveHider();
moveHistory.push(`${hiderPos.x},${hiderPos.y}`);
if(moveHistory.length > 5) moveHistory.shift();
document.getElementById('history').textContent = moveHistory.join(' → ');
// Update positions
updatePositions();
if(pushesLeft <= 0) {
alert('Out of pushes! Hider wins!');
resetGame();
}
}
function moveHider() {
const directions = [
{x: hiderPos.x + 1, y: hiderPos.y},
{x: hiderPos.x - 1, y: hiderPos.y},
{x: hiderPos.x, y: hiderPos.y + 1},
{x: hiderPos.x, y: hiderPos.y - 1}
].filter(pos =>
pos.x >= 0 && pos.x < size &&
pos.y >= 0 && pos.y < size
);
hiderPos = directions[Math.floor(Math.random() * directions.length)];
}
function resetGame() {
hiderPos = {x: Math.floor(Math.random() * size), y: Math.floor(Math.random() * size)};
seekerPos = {x: 9, y: 9};
pushesLeft = 5;
moveHistory = [];
document.getElementById('pushes').textContent = pushesLeft;
document.getElementById('history').textContent = '';
updatePositions();
}
// Initialize game
createGrid();
resetGame();
</script>
</body>
</html>
This implementation features:
- A 10x10 grid where the hider starts at a random position
- The seeker starts at the bottom-right corner
- Push tool mechanics:
- Click any cell to push in a 2-cell radius (cross-shaped area)
- Limited to 5 pushes
- Shows push history
- Hider moves to a random adjacent cell after each push
- Win conditions:
- Seeker wins by pushing the hider's current position
- Hider wins if seeker runs out of pushes
The game uses CSS grid for layout and has visual indicators for:
- Seeker position (blue)
- Hider position (red)
- Pushed cells (orange)
- Hidden cells (invisible when not active)
To play:
- The hider starts at a random position
- Click cells to use the push tool and try to locate the hider
- The hider moves after each push
- Track movement history to predict hider's location
The game will alert you when the hider is found or when you run out of pushes.