Calculator Tools Calculator Tools
Create

Interactive Counter

Nov 25, 2023

About this app

A fun and colorful interactive counter web app.

Number Run Merge 3D Math 0 Start Game

Related apps

Put this on your site

Source

                    <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Number Run Merge 3D Math</title>
<meta name="description" content="A fun and interactive 3D math merging number game.">
<meta name="keywords" content="math game, numbers, interactive, merge, 3D">

<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@700&display=swap" rel="stylesheet">

<style>
body {
font-family: 'Roboto', sans-serif;
background: linear-gradient(135deg, #ffec61, #f8a3b1);
color: #333;
text-align: center;
overflow: hidden;
}

.container {
position: relative;
width: 100vw;
height: 100vh;
overflow: hidden;
}

#game-area {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
perspective: 1000px;
}

.cube {
width: 100px;
height: 100px;
background: #eee;
display: flex;
align-items: center;
justify-content: center;
border-radius: 15px;
font-size: 2em;
transition: transform 0.5s ease;
}

.run-btn {
padding: 15px;
margin: 20px;
border: none;
border-radius: 25px;
background: #b0e0e6;
font-size: 1.5em;
transition: background 0.3s, transform 0.3s;
}

.run-btn:hover {
background: #87ceeb;
transform: scale(1.05);
}

#score {
font-size: 3em;
margin: 20px 0;
}
</style>

<script>
let score = 0;
let currentValue = 1;

function spawnCube() {
const cube = document.createElement('div');
cube.classList.add('cube');
cube.textContent = currentValue;
const positionX = (Math.random() * 400) - 200;
const positionY = (Math.random() * 400) - 200;
cube.style.transform = `translate3d(${positionX}px, ${positionY}px, 0)`;
document.getElementById('game-area').appendChild(cube);
setupCubeAnimation(cube);
}

function setupCubeAnimation(cube) {
cube.addEventListener('click', function() {
score += currentValue;
currentValue++;
updateScore();
cube.remove();
spawnCube();
});
}

function updateScore() {
document.getElementById('score').textContent = score;
}

function startGame() {
score = 0;
currentValue = 1;
updateScore();
document.getElementById('game-area').innerHTML = '';
spawnCube();
}

document.addEventListener('DOMContentLoaded', function() {
document.getElementById('start-btn').addEventListener('click', startGame);
});
</script>
</head>
<body>
<div class="container">
<div id="score">0</div>
<button id="start-btn" class="run-btn">Start Game</button>
<div id="game-area"></div>
</div>
</body>
</html>