Advertisement
kasougi

Untitled

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