Concentration Game

Developer
Size
2,427 Kb
Views
2,024

How do I make an concentration game?

This is a simple concentration game made with pure javascript without any library. In the boxes you will see social media icons. Can you find same social media icons repeatedly ?. What is a concentration game? How do you make a concentration game? This script and codes were developed by Krishna Babu on 11 January 2023, Wednesday.

Concentration Game Previews

Concentration Game - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Concentration Game</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div id="container"> <h1>Concentration Game</h1><p>This is a simple concentration game made with pure javascript without any library. In the boxes you will see social media icons. Can you find same social media icons repeatedly ?</p></br> <div class="holder"> <ul></ul> </div>
</div> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>

Concentration Game - Script Codes CSS Codes

*{margin:0; padding:0;}
body{background-color:#000;color:#fff;font-family:arial;}
#container{height:auto;width:100%;}
.holder{background-color:#777;width:515px;height:682px;margin:0 auto;position:relative;}
.holder ul{list-style:none;position:relative;float:left;}
.holder ul li{height:74px;width:74px;background-color:#000;margin:10px;float:left;margin-right:0px;margin-bottom:0px;}
.holder ul li div{height:74px;width:74px;background:url(http://flashadicts.com/clientdisplay/images/matching.png);opacity:0;}

Concentration Game - Script Codes JS Codes

$(document).ready(function(){ var array1 = []; var array2 = []; var val=0; var indexBox=-1; for(i=0; i<24; i++){ val = 7+(Math.round(Math.random()*5)*94); console.log(val); array1.push(val); array1.push(val); } for(i=0; i<48; i++){ //console.log(Math.round(Math.random()*(array1.length-1))); val = Math.round(Math.random()*(array1.length-1)); array2.push(array1[val]); array1.splice( val, 1); } for(i=0; i<48; i++){ $(".holder ul").append('<li><div style="background-position:-'+array2[i]+'px" data-pos='+array2[i]+'></div></li>'); } val=0; $(".holder ul li>div").click(function(){ $(this).css('opacity','1'); $(this).animate({opacity:1},500); if(val==0){ val = $(this).data("pos"); indexBox = $(this).parent('li').index(); }else{ if(val == $(this).data("pos")){ $('li:eq('+indexBox+')').animate({opacity:0},500); $(this).parent().animate({opacity:0},500); }else{ $(this).animate({opacity:0},500); $('li:eq('+indexBox+') div').animate({opacity:0},500); } val=0; } });
});
Concentration Game - Script Codes
Concentration Game - Script Codes
Home Page Home
Developer Krishna Babu
Username krishnab
Uploaded January 11, 2023
Rating 3
Size 2,427 Kb
Views 2,024
Do you need developer help for Concentration Game?

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!

Krishna Babu (krishnab) Script Codes
Create amazing marketing copy with AI!

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!