{"id":299098,"date":"2020-02-22T15:00:14","date_gmt":"2020-02-22T15:00:14","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=299098"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2020-02-22T15:00:14","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=299098","title":{"rendered":"\u041a\u0440\u0435\u0441\u0442\u0438\u043a\u0438-\u043d\u043e\u043b\u0438\u043a\u0438 (PixiJS)"},"content":{"rendered":"\n<div class=\"post__text post__text-html\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/489490\/\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/c0\/xl\/3v\/c0xl3voe_muivcbhukxqze4l1f8.png\" alt=\"image\"><\/p>\n<p>  \u041e\u0434\u0438\u043d \u0440\u0430\u043d\u0438\u043c\u044b\u0439, \u0433\u043b\u0443\u043f\u044b\u0439, \u043c\u0435\u0447\u0442\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0432\u0435\u0440\u0441\u0442\u0430\u043b\u044c\u0449\u0438\u043a \u0440\u0435\u0448\u0438\u043b \u0441\u0442\u0430\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u043e\u043c \u0438 \u0443 \u043d\u0435\u0433\u043e \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0432\u044b\u0448\u043b\u043e\u2026 \u041d\u043e \u043e\u043d \u043d\u0435 \u0431\u0440\u043e\u0441\u0438\u043b \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u0440\u0435\u0448\u0438\u043b \u043d\u0430\u0447\u0430\u0442\u044c \u0441 \u043c\u0430\u043b\u044b\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u2026<\/p>\n<p>  \u042d\u0442\u043e \u043b\u0443\u0447\u0448\u0435\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u044f \u043c\u043e\u0433 \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u0442\u044c. \u0418\u043c\u0435\u043d\u043d\u043e \u0441 \u044d\u0442\u043e \u0446\u0435\u043b\u044c\u044e \u044f \u043d\u0430\u0447\u0430\u043b \u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u0435\u043d\u044c\u043a\u0438\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0447\u0442\u043e\u0431\u044b \u043e\u0442\u0442\u043e\u0447\u0438\u0442\u044c \u0441\u0432\u043e\u0438 \u043d\u0430\u0432\u044b\u043a\u0438, \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0441 \u043d\u043e\u0432\u044b\u043c\u0438 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f\u043c\u0438 \u0432 \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u043e\u043c \u043c\u043d\u0435 \u044f\u0437\u044b\u043a\u0435 \u0438 \u0435\u0441\u043b\u0438 \u0447\u0435\u0441\u0442\u043d\u043e, \u0442\u043e \u044d\u0442\u043e \u0434\u0430\u0436\u0435 \u0441\u0442\u0430\u043b\u043e \u043f\u0440\u0438\u043d\u043e\u0441\u0438\u0442\u044c \u043c\u043d\u0435 \u0443\u0434\u043e\u0432\u043e\u043b\u044c\u0441\u0442\u0432\u0438\u0435.<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u043c\u0430\u043b\u043e \u043e\u043f\u044b\u0442\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438, \u0442\u043e \u0441\u0442\u0430\u0442\u044c\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0439, \u0430 \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0443\u0436\u0435 \u0435\u0441\u0442\u044c \u043e\u043f\u044b\u0442\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438, \u0442\u043e \u043f\u043e\u0442\u0440\u0430\u0442\u044c\u0442\u0435 \u0432\u0440\u0435\u043c\u044f \u043d\u0430 \u0447\u0442\u043e-\u0442\u043e \u0431\u043e\u043b\u0435\u0435 \u0441\u0442\u043e\u044f\u0449\u0435\u0435.<\/p>\n<p>  \u042d\u0442\u043e \u043d\u0435 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435. \u0411\u043e\u043b\u044c\u0448\u0435 \u043f\u043e\u0445\u043e\u0436\u0435 \u043d\u0430 \u0431\u043b\u043e\u0433.<\/p>\n<p>  \u0411\u044b\u043b\u0430 \u0446\u0435\u043b\u044c \u0441\u0434\u0435\u043b\u0430\u0442\u044c 3 \u0432\u0435\u0440\u0441\u0438\u0438 \u0438\u0433\u0440\u044b \u043a\u0440\u0435\u0441\u0442\u0438\u043a\u0438 \u043d\u043e\u043b\u0438\u043a\u0438.<\/p>\n<p>  1 \u2014 \u0421\u0430\u043c\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0435(<i>\u0431\u0435\u0437 \u043a\u0440\u0430\u0441\u0438\u0432\u043e\u0433\u043e \u0432\u0438\u0437\u0443\u0430\u043b\u0430, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e DOM<\/i>)<br \/>  2 \u2014 \u0414\u0430\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0433\u0440\u0430\u0442\u044c \u0432\u0434\u0432\u043e\u0435\u043c(<i>\u043e\u0434\u0438\u043d \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440<\/i>)<br \/>  3 \u2014 \u041f\u0435\u0440\u0435\u043d\u0435\u0441\u0442\u0438 \u0432\u0441\u0435 \u044d\u0442\u043e \u0432 canvas<\/p>\n<p>  \u041e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u043a\u0440\u0435\u0441\u0442\u0438\u043a\u0438-\u043d\u043e\u043b\u0438\u043a\u0438 \u044f \u043d\u0435 \u0431\u0443\u0434\u0443, \u043d\u0430\u0434\u0435\u044e\u0441\u044c, \u0432\u0441\u0435 \u0437\u043d\u0430\u044e\u0442 \u043f\u0440\u0438\u043d\u0446\u0438\u043f \u0438\u0433\u0440\u044b. \u0412\u0441\u0435 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0441\u0441\u044b\u043b\u043a\u0438(\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439, \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f) \u0431\u0443\u0434\u0443\u0442 \u0432 \u043a\u043e\u043d\u0446\u0435 \u0441\u0442\u0430\u0442\u044c\u0438.<\/p>\n<p>  \u0427\u0442\u043e \u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u0432\u044b\u0448\u043b\u043e? \u0425\u043c\u2026<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h3><b>\u041f\u0435\u0440\u0432\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f<\/b><\/h3>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/yq\/je\/zw\/yqjezw1gvbhttxdr-2stqqjrb3i.png\" alt=\"image\"><\/p>\n<p>  \u042d\u0442\u043e \u0441\u0430\u043c\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0435. \u0415\u0441\u043b\u0438 \u0447\u0435\u0441\u0442\u043d\u043e, \u0442\u043e \u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0432\u0435\u0440\u0441\u0438\u0438 \u043d\u0435 \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0442\u0441\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e\u2026<\/p>\n<p>  \u041d\u0430\u043c \u043d\u0443\u0436\u043d\u0430 \u0432\u0435\u0440\u0441\u0442\u043a\u0430 \u0438\u0437 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0440\u0430\u0437\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u043d\u0430\u0448\u0435 \u0438\u0433\u0440\u043e\u0432\u043e\u0435 \u043f\u043e\u043b\u0435. \u042f \u0434\u043e\u0431\u0430\u0432\u0438\u043b data-item \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0443 \u0442.\u043a. \u0434\u0443\u043c\u0430\u043b, \u0447\u0442\u043e \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440, \u043d\u043e \u0435\u0433\u043e \u044f \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b.<\/p>\n<pre><code class=\"xml\">&lt;div class=&quot;app&quot;&gt; \t&lt;div class=&quot;app_block&quot; data-item=&quot;0&quot;&gt;&lt;\/div&gt; \t&lt;div class=&quot;app_block&quot; data-item=&quot;1&quot;&gt;&lt;\/div&gt; \t&lt;div class=&quot;app_block&quot; data-item=&quot;2&quot;&gt;&lt;\/div&gt; \t&lt;div class=&quot;app_block&quot; data-item=&quot;3&quot;&gt;&lt;\/div&gt; \t&lt;div class=&quot;app_block&quot; data-item=&quot;4&quot;&gt;&lt;\/div&gt; \t&lt;div class=&quot;app_block&quot; data-item=&quot;5&quot;&gt;&lt;\/div&gt; \t&lt;div class=&quot;app_block&quot; data-item=&quot;6&quot;&gt;&lt;\/div&gt; \t&lt;div class=&quot;app_block&quot; data-item=&quot;7&quot;&gt;&lt;\/div&gt; \t&lt;div class=&quot;app_block&quot; data-item=&quot;8&quot;&gt;&lt;\/div&gt; &lt;\/div&gt; <\/code><\/pre>\n<p>  \u0421\u0440\u0430\u0437\u0443 \u0445\u043e\u0447\u0443 \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0434\u0438\u0442\u044c! \u0414\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u043d\u0435 \u0441\u0442\u043e\u0438\u0442 \u0440\u0430\u0441\u0446\u0435\u043d\u0438\u0432\u0430\u0442\u044c \u043a\u0430\u043a \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0432\u0435\u0440\u043d\u044b\u043c \u0438 \u043f\u0438\u0441\u0430\u0442\u044c \u0438\u043d\u0430\u0447\u0435 \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u043e\u0439. \u042d\u0442\u043e \u043c\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0438 \u043d\u0435 \u0431\u043e\u043b\u0435\u0435 \u0442\u043e\u0433\u043e.<\/p>\n<p>  \u0422\u0430\u043a. \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0437\u0430\u0431\u0438\u043d\u0434\u0438\u0442\u044c \u043a\u043b\u0438\u043a \u043f\u043e \u044f\u0447\u0435\u0439\u043a\u0435. \u0412\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u043b\u0438\u043a\u0430 \u043c\u044b \u0445\u043e\u0434\u0438\u043c(\u0431\u043e\u0442 \u0442\u043e\u0436\u0435, \u043d\u043e \u043f\u043e \u043e\u0447\u0435\u0440\u0435\u0434\u0438) \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u044f\u0447\u0435\u0439\u043a\u0443.<\/p>\n<pre><code class=\"javascript\">var items = document.getElementsByClassName(&quot;app_block&quot;); \/\/ \u041a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 var movePlayer = true; \/\/ \u0425\u043e\u0434 \u0438\u0433\u0440\u043e\u043a\u0430 var game = true;\/\/ \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0438\u0433\u0440\u044b  \/\/ \u041f\u0435\u0440\u0435\u0431\u0438\u0440\u0430\u0435\u043c \u0432\u0441\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0438 \u043d\u0430\u0437\u043d\u0430\u0447\u0430\u0435\u043c \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u043a\u043b\u0438\u043a \u043d\u0430 \u044f\u0447\u0435\u0439\u043a\u0443. for (var i = 0; i &lt; items.length; i++) { \titems[i].addEventListener(&quot;click&quot;, function() { \t\tvar collecion = document.querySelectorAll(&quot;.app_block:not(.active)&quot;);  \t\t\/\/ \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043d\u0430 \u043d\u0438\u0447\u044c\u044e \t\tif(collecion.length == 1) { \t\t\texit({win: &quot;other&quot;}); \t\t}  \t\t\/\/ \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043d\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432\u043d\u0443\u0442\u0440\u0438 \u044f\u0447\u0435\u0439\u043a\u0438 \t\tif( !this.classList.contains(&quot;active&quot;) ){  \t\t\t\/\/ \u0435\u0441\u043b\u0438 \u0445\u043e\u0434\u0438\u0442 \u0438\u0433\u0440\u043e\u043a \t\t\tif( movePlayer) {  \t\t\t\t\/\/ \u0435\u0441\u043b\u0438 \u044f\u0447\u0435\u0439\u043a\u0430 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u0430 \t\t\t\tif(this.innerHTML == &quot;&quot;) { \t\t\t\t\t\/\/ \u0437\u0430\u043d\u044f\u0442\u044c \u044f\u0447\u0435\u0439\u043a\u0443 \t\t\t\t\tthis.classList.add(&quot;active&quot;); \t\t\t\t\tthis.classList.add(&quot;active_x&quot;); \t\t\t\t\tthis.innerHTML = &quot;x&quot; \t\t\t\t} \t\t\t\t\/\/ \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u044f\u0447\u0435\u0435\u043a \u0438 \u0432\u044b\u0445\u043e\u0434 \t\t\t\tvar result = checkMap(); \t\t\t\tif( result.val) { \t\t\t\t\tgame = false; \t\t\t\t\tsetTimeout(function() { \t\t\t\t\t\texit(result); \t\t\t\t\t}, 10); \t\t\t\t}  \t\t\t\tmovePlayer = !movePlayer; \t\t\t} \t\t\t \t\t\t\/\/ \u0435\u0441\u043b\u0438 \u0432\u0441\u0435 \u0435\u0449\u0435 \u0438\u0433\u0440\u0430\u0435\u043c, \u0442\u043e \u0445\u043e\u0434\u0438\u0442 \u0431\u043e\u0442 \t\t\tif(game) { \t\t\t\tsetTimeout(function() { \t\t\t\t\tbotMove(); \t\t\t\t}, 200); \t\t\t} \t\t} \t}); } <\/code><\/pre>\n<p>  \u0411\u043e\u0442 \u0445\u043e\u0434\u0438\u0442 \u0440\u0430\u043d\u0434\u043e\u043c\u043d\u043e.<\/p>\n<pre><code class=\"javascript\">function botMove() { \tvar items = document.querySelectorAll(&quot;.app_block:not(.active)&quot;);  \tvar step = getRandomInt(items.length);  \titems[ step ].innerHTML = &quot;0&quot;; \titems[ step ].classList.add(&quot;active&quot;); \titems[ step ].classList.add(&quot;active_o&quot;);  \tvar result = checkMap(); \tif( result.val) { \t\tsetTimeout(function() { \t\t\texit(result); \t\t}, 1); \t}  \tmovePlayer = !movePlayer; }  function getRandomInt(max) { \treturn Math.floor(Math.random() * Math.floor(max)); } <\/code><\/pre>\n<p>  \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u044f\u0447\u0435\u0435\u043a<\/p>\n<pre><code class=\"javascript\">function checkMap() { \tvar block = document.querySelectorAll(&quot;.app_block&quot;); \tvar items = []; \tfor (var i = 0; i &lt; block.length; i++) {  \t\titems.push(block[i].innerHTML); \t}  \tif ( items[0] == &quot;x&quot; &amp;&amp; items[1] == 'x' &amp;&amp; items[2] == 'x' || \t\t items[3] == &quot;x&quot; &amp;&amp; items[4] == 'x' &amp;&amp; items[5] == 'x' || \t\t items[6] == &quot;x&quot; &amp;&amp; items[7] == 'x' &amp;&amp; items[8] == 'x' || \t\t items[0] == &quot;x&quot; &amp;&amp; items[3] == 'x' &amp;&amp; items[6] == 'x' || \t\t items[1] == &quot;x&quot; &amp;&amp; items[4] == 'x' &amp;&amp; items[7] == 'x' || \t\t items[2] == &quot;x&quot; &amp;&amp; items[5] == 'x' &amp;&amp; items[8] == 'x' || \t\t items[0] == &quot;x&quot; &amp;&amp; items[4] == 'x' &amp;&amp; items[8] == 'x' || \t\t items[6] == &quot;x&quot; &amp;&amp; items[4] == 'x' &amp;&amp; items[2] == 'x' ) \t\treturn { val: true, win: &quot;player&quot;} \tif ( items[0] == &quot;0&quot; &amp;&amp; items[1] == '0' &amp;&amp; items[2] == '0' || \t\t items[3] == &quot;0&quot; &amp;&amp; items[4] == '0' &amp;&amp; items[5] == '0' || \t\t items[6] == &quot;0&quot; &amp;&amp; items[7] == '0' &amp;&amp; items[8] == '0' || \t\t items[0] == &quot;0&quot; &amp;&amp; items[3] == '0' &amp;&amp; items[6] == '0' || \t\t items[1] == &quot;0&quot; &amp;&amp; items[4] == '0' &amp;&amp; items[7] == '0' || \t\t items[2] == &quot;0&quot; &amp;&amp; items[5] == '0' &amp;&amp; items[8] == '0' || \t\t items[0] == &quot;0&quot; &amp;&amp; items[4] == '0' &amp;&amp; items[8] == '0' || \t\t items[6] == &quot;0&quot; &amp;&amp; items[4] == '0' &amp;&amp; items[2] == '0' ) \t\treturn { val: true, win: &quot;bot&quot;}  \treturn {val: false} } <\/code><\/pre>\n<p>  \u0417\u0434\u0435\u0441\u044c \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0432\u0441\u0435 \u0447\u0435\u0440\u0435\u0437 \u0446\u0438\u043a\u043b\u044b. \u042f \u0432\u044b\u0431\u0440\u0430\u043b \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043f\u0443\u0442\u044c. \u0423 \u043c\u0435\u043d\u044f \u043f\u043e\u043b\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0441\u0442\u0430\u0442\u0438\u0447\u043d\u043e. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u044f\u0447\u0435\u0435\u043a. \u0421\u0442\u043e\u0438\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e \u043e\u0431\u044a\u0435\u043a\u0442 \u0447\u0442\u043e\u0431\u044b \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043a\u0442\u043e \u043e\u0434\u0435\u0440\u0436\u0430\u043b \u043f\u043e\u0431\u0435\u0434\u0443. \u0412 \u043e\u0431\u044a\u0435\u043a\u0442\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 val \u0438 win. Val \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u0435 \u0438\u0433\u0440\u044b.<\/p>\n<p>  \u041a\u043e\u043d\u0435\u0446 \u0438\u0433\u0440\u044b. <\/p>\n<pre><code class=\"javascript\">\/\/ \u0432\u044b\u0445\u043e\u0434\/\u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 function exit(obj) { \talert(obj.win + &quot; - game over&quot;); \tlocation.reload(); }; <\/code><\/pre>\n<p>  \u0412\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u043b\u0438\u043a\u0430 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430, \u0430 \u0432\u0435\u0440\u043d\u0443\u043b \u043b\u0438 checkMap val: true. \u0415\u0441\u043b\u0438 \u0434\u0430, \u0442\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u043c \u0438\u0433\u0440\u0443.<\/p>\n<h3><b>\u0412\u0442\u043e\u0440\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f<\/b><\/h3>\n<p>  \u0414\u0432\u0430 \u0438\u0433\u0440\u043e\u043a\u0430 \u0437\u0430 \u043e\u0434\u043d\u0438\u043c \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u043e\u043c.<\/p>\n<p>  \u0412\u044b\u043d\u0435\u0441 \u0447\u0430\u0441\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0438 \u0438\u0437 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u043a\u043b\u0438\u043a\u0430 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u044e \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0432\u044b\u0437\u043e\u0432\u0430, \u0432\u0435\u0434\u044c \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043d\u0430 \u043a\u0430\u043a\u0443\u044e \u043a\u043d\u043e\u043f\u043a\u0443 \u0436\u043c\u044f\u043a\u043d\u0443\u043b\u0438.<\/p>\n<pre><code class=\"javascript\">var items = document.getElementsByClassName(&quot;app_block&quot;); var movePlayer = true; var game = true;  for (var i = 0; i &lt; items.length; i++) { \titems[i].addEventListener(&quot;click&quot;, function() { \t\tvar collecion = document.querySelectorAll(&quot;.app_block:not(.active)&quot;); \t\tif(collecion.length == 1) { \t\t\texit({win: &quot;other&quot;}); \t\t}  \t\tif( !this.classList.contains(&quot;active&quot;) ){ \t\t\tif( movePlayer) { \t\t\t\tfirstPlayer(this); \t\t\t} else { \t\t\t\tsecondPlayer(this); \t\t\t} \t\t} \t}); }  <\/code><\/pre>\n<p>  \u042f \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u043b \u043d\u0430 \u0434\u0432\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043d\u043e \u0432 \u043d\u0438\u0445 \u0435\u0441\u0442\u044c \u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u043e\u0434\u0430. \u0412 \u0438\u0434\u0435\u0430\u043b\u0435 \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c \u043d\u0430 3. \u041e\u0434\u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f, \u0430 \u0434\u0432\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0435 \u0441 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043e\u043c.<\/p>\n<pre><code class=\"javascript\">function firstPlayer(that) { \tif(that.innerHTML == &quot;&quot;) { \t\tthat.classList.add(&quot;active&quot;); \t\tthat.classList.add(&quot;active_x&quot;); \t\tthat.innerHTML = &quot;x&quot; \t}  \tvar result = checkMap(); \tif( result.val) { \t\tgame = false; \t\tsetTimeout(function() { \t\t\texit(result); \t\t}, 10); \t}  \tmovePlayer = !movePlayer; }  function secondPlayer(that) { \tif(that.innerHTML == &quot;&quot;) { \t\tthat.classList.add(&quot;active&quot;); \t\tthat.classList.add(&quot;active_o&quot;); \t\tthat.innerHTML = &quot;0&quot; \t}  \tvar result = checkMap(); \tif( result.val) { \t\tgame = false; \t\tsetTimeout(function() { \t\t\texit(result); \t\t}, 10); \t}  \tmovePlayer = !movePlayer; } <\/code><\/pre>\n<p>  <\/p>\n<h2><b>\u0422\u0440\u0435\u0442\u044c\u044f \u0432\u0435\u0440\u0441\u0438\u044f<\/b><\/h2>\n<p>  \u041f\u043e\u0436\u0430\u043b\u0443\u0439 \u044d\u0442\u043e \u0441\u0430\u043c\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0439 \u043f\u0443\u043d\u043a\u0442 \u0442.\u043a. \u0442\u0435\u043f\u0435\u0440\u044c \u0438\u0433\u0440\u0430 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u043e\u0445\u043e\u0436\u0430 \u043d\u0430 \u0438\u0433\u0440\u0443, \u0430 \u043d\u0435 \u043d\u0430 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 DOM \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432. <\/p>\n<p>  \u042f \u0432\u044b\u0431\u0440\u0430\u043b \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b PixiJS. \u041d\u0435 \u043c\u043e\u0433\u0443 \u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043d\u0438\u0447\u0435\u0433\u043e \u043e + \u0438 \u2014 \u044d\u0442\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438, \u043d\u043e \u044f \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u043b \u043e\u0434\u0438\u043d \u043f\u0440\u0438\u043c\u0435\u0440 \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u044b\u043b\u043e 60 000 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0438 \u0432\u0441\u0435 \u043e\u043d\u0438 \u0430\u043d\u0438\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435. \u0410\u043d\u0438\u043c\u0430\u0446\u0438\u044f \u043f\u0440\u043e\u0441\u0442\u0430\u044f, \u043d\u043e FPS \u0434\u0435\u0440\u0436\u0430\u043b\u0441\u044f \u043d\u0430 50-60. \u041c\u043d\u0435 \u044d\u0442\u043e \u043f\u043e\u043d\u0440\u0430\u0432\u0438\u043b\u043e\u0441\u044c \u0438 \u044f \u0441\u0442\u0430\u043b \u0447\u0438\u0442\u0430\u0442\u044c \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e. \u0421\u043a\u0430\u0436\u0443 \u0441\u0440\u0430\u0437\u0443, \u0437\u043d\u0430\u043d\u0438\u044f \u0430\u043d\u0433 \u044f\u0437\u044b\u043a\u0430 \u0443 \u043c\u0435\u043d\u044f \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b, \u0431\u044b\u043b\u043e \u0441\u043b\u043e\u0436\u043d\u043e, \u0430 \u043d\u0430 \u0420\u0443\u0441\u0441\u043a\u043e\u043c \u0441\u0442\u0430\u0442\u0435\u0439 \u043e\u0447\u0435\u043d\u044c \u043c\u0430\u043b\u043e.(\u0438\u043b\u0438 \u044f \u043f\u043b\u043e\u0445\u043e \u0438\u0441\u043a\u0430\u043b). \u041f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u0442\u044b\u043a\u0430 \u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0433\u0443\u0443\u0433\u043b \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0447\u0438\u043a\u0430 \u043f\u0440\u043e\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u0442\u0435\u0440\u043d\u0438\u0438.<\/p>\n<p>  \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u043b \u043b\u0438\u0448\u044c \u043e\u0434\u0438\u043d \u0434\u043e\u043a\u043b\u0430\u0434 \u043d\u0430 \u044d\u0442\u0443 \u0442\u0435\u043c\u0443 <a href=\"https:\/\/youtu.be\/Q5tf38DATBM\">\u042e\u043b\u0438\u044f \u041f\u0443\u0447\u043d\u0438\u043d\u0430 \u00ab\u0416\u0438\u0440\u043d\u0430\u044f \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044f \u0441 Pixi js\u00bb<\/a>.<\/p>\n<p>  \u0414\u043e\u043a\u043b\u0430\u0434 \u043e\u0442 2014 \u0433\u043e\u0434\u0430 \u0438 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c, \u0447\u0442\u043e API \u043c\u043e\u0433\u043b\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c\u0441\u044f. \u041e\u0434\u043d\u0438\u043c \u0433\u043b\u0430\u0437\u043e\u043c \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e, \u0430 \u0432\u0442\u043e\u0440\u044b\u043c \u043d\u0430 \u0432\u0438\u0434\u0435\u043e. \u0422\u0430\u043a \u0438 \u0438\u0437\u0443\u0447\u0430\u043b. \u0425\u0432\u0430\u0442\u0438\u043b\u043e 4 \u0447\u0430\u0441\u0430 \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u043f\u0440\u043e\u0441\u0442\u0435\u043d\u044c\u043a\u0438\u0439 \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f. \u0411\u043b\u0438\u0436\u0435 \u043a \u043a\u043e\u0434\u0443.<\/p>\n<p>  \u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u043c \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u0443\u044e \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e pixi<\/p>\n<pre><code class=\"javascript\">const app = new PIXI.Application({ \twidth: 720, \theight: 390, \tresolution: window.devicePixelRation || 1, }); document.body.appendChild(app.view); <\/code><\/pre>\n<p>  \u0430 \u0442\u0430\u043a \u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c wrapper(\u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0441 \u044f\u0447\u0435\u0439\u043a\u0430\u043c\u0438) \u0438 \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u043c \u0435\u0433\u043e \u0432 \u043d\u0430\u0448 canvas<\/p>\n<pre><code class=\"javascript\">let wrapper = new PIXI.Container(); app.stage.addChild(wrapper); <\/code><\/pre>\n<p>  \u0412 \u0446\u0438\u043a\u043b\u0435 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u0430\u0448\u0438 \u044f\u0447\u0435\u0439\u043a\u0438, \u0437\u0430\u0434\u0430\u0435\u043c \u0438\u043c \u043d\u0443\u0436\u043d\u044b\u0435 \u0440\u0430\u0437\u043c\u0435\u0440\u044b, \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b, \u0430 \u0442\u0430\u043a \u0436\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u044f\u0447\u0435\u0439\u043a\u0435 \u0432 \u0432\u0438\u0434\u0435 \u043f\u0443\u0441\u0442\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u0442.\u043a. \u044d\u0442\u043e \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c \u0438 \u0432\u0435\u0448\u0430\u0435\u043c \u043d\u0430 \u044f\u0447\u0435\u0439\u043a\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438, \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u043a\u043b\u044e\u0447\u0438\u0432 \u0444\u043b\u0430\u0433 \u0438\u043d\u0442\u0435\u0440\u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438 \u0443 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430.<\/p>\n<pre><code class=\"javascript\">for (let i = 0; i &lt; 9; i++) {     let container = new PIXI.Container(); \tlet block = new PIXI.TilingSprite( PIXI.Texture.from(&quot;images\/bg.png&quot;) , 240, 130);      \tcontainer.x = (i % 3) * 240;     container.y = Math.floor(i \/ 3) * 130;     container.addChild(block);          let text = new PIXI.Text(&quot;&quot;);     text.anchor.set(0.5);     text.x = container.width \/ 2;     text.y = container.height \/ 2;     container.addChild(text);          container.interactive = true;         container.on(&quot;mousedown&quot;, function () {         addValueInBlock(this);     });          wrapper.addChild(container); } <\/code><\/pre>\n<p>  addValueInBlock \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0445\u043e\u0434 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0433\u0440\u043e\u043a\u0430. \u042f \u043d\u0435 \u043d\u0430\u0448\u0435\u043b \u043b\u0443\u0447\u0448\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u0447\u0435\u043c \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0442\u044c \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0442\u0435\u043a\u0441\u0442\u0430 \u0441\u0432\u043e\u0438 \u0441\u0442\u0438\u043b\u0438. \u0422\u0430\u043c \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0446\u0432\u0435\u0442, \u0430 \u043a\u0430\u043a \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0446\u0432\u0435\u0442 \u0442\u0430\u043a \u0438 \u043d\u0435 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0441\u044f. \u041f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u043d\u043e\u0432\u044b\u0435 \u0441\u0442\u0438\u043b\u0438 \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c \u0442\u0435\u043a\u0441\u0442\u0443. \u0422\u0430\u043a\u0436\u0435 \u0437\u0434\u0435\u0441\u044c \u0438\u0434\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u044f\u0447\u0435\u0435\u043a.<\/p>\n<pre><code class=\"javascript\">function addValueInBlock(that) {     if(firstPlayer) {         \/\/ \u0425\u043e\u0434 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0438\u0433\u0440\u043e\u043a\u0430 - X         if( that.children[1].text == &quot; &quot; ) {             that.children[1].style = {                 fill: &quot;#d64c42&quot;,                 fontFamily: &quot;Arial&quot;,                 fontSize: 32,                 fontWeight: &quot;bold&quot;,             };             that.children[1].text = &quot;x&quot;                          firstPlayer = !firstPlayer;         }              } else {         \/\/ \u0425\u043e\u0434 \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u0438\u0433\u0440\u043e\u043a\u0430 - 0                  if( that.children[1].text == &quot; &quot; ) {             that.children[1].style = {                 fill: &quot;#e2e3e8&quot;,                 fontFamily: &quot;Arial&quot;,                 fontSize: 32,                 fontWeight: &quot;bold&quot;,             };             that.children[1].text = &quot;0&quot;                           firstPlayer = !firstPlayer;         }     }     endGame(); } <\/code><\/pre>\n<p>  \u041a\u0430\u0441\u0430\u0435\u043c\u043e \u0441\u0430\u043c\u043e\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438. checkMap. \u042f \u0442\u0430\u043a \u043f\u043e\u043d\u044f\u043b, \u0443 pixiJS \u043d\u0435\u043b\u044c\u0437\u044f \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c\u0441\u044f \u043a \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0443 \u043f\u043e \u0438\u043c\u0435\u043d\u0438 \u0438\u043b\u0438 id. \u041f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u0431\u0438\u0440\u0430\u0442\u044c \u0432\u0441\u044e \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044e \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0435 \u0438\u0437-\u0437\u0430 \u044d\u0442\u043e\u0433\u043e \u043a\u043e\u0434 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0433\u0440\u043e\u043c\u043e\u0437\u043a\u0438\u043c. \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u043d\u0438\u0447\u0435\u043c \u043d\u0435 \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0442 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445, \u043a\u0440\u043e\u043c\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u043d\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442.<\/p>\n<pre><code class=\"javascript\">function checkMap() {     let items = wrapper.children;      \tif ( items[0].children[1].text == &quot;x&quot; &amp;&amp; items[1].children[1].text == 'x' &amp;&amp; items[2].children[1].text == 'x' || \t\t items[3].children[1].text == &quot;x&quot; &amp;&amp; items[4].children[1].text == 'x' &amp;&amp; items[5].children[1].text == 'x' || \t\t items[6].children[1].text == &quot;x&quot; &amp;&amp; items[7].children[1].text == 'x' &amp;&amp; items[8].children[1].text == 'x' || \t\t items[0].children[1].text == &quot;x&quot; &amp;&amp; items[3].children[1].text == 'x' &amp;&amp; items[6].children[1].text == 'x' || \t\t items[1].children[1].text == &quot;x&quot; &amp;&amp; items[4].children[1].text == 'x' &amp;&amp; items[7].children[1].text == 'x' || \t\t items[2].children[1].text == &quot;x&quot; &amp;&amp; items[5].children[1].text == 'x' &amp;&amp; items[8].children[1].text == 'x' || \t\t items[0].children[1].text == &quot;x&quot; &amp;&amp; items[4].children[1].text == 'x' &amp;&amp; items[8].children[1].text == 'x' || \t\t items[6].children[1].text == &quot;x&quot; &amp;&amp; items[4].children[1].text == 'x' &amp;&amp; items[2].children[1].text == 'x' ) {         return {active: true, win: &quot;player 1&quot;};     } \t\t \tif ( items[0].children[1].text == &quot;0&quot; &amp;&amp; items[1].children[1].text == '0' &amp;&amp; items[2].children[1].text == '0' || \t\t items[3].children[1].text == &quot;0&quot; &amp;&amp; items[4].children[1].text == '0' &amp;&amp; items[5].children[1].text == '0' || \t\t items[6].children[1].text == &quot;0&quot; &amp;&amp; items[7].children[1].text == '0' &amp;&amp; items[8].children[1].text == '0' || \t\t items[0].children[1].text == &quot;0&quot; &amp;&amp; items[3].children[1].text == '0' &amp;&amp; items[6].children[1].text == '0' || \t\t items[1].children[1].text == &quot;0&quot; &amp;&amp; items[4].children[1].text == '0' &amp;&amp; items[7].children[1].text == '0' || \t\t items[2].children[1].text == &quot;0&quot; &amp;&amp; items[5].children[1].text == '0' &amp;&amp; items[8].children[1].text == '0' || \t\t items[0].children[1].text == &quot;0&quot; &amp;&amp; items[4].children[1].text == '0' &amp;&amp; items[8].children[1].text == '0' || \t\t items[6].children[1].text == &quot;0&quot; &amp;&amp; items[4].children[1].text == '0' &amp;&amp; items[2].children[1].text == '0' ) {         return {active: true, win: &quot;player 2&quot;};     }      \treturn {active: false}; } <\/code><\/pre>\n<p>  \u041d\u0443 \u0438 \u0434\u0432\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0442 \u0437\u0430 \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u0435 \u0438\u0433\u0440\u044b \u0438 \u043e\u0447\u0438\u0441\u0442\u043a\u0443 \u043a\u0430\u043d\u0432\u0430\u0441\u0430. \u041c\u043d\u0435 \u043a\u0430\u0436\u0435\u0442\u0441\u044f, \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u0435 \u0437\u0434\u0435\u0441\u044c \u043b\u0438\u0448\u043d\u0435\u0435.<\/p>\n<pre><code class=\"javascript\">function endGame() {     var result = checkMap();     console.log(result);     if( result.active ) {         setTimeout(function() {             alert(result.win + &quot; - win&quot;);             clearMap();         }, 100);     } }  function clearMap() {     console.log(&quot;sdf&quot;);     let items = wrapper.children;          for(let i = 0; i &lt; items.length; i++) {         console.log( items[i].children[1].text );         items[i].children[1].text = &quot;&quot;;         firstPlayer = true;     } } <\/code><\/pre>\n<p>  \u0415\u0441\u043b\u0438 \u043f\u043e\u0434\u044b\u0442\u043e\u0436\u0438\u0442\u044c, \u0442\u043e \u0431\u044b\u043b\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0441\u0442\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u044d\u0442\u0430\u043f\u043e\u0432. \u041f\u0443\u0441\u0442\u044c \u043d\u0435 \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u044b\u0439 \u0446\u0438\u043a\u043b \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438, \u043d\u043e \u0441 \u0447\u0435\u0433\u043e \u0442\u043e \u043c\u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043d\u0430\u0447\u0438\u043d\u0430\u0442\u044c. <\/p>\n<p>  \u0421\u043f\u0430\u0441\u0438\u0431\u043e, \u0447\u0442\u043e \u043f\u0440\u043e\u0447\u043b\u0438 \u0438 \u0434\u043e \u0432\u0441\u0442\u0440\u0435\u0447\u0438.<\/p>\n<h3>\u0421\u0441\u044b\u043b\u043a\u0438<\/h3>\n<p>  <a href=\"https:\/\/github.com\/EpicLegend\/tictac-js\">Github<\/a><br \/>  <a href=\"https:\/\/youtu.be\/Q5tf38DATBM\">\u0414\u043e\u043a\u043b\u0430\u0434<\/a><br \/>  <a href=\"https:\/\/www.pixijs.com\/\">\u041e\u0444. \u0441\u0430\u0439\u0442 PixiJS<\/a><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/489490\/\"> https:\/\/habr.com\/ru\/post\/489490\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/489490\/\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/c0\/xl\/3v\/c0xl3voe_muivcbhukxqze4l1f8.png\" alt=\"image\"><\/p>\n<p>  \u041e\u0434\u0438\u043d \u0440\u0430\u043d\u0438\u043c\u044b\u0439, \u0433\u043b\u0443\u043f\u044b\u0439, \u043c\u0435\u0447\u0442\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0432\u0435\u0440\u0441\u0442\u0430\u043b\u044c\u0449\u0438\u043a \u0440\u0435\u0448\u0438\u043b \u0441\u0442\u0430\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u043e\u043c \u0438 \u0443 \u043d\u0435\u0433\u043e \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0432\u044b\u0448\u043b\u043e\u2026 \u041d\u043e \u043e\u043d \u043d\u0435 \u0431\u0440\u043e\u0441\u0438\u043b \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u0440\u0435\u0448\u0438\u043b \u043d\u0430\u0447\u0430\u0442\u044c \u0441 \u043c\u0430\u043b\u044b\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u2026<\/p>\n<p>  \u042d\u0442\u043e \u043b\u0443\u0447\u0448\u0435\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u044f \u043c\u043e\u0433 \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u0442\u044c. \u0418\u043c\u0435\u043d\u043d\u043e \u0441 \u044d\u0442\u043e \u0446\u0435\u043b\u044c\u044e \u044f \u043d\u0430\u0447\u0430\u043b \u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u0435\u043d\u044c\u043a\u0438\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0447\u0442\u043e\u0431\u044b \u043e\u0442\u0442\u043e\u0447\u0438\u0442\u044c \u0441\u0432\u043e\u0438 \u043d\u0430\u0432\u044b\u043a\u0438, \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0441 \u043d\u043e\u0432\u044b\u043c\u0438 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f\u043c\u0438 \u0432 \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u043e\u043c \u043c\u043d\u0435 \u044f\u0437\u044b\u043a\u0435 \u0438 \u0435\u0441\u043b\u0438 \u0447\u0435\u0441\u0442\u043d\u043e, \u0442\u043e \u044d\u0442\u043e \u0434\u0430\u0436\u0435 \u0441\u0442\u0430\u043b\u043e \u043f\u0440\u0438\u043d\u043e\u0441\u0438\u0442\u044c \u043c\u043d\u0435 \u0443\u0434\u043e\u0432\u043e\u043b\u044c\u0441\u0442\u0432\u0438\u0435.<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u043c\u0430\u043b\u043e \u043e\u043f\u044b\u0442\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438, \u0442\u043e \u0441\u0442\u0430\u0442\u044c\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0439, \u0430 \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0443\u0436\u0435 \u0435\u0441\u0442\u044c \u043e\u043f\u044b\u0442\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438, \u0442\u043e \u043f\u043e\u0442\u0440\u0430\u0442\u044c\u0442\u0435 \u0432\u0440\u0435\u043c\u044f \u043d\u0430 \u0447\u0442\u043e-\u0442\u043e \u0431\u043e\u043b\u0435\u0435 \u0441\u0442\u043e\u044f\u0449\u0435\u0435.<\/p>\n<p>  \u042d\u0442\u043e \u043d\u0435 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435. \u0411\u043e\u043b\u044c\u0448\u0435 \u043f\u043e\u0445\u043e\u0436\u0435 \u043d\u0430 \u0431\u043b\u043e\u0433.<\/p>\n<p>  \u0411\u044b\u043b\u0430 \u0446\u0435\u043b\u044c \u0441\u0434\u0435\u043b\u0430\u0442\u044c 3 \u0432\u0435\u0440\u0441\u0438\u0438 \u0438\u0433\u0440\u044b \u043a\u0440\u0435\u0441\u0442\u0438\u043a\u0438 \u043d\u043e\u043b\u0438\u043a\u0438.<\/p>\n<p>  1 \u2014 \u0421\u0430\u043c\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0435(<i>\u0431\u0435\u0437 \u043a\u0440\u0430\u0441\u0438\u0432\u043e\u0433\u043e \u0432\u0438\u0437\u0443\u0430\u043b\u0430, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e DOM<\/i>)<br \/>  2 \u2014 \u0414\u0430\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0433\u0440\u0430\u0442\u044c \u0432\u0434\u0432\u043e\u0435\u043c(<i>\u043e\u0434\u0438\u043d \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440<\/i>)<br \/>  3 \u2014 \u041f\u0435\u0440\u0435\u043d\u0435\u0441\u0442\u0438 \u0432\u0441\u0435 \u044d\u0442\u043e \u0432 canvas<\/p>\n<p>  \u041e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u043a\u0440\u0435\u0441\u0442\u0438\u043a\u0438-\u043d\u043e\u043b\u0438\u043a\u0438 \u044f \u043d\u0435 \u0431\u0443\u0434\u0443, \u043d\u0430\u0434\u0435\u044e\u0441\u044c, \u0432\u0441\u0435 \u0437\u043d\u0430\u044e\u0442 \u043f\u0440\u0438\u043d\u0446\u0438\u043f \u0438\u0433\u0440\u044b. \u0412\u0441\u0435 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0441\u0441\u044b\u043b\u043a\u0438(\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439, \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f) \u0431\u0443\u0434\u0443\u0442 \u0432 \u043a\u043e\u043d\u0446\u0435 \u0441\u0442\u0430\u0442\u044c\u0438.<\/p>\n<p>  \u0427\u0442\u043e \u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u0432\u044b\u0448\u043b\u043e? \u0425\u043c\u2026  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-299098","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/299098","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=299098"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/299098\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=299098"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=299098"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=299098"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}