Advertisement
kasougi

Untitled

May 28th, 2022
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.42 KB | None | 0 0
  1. <style>
  2. html,
  3. body {
  4. margin: 0;
  5. padding: 0;
  6. background: #faf8ef;
  7. color: #776e65;
  8. font-family: clear sans, helvetica neue, Arial, sans-serif;
  9. font-size: 18px
  10. }
  11.  
  12. body {
  13. margin: 80px 0
  14. }
  15.  
  16. .container {
  17. width: 500px;
  18. margin: 0 auto
  19. }
  20.  
  21. .game-container {
  22. margin-left: 8px;
  23. /*margin-top: 40px;*/
  24. position: relative;
  25. padding: 15px 0px 15px 15px;
  26. cursor: default;
  27. touch-action: none;
  28. background: #f4f4f49e;
  29. border-radius: 6px;
  30. width: 485px;
  31. height: 500px;
  32. box-sizing: border-box
  33. }
  34.  
  35. .grid-container {
  36. /*position: absolute;*/
  37. z-index: 1
  38. }
  39.  
  40. .grid-row {
  41. margin-bottom: 15px
  42. }
  43.  
  44. .grid-row:last-child {
  45. margin-bottom: 0
  46. }
  47.  
  48. .grid-row:after {
  49. content: "";
  50. display: block;
  51. clear: both
  52. }
  53.  
  54. .tile {
  55. font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
  56. width: 102px;
  57. height: 102px;
  58. margin-right: 15px;
  59. float: left;
  60. border-radius: 3px;
  61. background: rgba(238, 228, 218, 0.35);
  62. display: grid;
  63. place-items: center;
  64. font-weight: bold;
  65. font-size: 25px;
  66. }
  67.  
  68. .two {
  69. background-color: #eee4da;
  70. font-size: 45px;
  71. }
  72. .four {
  73. background-color: #ede0c8;
  74. font-size: 45px;
  75. }
  76. .eight {
  77. background-color: #d4d700;
  78. font-size: 45px;
  79. }
  80. .sixteen {
  81. background-color: #80b918;
  82. font-size: 45px;
  83. }
  84. .thirtytwo {
  85. background-color: #2b863f;
  86. font-size: 45px;
  87. }
  88. .sixtyfour {
  89. background-color: #1d915f;
  90. font-size: 45px;
  91. }
  92. .onetwoeight {
  93. background-color: #1ed1af;
  94. font-size: 45px;
  95. }
  96. .twofivesix {
  97. background-color: #049a8f;
  98. font-size: 45px;
  99. }
  100. .fiveonetwo {
  101. background-color: #f77f00;
  102. font-size: 45px;
  103. }
  104. .onezerotwofour {
  105. background-color: #de121d;
  106. font-size: 35px;
  107. }
  108. .twozerofoureight {
  109. background-color: #e7e247;
  110. font-size: 35px;
  111. }
  112.  
  113. .heading {
  114. padding: 0 8px 0 8px;
  115. }
  116.  
  117. .game-intro {
  118. padding: 0 8px 0 8px;
  119. }
  120.  
  121. .heading:after {
  122. content: "";
  123. display: block;
  124. clear: both;
  125. }
  126.  
  127. .heading .title {
  128. font-size: 80px;
  129. font-weight: 700;
  130. margin: 0;
  131. display: block;
  132. float: left;
  133. }
  134.  
  135. .heading .title a {
  136. text-decoration: none;
  137. }
  138.  
  139. .scores-container {
  140. float: right;
  141. text-align: right;
  142. }
  143.  
  144. .score-container,.best-container {
  145. position: relative;
  146. display: inline-block;
  147. background: #f4f4f49e;
  148. padding: 15px 25px;
  149. font-size: 25px;
  150. height: 25px;
  151. line-height: 47px;
  152. font-weight: 700;
  153. border-radius: 3px;
  154. color: #fff;
  155. margin-top: 8px;
  156. text-align: center;
  157. }
  158.  
  159. .score-container:after,.best-container:after {
  160. position: absolute;
  161. width: 100%;
  162. top: 10px;
  163. left: 0;
  164. text-transform: uppercase;
  165. font-size: 13px;
  166. line-height: 13px;
  167. text-align: center;
  168. color: #eee4da;
  169. }
  170.  
  171. .score-container .score-addition,.best-container .score-addition {
  172. position: absolute;
  173. right: 30px;
  174. color: red;
  175. font-size: 25px;
  176. line-height: 25px;
  177. font-weight: 700;
  178. color: rgba(119,110,101,.9);
  179. z-index: 100;
  180. -webkit-animation: move-up 600ms ease-in;
  181. -moz-animation: move-up 600ms ease-in;
  182. animation: move-up 600ms ease-in;
  183. -webkit-animation-fill-mode: both;
  184. -moz-animation-fill-mode: both;
  185. animation-fill-mode: both;
  186. }
  187.  
  188. .score-container:after {
  189. content: "Score";
  190. }
  191.  
  192. .best-container:after {
  193. content: "Best";
  194. }
  195.  
  196. /*.game-intro {*/
  197. /* float: left;*/
  198. /* line-height: 42px;*/
  199. /* margin-bottom: 0;*/
  200. /*}*/
  201.  
  202. @media screen and (max-width:520px) {
  203. html,
  204. body {
  205. font-size: 15px
  206. }
  207.  
  208. body {
  209. margin: 20px 0;
  210. padding: 0 20px
  211. }
  212.  
  213.  
  214. .container {
  215. width: 280px;
  216. margin: 0 auto
  217. }
  218.  
  219. .game-container {
  220. margin-left: 6px;
  221. /*margin-top: 17px;*/
  222. position: relative;
  223. padding: 10px 0 10px 10px;
  224. cursor: default;
  225. touch-action: none;
  226. background: #f4f4f49e;
  227. border-radius: 6px;
  228. width: 278px;
  229. height: 280px;
  230. box-sizing: border-box
  231. }
  232.  
  233. .grid-container {
  234. position: absolute;
  235. z-index: 1
  236. }
  237.  
  238. .grid-row {
  239. margin-bottom: 10px
  240. }
  241.  
  242. .grid-row:last-child {
  243. margin-bottom: 0
  244. }
  245.  
  246. .grid-row:after {
  247. content: "";
  248. display: block;
  249. clear: both
  250. }
  251.  
  252. .tile {
  253. width: 55px;
  254. height: 55px;
  255. margin-right: 12px;
  256. float: left;
  257. border-radius: 3px;
  258. background: rgba(238, 228, 218, .35)
  259. }
  260.  
  261. .two {
  262. background-color: #eee4da;
  263. font-size: 25px;
  264. }
  265. .four {
  266. background-color: #ede0c8;
  267. font-size: 25px;
  268. }
  269. .eight {
  270. background-color: #d4d700;
  271. font-size: 25px;
  272. }
  273. .sixteen {
  274. background-color: #80b918;
  275. font-size: 25px;
  276. }
  277. .thirtytwo {
  278. background-color: #2b863f;
  279. font-size: 25px;
  280. }
  281. .sixtyfour {
  282. background-color: #1d915f;
  283. font-size: 25px;
  284. }
  285. .onetwoeight {
  286. background-color: #1ed1af;
  287. font-size: 25px;
  288. }
  289. .twofivesix {
  290. background-color: #049a8f;
  291. font-size: 25px;
  292. }
  293. .fiveonetwo {
  294. background-color: #f77f00;
  295. font-size: 25px;
  296. }
  297. .onezerotwofour {
  298. background-color: #f77f00;
  299. font-size: 15px;
  300. }
  301. .twozerofoureight {
  302. background-color: #e7e247;
  303. font-size: 15px;
  304. }
  305.  
  306. .heading {
  307. margin-bottom: 10px;
  308. }
  309.  
  310. .heading {
  311. padding: 0 6px 0 6px;
  312. }
  313.  
  314. .game-intro {
  315. padding: 0 6px 0 6px;
  316. margin-bottom: 10px;
  317. }
  318.  
  319. /*.game-intro {*/
  320. /* width: 55%;*/
  321. /* display: block;*/
  322. /* box-sizing: border-box;*/
  323. /* line-height: 1.65;*/
  324. /*}*/
  325. }
  326.  
  327. .title {
  328. float: none;
  329. }
  330.  
  331. .heading .title {
  332. float: left;
  333. }
  334.  
  335. .right {
  336. float: right;
  337. }
  338.  
  339. .left {
  340. float: left;
  341. }
  342.  
  343. .clearfix {
  344. clear: both;
  345. }
  346.  
  347. .play-now {
  348. margin-top: 22px;
  349. }
  350.  
  351. .play-now a {
  352. border-radius: 6px;
  353. padding: 12px;
  354. text-decoration: none;
  355. background-color: #bbada0;
  356. color: #fff;
  357. }
  358.  
  359. .game-intro {
  360. font-size: 17px;
  361. margin-bottom: 10px;
  362. }
  363.  
  364. .game-intro a {
  365. margin-right: 10px;
  366. }
  367.  
  368. .play-now a:hover {
  369. text-decoration: underline;
  370. }
  371.  
  372.  
  373. </style>
  374.  
  375. <svelte:window
  376. on:keydown={keyPress}
  377. on:touchstart={(event) => handleTouchStart(event)}
  378. on:touchend={(event) => handleTouchEnd(event)}
  379. />
  380.  
  381.  
  382. <!--<div class="header">-->
  383. <!-- <h1 class="title">2048</h1>-->
  384. <!-- <div class="reset-box">-->
  385. <!-- <h1 on:click={reset}>Перезапустить</h1>-->
  386. <!-- </div>-->
  387. <!--</div>-->
  388. <div class="container">
  389.  
  390. <div class="heading">
  391. <h1 class="title"><a href='/'>2048</a></h1>
  392. <div class="scores-container">
  393. <div class="score-container">{game.score}</div>
  394. <div class="best-container">{game.best}</div>
  395. </div>
  396. </div>
  397. <div class="game-intro">
  398. <a class="restart-button" on:click={reset}>Заново</a>
  399. <a on:click={() => helpIsAsked = true}>Помощь</a>
  400. </div>
  401.  
  402. <div class="game-container">
  403. <div class="game-messages">
  404. {#if gameIsOver}
  405. <GameIsOver on:close="{() => gameIsOver = false}">
  406. <h2 slot="header">
  407. Вы проиграли
  408. Ваш счет: {game.score}
  409. Ваш рекорд: {game.best}
  410. </h2>
  411.  
  412. Хотите попробовать снова?
  413.  
  414. <button on:click={() => reset()}>
  415. Начать заново
  416. </button>
  417. </GameIsOver>
  418. {/if}
  419. {#if gameIsWon}
  420. <Win on:close="{() => gameIsWon = false}">
  421. <h2 slot="header">
  422. Поздравляем вы выиграли! Но вы можете продолжать игру
  423. </h2>
  424. </Win>
  425. {/if}
  426. {#if helpIsAsked}
  427. <Help on:close="{() => helpIsAsked = false}">
  428. <h2 slot="header">
  429. 2048 Правила игры
  430. </h2>
  431. 2048 - головоломка, в которой нужно соединять одинаковые числа,
  432. перемещая их влево, вправо, вверх или вниз.
  433. После каждого хода на поле в случайном месте появляется либо 2 либо 4.
  434. Чтобы выиграть нужно, чтобы одно из чисел стало равным 2048.
  435. </Help>
  436. {/if}
  437. </div>
  438. <div autofocus class="grid-container">
  439.  
  440. {#each numbers as arr, i}
  441. <div class="grid-row">
  442. {#each arr as num, i}
  443. <div
  444. class="tile {num === 2 ? 'two' : num === 4 ? 'four' : num === 8 ? 'eight' : num === 16 ? 'sixteen' :
  445. num === 32 ? 'thirtytwo' : num === 64 ? 'sixtyfour' : num === 128 ? 'onetwoeight' :
  446. num === 256 ? 'twofivesix' : num === 512 ? 'fiveonetwo' : num === 1024 ? 'onezerotwofour' :
  447. num === 2048 ? 'twozerofoureight' : ''}">
  448. {num !== 0 ? num : ''}
  449. </div>
  450. {/each}
  451. </div>
  452. {/each}
  453. </div>
  454. </div>
  455. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement