From a25bd81dbc7d203f76f9fa65ae6920939e345dec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=20=D0=9A=D0=B0=D0=BF?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BA=D0=BE?= Date: Thu, 12 Aug 2021 14:32:54 +0300 Subject: [PATCH] =?UTF-8?q?=D1=80=D1=83=D1=87=D0=BD=D0=BE=D0=B5=20=D1=82?= =?UTF-8?q?=D0=B5=D0=BB=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 667.ручноетело.js | 46 +++++++++++++++++++++++++++++++++++++ 700.пуск.js | 2 ++ index.html | 1 + 3 files changed, 49 insertions(+) create mode 100644 667.ручноетело.js diff --git a/667.ручноетело.js b/667.ручноетело.js new file mode 100644 index 0000000..119bf5d --- /dev/null +++ b/667.ручноетело.js @@ -0,0 +1,46 @@ +function РучноеТело(события) { + this.создать = function() { + события.подписать(this); + }; + + this.обработатьСобытие = function(событие) { + if (событие != "игрок начал прыжок") + { + return; + } + события.отписать(this); + this.настроить(); + }; + + this.настроить = function() + { + + var физика = { + inertia: Infinity, + }; + this.тело = Matter.Bodies.rectangle(1200, 300, 40, 40, физика); + Matter.Composite.add(мир.физика.движок.world, this.тело); + + this.элемент = document.createElement("div"); + document.getElementById("корень").appendChild(this.элемент); + this.элемент.id = `рт`; + this.элемент.style.position = "absolute"; + this.элемент.style.display = "block"; + this.элемент.style.transformOrigin = "center"; + this.элемент.style.width = `40px`; + this.элемент.style.height = `40px`; + this.элемент.style.setProperty("background", "url(р/отладка/основа.jpg)"); + }; + + this.обновить = function() + { + if (!this.тело) + { + return; + } + мир.синхронизироватьЭлементТело(this.элемент, this.тело); + }; + + // Конструктор. + this.создать(); +} diff --git a/700.пуск.js b/700.пуск.js index e4eb8cc..6845f5b 100644 --- a/700.пуск.js +++ b/700.пуск.js @@ -7,12 +7,14 @@ function Пуск() мир.звуки = new Звуки(мир.ключники, мир.события); мир.движение = new Движение(мир.ключники); /**/мир.ограничитель = new Ограничитель(); + /**/мир.рт = new РучноеТело(мир.события); this.обновить(); }; this.обновить = function() { /**/мир.ограничитель.обновить(); + /**/мир.рт.обновить(); мир.физика.обновить(); мир.объекты.обновить(); мир.игрок.обновить(); diff --git a/index.html b/index.html index 16fe9ef..e8e35c6 100644 --- a/index.html +++ b/index.html @@ -80,6 +80,7 @@ +