Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <style>
- html,
- body {
- margin: 0;
- padding: 0;
- background: #faf8ef;
- color: #776e65;
- font-family: clear sans, helvetica neue, Arial, sans-serif;
- font-size: 18px
- }
- body {
- margin: 80px 0
- }
- .container {
- width: 500px;
- margin: 0 auto
- }
- .game-container {
- margin-left: 8px;
- /*margin-top: 40px;*/
- position: relative;
- padding: 15px 0px 15px 15px;
- cursor: default;
- touch-action: none;
- background: #f4f4f49e;
- border-radius: 6px;
- width: 485px;
- height: 500px;
- box-sizing: border-box
- }
- .grid-container {
- /*position: absolute;*/
- z-index: 1
- }
- .grid-row {
- margin-bottom: 15px
- }
- .grid-row:last-child {
- margin-bottom: 0
- }
- .grid-row:after {
- content: "";
- display: block;
- clear: both
- }
- .tile {
- font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
- width: 102px;
- height: 102px;
- margin-right: 15px;
- float: left;
- border-radius: 3px;
- background: rgba(238, 228, 218, 0.35);
- display: grid;
- place-items: center;
- font-weight: bold;
- font-size: 25px;
- }
- .two {
- background-color: #eee4da;
- font-size: 45px;
- }
- .four {
- background-color: #ede0c8;
- font-size: 45px;
- }
- .eight {
- background-color: #d4d700;
- font-size: 45px;
- }
- .sixteen {
- background-color: #80b918;
- font-size: 45px;
- }
- .thirtytwo {
- background-color: #2b863f;
- font-size: 45px;
- }
- .sixtyfour {
- background-color: #1d915f;
- font-size: 45px;
- }
- .onetwoeight {
- background-color: #1ed1af;
- font-size: 45px;
- }
- .twofivesix {
- background-color: #049a8f;
- font-size: 45px;
- }
- .fiveonetwo {
- background-color: #f77f00;
- font-size: 45px;
- }
- .onezerotwofour {
- background-color: #de121d;
- font-size: 35px;
- }
- .twozerofoureight {
- background-color: #e7e247;
- font-size: 35px;
- }
- .heading {
- padding: 0 8px 0 8px;
- }
- .game-intro {
- padding: 0 8px 0 8px;
- }
- .heading:after {
- content: "";
- display: block;
- clear: both;
- }
- .heading .title {
- font-size: 80px;
- font-weight: 700;
- margin: 0;
- display: block;
- float: left;
- }
- .heading .title a {
- text-decoration: none;
- }
- .scores-container {
- float: right;
- text-align: right;
- }
- .score-container,.best-container {
- position: relative;
- display: inline-block;
- background: #f4f4f49e;
- padding: 15px 25px;
- font-size: 25px;
- height: 25px;
- line-height: 47px;
- font-weight: 700;
- border-radius: 3px;
- color: #fff;
- margin-top: 8px;
- text-align: center;
- }
- .score-container:after,.best-container:after {
- position: absolute;
- width: 100%;
- top: 10px;
- left: 0;
- text-transform: uppercase;
- font-size: 13px;
- line-height: 13px;
- text-align: center;
- color: #eee4da;
- }
- .score-container .score-addition,.best-container .score-addition {
- position: absolute;
- right: 30px;
- color: red;
- font-size: 25px;
- line-height: 25px;
- font-weight: 700;
- color: rgba(119,110,101,.9);
- z-index: 100;
- -webkit-animation: move-up 600ms ease-in;
- -moz-animation: move-up 600ms ease-in;
- animation: move-up 600ms ease-in;
- -webkit-animation-fill-mode: both;
- -moz-animation-fill-mode: both;
- animation-fill-mode: both;
- }
- .score-container:after {
- content: "Score";
- }
- .best-container:after {
- content: "Best";
- }
- /*.game-intro {*/
- /* float: left;*/
- /* line-height: 42px;*/
- /* margin-bottom: 0;*/
- /*}*/
- @media screen and (max-width:520px) {
- html,
- body {
- font-size: 15px
- }
- body {
- margin: 20px 0;
- padding: 0 20px
- }
- .container {
- width: 280px;
- margin: 0 auto
- }
- .game-container {
- margin-left: 6px;
- /*margin-top: 17px;*/
- position: relative;
- padding: 10px 0 10px 10px;
- cursor: default;
- touch-action: none;
- background: #f4f4f49e;
- border-radius: 6px;
- width: 278px;
- height: 280px;
- box-sizing: border-box
- }
- .grid-container {
- position: absolute;
- z-index: 1
- }
- .grid-row {
- margin-bottom: 10px
- }
- .grid-row:last-child {
- margin-bottom: 0
- }
- .grid-row:after {
- content: "";
- display: block;
- clear: both
- }
- .tile {
- width: 55px;
- height: 55px;
- margin-right: 12px;
- float: left;
- border-radius: 3px;
- background: rgba(238, 228, 218, .35)
- }
- .two {
- background-color: #eee4da;
- font-size: 25px;
- }
- .four {
- background-color: #ede0c8;
- font-size: 25px;
- }
- .eight {
- background-color: #d4d700;
- font-size: 25px;
- }
- .sixteen {
- background-color: #80b918;
- font-size: 25px;
- }
- .thirtytwo {
- background-color: #2b863f;
- font-size: 25px;
- }
- .sixtyfour {
- background-color: #1d915f;
- font-size: 25px;
- }
- .onetwoeight {
- background-color: #1ed1af;
- font-size: 25px;
- }
- .twofivesix {
- background-color: #049a8f;
- font-size: 25px;
- }
- .fiveonetwo {
- background-color: #f77f00;
- font-size: 25px;
- }
- .onezerotwofour {
- background-color: #f77f00;
- font-size: 15px;
- }
- .twozerofoureight {
- background-color: #e7e247;
- font-size: 15px;
- }
- .heading {
- margin-bottom: 10px;
- }
- .heading {
- padding: 0 6px 0 6px;
- }
- .game-intro {
- padding: 0 6px 0 6px;
- margin-bottom: 10px;
- }
- /*.game-intro {*/
- /* width: 55%;*/
- /* display: block;*/
- /* box-sizing: border-box;*/
- /* line-height: 1.65;*/
- /*}*/
- }
- .title {
- float: none;
- }
- .heading .title {
- float: left;
- }
- .right {
- float: right;
- }
- .left {
- float: left;
- }
- .clearfix {
- clear: both;
- }
- .play-now {
- margin-top: 22px;
- }
- .play-now a {
- border-radius: 6px;
- padding: 12px;
- text-decoration: none;
- background-color: #bbada0;
- color: #fff;
- }
- .game-intro {
- font-size: 17px;
- margin-bottom: 10px;
- }
- .game-intro a {
- margin-right: 10px;
- }
- .play-now a:hover {
- text-decoration: underline;
- }
- </style>
- <svelte:window
- on:keydown={keyPress}
- on:touchstart={(event) => handleTouchStart(event)}
- on:touchend={(event) => handleTouchEnd(event)}
- />
- <!--<div class="header">-->
- <!-- <h1 class="title">2048</h1>-->
- <!-- <div class="reset-box">-->
- <!-- <h1 on:click={reset}>Перезапустить</h1>-->
- <!-- </div>-->
- <!--</div>-->
- <div class="container">
- <div class="heading">
- <h1 class="title"><a href='/'>2048</a></h1>
- <div class="scores-container">
- <div class="score-container">{game.score}</div>
- <div class="best-container">{game.best}</div>
- </div>
- </div>
- <div class="game-intro">
- <a class="restart-button" on:click={reset}>Заново</a>
- <a on:click={() => helpIsAsked = true}>Помощь</a>
- </div>
- <div class="game-container">
- <div class="game-messages">
- {#if gameIsOver}
- <GameIsOver on:close="{() => gameIsOver = false}">
- <h2 slot="header">
- Вы проиграли
- Ваш счет: {game.score}
- Ваш рекорд: {game.best}
- </h2>
- Хотите попробовать снова?
- <button on:click={() => reset()}>
- Начать заново
- </button>
- </GameIsOver>
- {/if}
- {#if gameIsWon}
- <Win on:close="{() => gameIsWon = false}">
- <h2 slot="header">
- Поздравляем вы выиграли! Но вы можете продолжать игру
- </h2>
- </Win>
- {/if}
- {#if helpIsAsked}
- <Help on:close="{() => helpIsAsked = false}">
- <h2 slot="header">
- 2048 Правила игры
- </h2>
- 2048 - головоломка, в которой нужно соединять одинаковые числа,
- перемещая их влево, вправо, вверх или вниз.
- После каждого хода на поле в случайном месте появляется либо 2 либо 4.
- Чтобы выиграть нужно, чтобы одно из чисел стало равным 2048.
- </Help>
- {/if}
- </div>
- <div autofocus class="grid-container">
- {#each numbers as arr, i}
- <div class="grid-row">
- {#each arr as num, i}
- <div
- class="tile {num === 2 ? 'two' : num === 4 ? 'four' : num === 8 ? 'eight' : num === 16 ? 'sixteen' :
- num === 32 ? 'thirtytwo' : num === 64 ? 'sixtyfour' : num === 128 ? 'onetwoeight' :
- num === 256 ? 'twofivesix' : num === 512 ? 'fiveonetwo' : num === 1024 ? 'onezerotwofour' :
- num === 2048 ? 'twozerofoureight' : ''}">
- {num !== 0 ? num : ''}
- </div>
- {/each}
- </div>
- {/each}
- </div>
- </div>
- </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement