Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>✦ ПяТнАшКе ✦</title>
- <style>
- html, body{
- height: 100%;
- margin: 0;
- }
- body {
- display: flex;
- justify-content: center;
- align-items: center;
- font-family: fantasy;
- }
- #field {
- background-color: pink;
- width: 400px;
- height: 400px;
- border-radius: 5px;
- position: relative;
- }
- .field__cell {
- width: 81.25px;
- height: 81.25px;
- border-radius: 3px;
- position: absolute;
- }
- .field__cell--null {
- background-color: hotpink;
- }
- .field__cell--tile {
- background-color: black;
- color: deeppink;
- font-size: 50px;
- font-weight: bold;
- font-family: Century Gothic;
- display: flex;
- justify-content: center;
- align-items: center;
- transition: left 0.5s ease, top 0.5 ease;
- }
- #modal {
- height: 100%;
- width: 100%;
- border-radius: inherit;
- visibility: hidden;
- opacity: 0;
- transition: opacity 1s ease;
- position: relative;
- z-index: 1;
- display: flex;
- align-items: center;
- justify-content: center;
- background-color: black;
- color: lightpink;
- font-size: 100px;
- }
- #modal {
- visibility: visible;
- opacity: 1;
- }
- </style>
- </head>
- <body>
- <div id="field"></div>
- <script>
- var tiles = [];
- var freeCell = {y: 3, x: 3};
- var shuffled = false;
- function createField() {
- var x, y, cell;
- for (y = 0; y < 4; ++y) {
- for (x = 0; x < 4; ++x) {
- cell = createCellNull();
- cell.y = y;
- cell.x = x;
- setCellOffset(cell);
- appendCell(cell);
- }
- }
- console.log("function createField is okey");
- }
- function createCellNull() {
- var cell = document.createElement("div");
- cell.classList.add("field__cell", "field__cell--null");
- console.log("function createCellNull is okey");
- return cell;
- }
- function setCellOffset(cell) {
- cell.style.left = (15 + (15 + 81.25) * cell.x) + "px";
- cell.style.top = (15 + (15 + 81.25) * cell.y) + "px";
- console.log("function setCellOffset is okey");
- }
- function appendCell(cell) {
- var field = document.getElementById("field");
- field.appendChild(cell);
- console.log("function appendCell is okey");
- }
- function createTiles() {
- var x, y, cell, n;
- for (y = 0; y < 4; ++y) {
- for (x = 0; x < 4; ++x) {
- n = y * 4 + x + 1;
- if(n < 16) {
- cell = createCellTile();
- cell.y = y;
- cell.x = x;
- cell.innerHTML = n;
- setCellOffset(cell);
- appendCell(cell);
- tiles.push(cell);
- }
- }
- }
- console.log("function createTiles is okey");
- }
- function createCellTile() {
- var cell = document.createElement("div");
- cell.classList.add("field__cell", "field__cell--tile");
- console.log("function createCellTile is okey");
- return cell;
- }
- createField();
- createTiles();
- animateTiles();
- shuffleTiles();
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement