Memory game
How do I make an memory game?
What is a memory game? How do you make a memory game? This script and codes were developed by Maharajan on 26 January 2023, Thursday.
Memory game - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>memory game</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div class="game-container">
</div> <script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Memory game - Script Codes CSS Codes
.game-container
{ width:165px; height:150px;
}
.flipcontainer
{ width:50px; height:50px; position:relative; -webkit-perspective: 500px; /* Chrome, Safari, Opera */ perspective: 500px; display:inline-block; margin-left:5px; cursor:pointer;
}
.front-face,.back-face
{ width:100%; height:100%; position:absolute; left:0px; top:0px; background:blue; color:#fff;text-align:center;line-height:50px;
}
.back-face
{ background:green;
-webkit-transform: rotateX(-180deg); transform: rotateX(-180deg);
}
.front-face, .back-face { -webkit-backface-visibility: hidden; backface-visibility: hidden; -webkit-transition: -webkit-transform 1s; transition: transform 1s;
}
.flipped .front-face,.checked .front-face{ -webkit-transform: rotateX(-180deg); transform: rotateX(-180deg);
}
.flipped .back-face,.checked .back-face
{ -webkit-transform: rotateX(0); transform: rotateX(0);
}
.checked .back-face
{ opacity:.3
}
Memory game - Script Codes JS Codes
$(function() { checkdata=[]; var gamebox = [{ name: 'bird',value: 2 },{ name: 'animal', value:1}, {name: 'dove',value: 2}, {name: 'empty',value:12 },{name:'country',value:3},{name:'india',value:3},{name:'food',value:4}, {name:'biriyani',value:4},{name:'lion',value:1} ] gamebox.sort(function() { return 0.5 - Math.random() }); for(var i=0;i<gamebox.length;i++) { $('<div class="flipcontainer"><div class="front-face"></div>'+ '<div class="back-face">'+gamebox[i].name+'</div></div>').appendTo($('.game-container')).data('checkans',gamebox[i].value); } $('.flipcontainer').on('click',function(e) { if(!$(this).hasClass('flipped')) { e.preventDefault(); $(this).toggleClass('flipped'); checkdata.push($(this).data('checkans')) if(checkdata.length > 1) { if(checkdata[0]==checkdata[1]) { setTimeout(function() { $('.flipped').addClass('checked'); $('.game-container > .flipcontainer').delay('100000').removeClass('flipped');; checkdata=[]; alert('matched')
},500); } else { setTimeout(function() { $('.game-container > .flipcontainer').delay('100000').removeClass('flipped') checkdata=[];
},500); } } console.log(checkdata); } });
});
Developer | Maharajan |
Username | mhrjnsa1 |
Uploaded | January 26, 2023 |
Rating | 3 |
Size | 2,424 Kb |
Views | 4,048 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Circle loader | 1,799 Kb |
Parallax slider | 1,936 Kb |
Drop down options disable | 1,723 Kb |
Pure css loader | 2,407 Kb |
Sound waves | 1,738 Kb |
Simeple snake design | 1,913 Kb |
Notification | 2,125 Kb |
Simple register | 2,505 Kb |
Change background while click and hover | 1,740 Kb |
Boom | 1,794 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Slider for stackoverflow | KKOKU | 3,222 Kb |
Nested flexbox layout for library catalog | Boycetrus | 3,271 Kb |
My three.js practice | Esambino | 3,203 Kb |
Exploring css spinners | Akagr | 3,569 Kb |
Toolbar | Onsen | 5,414 Kb |
Basic HTML Slideshow | Tomhodgins | 3,386 Kb |
SVG hamburger menu button | Elifitch | 2,602 Kb |
Shop Talk logo made in CSS | Hugo | 19,368 Kb |
AOR site logo | Thatbram | 2,527 Kb |
A Pen by Jess | Jessamyne | 5,100 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!