Colorful Number Grid Game
About this app
Engage in a fun and interactive number grid game where you can test your speed and agility. Match pairs of numbers in an exciting and colorful interface!
Colorful Number Grid Game
Related apps
Put this on your site
Source
<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>Colorful Number Grid Game</title>
<meta name="description" content="Engage in a fun and interactive number grid game where you can test your speed and agility. Match pairs of numbers in an exciting and colorful interface!">
<meta name="keywords" content="number game, fun game, interactive, colorful grid, match numbers">
<!-- Libraries -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.min.js" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6.6.0/css/fontawesome.min.css" crossorigin="anonymous">
<script type="text/javascript">
try {
document.addEventListener("DOMContentLoaded", function() {
const mainContainer = $("#main-container");
let numbers = [];
let selected = [];
let matchedCount = 0;
function initGame() {
numbers = Array.from(Array(36).keys()).map(num => Math.floor(num / 2)); // 0-17 each number twice
numbers.sort(() => Math.random() - 0.5);
renderGrid();
}
function renderGrid() {
mainContainer.empty();
for (let i = 0; i < 36; i++) {
let card = $('<div class="card col-2 m-1" data-index="'+i+'"></div>').css({
'width': '60px',
'height': '60px',
'display': 'flex',
'align-items': 'center',
'justify-content': 'center',
'font-size': '24px',
'background-color': '#ffcc00',
'cursor': 'pointer',
'border-radius': '10px'
}).text('');
card.on('click', function() {
if (selected.length < 2 && !$(this).hasClass('matched')) {
const index = $(this).data('index');
$(this).text(numbers[index]).css('background-color', '#4caf50');
selected.push({index: index, number: numbers[index]});
if (selected.length === 2) {
checkForMatch();
}
}
});
mainContainer.append(card);
}
}
function checkForMatch() {
setTimeout(() => {
if (selected[0].number === selected[1].number) {
$(`.card[data-index='${selected[0].index}'], .card[data-index='${selected[1].index}']`).addClass('matched').css('background-color', '#2196F3');
matchedCount++;
if (matchedCount === 18) {
alert('Congratulations, you found all matches!');
resetGame();
}
} else {
$(`.card[data-index='${selected[0].index}'], .card[data-index='${selected[1].index}']`).text('').css('background-color', '#ffcc00');
}
selected = [];
}, 1000);
}
function resetGame() {
matchedCount = 0;
initGame();
}
initGame();
});
} catch (error) {
throw error;
}
</script>
<style>
body {
background: linear-gradient(to bottom, #ece9e6, #ffffff);
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
#main-container {
display: flex;
flex-wrap: wrap;
max-width: 450px;
}
.card {
transition: background-color 0.3s, transform 0.3s;
}
.card:hover {
transform: scale(1.05);
}
</style>
</head>
<body>
<div id="main-container" class="container">
<!-- App HTML Goes Here -->
</div>
</body>
</html>
NEW APPS
These are apps made by the community!