JSFiddle - React, Tailwind, and code Playground
by awesomespaceman
HTML
<!DOCTYPE html>
<html>
<head>
<title>
</title>
<link rel="stylesheet" href="style.css">
</head>
<body id="ht">
<!-- astea 2 sunt puse ca indexarea claselor sa inceapa de la 1 -->
<div class="checker white_checker" style="display:none"> </div>
<div class="checker black_checker" style="display:none"> </div>
<div class="square" style="display: none" id="ht"> </div>
<div class="black_background" id="black_background"> </div>
<div class="score" id="score">
<br>
</div>
<div class="table" id="table">
<div class="checker white_checker">♛ </div>
<div class="checker white_checker">♛ </div>
<div class="checker white_checker">♛ </div>
<div class="checker white_checker">♛ </div>
<div class="checker white_checker">♛ </div>
<div class="checker white_checker">♛ </div>
<div class="checker white_checker">♛ </div>
<div class="checker white_checker">♛ </div>
<div class="checker white_checker">♛ </div>
<div class="checker white_checker">♛ </div>
<div class="checker white_checker">♛ </div>
<div class="checker white_checker">♛ </div>
<div class="checker black_checker"> </div>
<div class="checker black_checker"> </div>
<div class="checker black_checker"> </div>
<div class="checker black_checker"> </div>
<div class="checker black_checker"> </div>
<div class="checker black_checker"> </div>
<div class="checker black_checker"> </div>
<div class="checker black_checker"> </div>
<div class="checker black_checker"> </div>
<div class="checker black_checker"> </div>
<div class="checker black_checker"> </div>
<div class="checker black_checker"> </div>
<div class="square black_square"></div>
<div class="square white_square"> </div>
<div class="square black_square"> </div>
<div class="square...
CSS
body,
html {
transition: 1s ease-in-out;
width: 100%;
height: 100%;
margin: 0 0;
padding: 0 0;
}
.square {
float: left;
width: 80px;
height: 80px;
}
.white_square {
background-color: #F0D2B4;
}
.black_square {
background-color: #BA7A3A;
}
.clear_float {
clear: both;
}
.table {
position: relative;
width: 640px;
height: 640px;
margin: 0 auto;
}
.score {
background-color: #1aaaad;
color: white;
display: none;
font-size: 45px;
font-weight: 900;
height: 150px;
border-radius: 10%;
left: 0px;
letter-spacing: 1px;
margin: 0 auto;
padding-top: 30px;
overflow: hidden;
position: absolute;
right: 0px;
text-align: center;
top: 15%;
width: 200px;
z-index: 8;
font-family: Calibri, Candara, Segoe, 'Segoe UI', Optima, Arial, sans-serif;
-webkit-transition: 5s ease-in-out;
-moz-transition: 5s ease-in-out;
-o-transition: 5s ease-in-out;
transition: 5s ease-in-out;
}
.checker {
top: 10px;
left: 10px;
width: 54px;
height: 54px;
border-radius: 50%;
position: absolute;
border: 4px solid white;
cursor: pointer;
}
.white_checker {
background: #CC0000;
-webkit-transition: 0.3s ease-in-out;
-moz-transition: 0.3s ease-in-out;
-o-transition: 0.3s ease-in-out;
transition: 0.3s ease-in-out;
}
.black_checker {
}
.black_background {
position: fixed;
width: 100%;
height: 100%;
background-color: black;
opacity: 0.5;
z-index: 7;
display: none;
}
@media only screen and (max-width: 640px) {
.table {
width: 400px;
height: 400px;
}
.square {
width: 50px;
height: 50px;
}
.checker {
width: 32px;
height: 32px;
}
}
JavaScript
/*=========variabile globale=========================*/
var square_class = document.getElementsByClassName("square");
var white_checker_class = document.getElementsByClassName("white_checker");
var black_checker_class = document.getElementsByClassName("black_checker");
var table = document.getElementById("table");
var score = document.getElementById("score");
var black_background = document.getElementById("black_background");
var moveSound = document.getElementById("moveSound");
var winSound = document.getElementById("winSound");
var windowHeight = window.innerHeight ||
document.documentElement.clientHeight ||
document.body.clientHeight;;
var windowWidth = window.innerWidth ||
document.documentElement.clientWidth ||
document.body.clientWidth;
var moveLength = 80;
var moveDeviation = 10;
var Dimension = 1;
var selectedPiece, selectedPieceindex;
var upRight, upLeft, downLeft, downRight; // toate variantele posibile de mers pt o dama
var contor = 0,
gameOver = 0;
var bigScreen = 1;
var block = [];
var w_checker = [];
var b_checker = [];
var the_checker;
var oneMove;
var anotherMove;
var mustAttack = true;
var multiplier = 1 // 2 daca face saritura 1 in caz contrat
var tableLimit, reverse_tableLimit, moveUpLeft, moveUpRight, moveDownLeft, moveDownRight, tableLimitLeft, tableLimitRight;
/*================================*/
getDimension();
if (windowWidth > 640) {
moveLength = 80;
moveDeviation = 10;
} else {
moveLength = 50;
moveDeviation = 6;
}
/*================declararea claselor=========*/
var square_p = function(square, index) {
this.id = square;
this.ocupied = false;
this.pieceId = undefined;
this.id.onclick = function() {
makeMove(index);
}
}
var checker = function(piece, color, square) {
this.id = piece;
this.color = color;
this.king = false;
this.ocupied_square = square;
this.alive = true;
this.attack = false;
if (square % 8) {
this.coordX = square % 8;
this.coordY = Math.floor(square / 8) + 1;
...