From fde0a9ed9d9670f68fe8d46be7a88454521c4961 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:55:37 +0300 Subject: [PATCH] some --- 320.игрок.js | 4 ++-- 667.ручноетело.js | 38 ++++++++++++++++++++++++++++--------- 800.пример.json.js | 2 ++ 3 files changed, 33 insertions(+), 11 deletions(-) diff --git a/320.игрок.js b/320.игрок.js index dda0ebb..43a4c0f 100644 --- a/320.игрок.js +++ b/320.игрок.js @@ -30,14 +30,14 @@ мир.игрок.обновить = function() { - мир.игрок.тело = мир.объекты.тела[мир.игрок.задано.объект]; + /**///мир.игрок.тело = мир.объекты.тела[мир.игрок.задано.объект]; + мир.игрок.тело = мир.рт.тело; if (!мир.игрок.тело) { return; } мир.игрок.переместить(); - //мир.игрок.задатьМаскуСтолкновения(); мир.игрок.отслеживатьПрыжкиПриземления(); }; diff --git a/667.ручноетело.js b/667.ручноетело.js index 7e91b0c..d67f28c 100644 --- a/667.ручноетело.js +++ b/667.ручноетело.js @@ -1,8 +1,9 @@ function РучноеТело(события) { this.создать = function() { - события.подписать(this); + //события.подписать(this); }; + /* this.обработатьСобытие = function(событие) { if (событие != "игрок начал прыжок") { @@ -11,16 +12,25 @@ function РучноеТело(события) { события.отписать(this); this.настроить(); }; + */ this.настроить = function() { + /* + if (!мир.физика.движок) + { + return; + } + */ + if (this.настроено) + { + return; + } + this.настроено = true; - var физика = { - inertia: Infinity, - }; // 1. - this.тело1 = Matter.Bodies.rectangle(1200, 300, 40, 40, физика); - Matter.Composite.add(мир.физика.движок.world, this.тело1); + this.тело1 = Matter.Bodies.rectangle(125, 300, 40, 40, { isSensor: true }); + //Matter.Composite.add(мир.физика.движок.world, this.тело1); this.элемент1 = document.createElement("div"); document.getElementById("корень").appendChild(this.элемент1); @@ -30,10 +40,11 @@ function РучноеТело(события) { this.элемент1.style.width = `40px`; this.элемент1.style.height = `40px`; this.элемент1.style.setProperty("background", "url(р/отладка/основа.jpg)"); + this.элемент1.style.setProperty("z-index", "100"); // 2. - this.тело2 = Matter.Bodies.rectangle(1150, 300, 40, 40, физика); - Matter.Composite.add(мир.физика.движок.world, this.тело2); + this.тело2 = Matter.Bodies.rectangle(55, 300, 40, 40, {}); + //Matter.Composite.add(мир.физика.движок.world, this.тело2); this.элемент2 = document.createElement("div"); document.getElementById("корень").appendChild(this.элемент2); @@ -43,11 +54,20 @@ function РучноеТело(события) { this.элемент2.style.width = `40px`; this.элемент2.style.height = `40px`; this.элемент2.style.setProperty("background", "url(р/отладка/основа.jpg)"); + this.элемент2.style.setProperty("z-index", "100"); + + // Compound. + this.тело = Matter.Body.create({ + parts: [this.тело1, this.тело2], + inertia: Infinity, + }); + Matter.Composite.add(мир.физика.движок.world, this.тело); }; this.обновить = function() { - if (!this.тело1) + this.настроить(); + if (!this.тело) { return; } diff --git a/800.пример.json.js b/800.пример.json.js index bd96180..20becfa 100644 --- a/800.пример.json.js +++ b/800.пример.json.js @@ -136,6 +136,7 @@ скорость: [5, 12.5], клавиши: ["ArrowLeft", "ArrowRight", "ArrowUp"], }, + /* слежение: { колобок: { объект: "кирпич", @@ -155,6 +156,7 @@ маски: [1, 1|2], }, }, + */ звуки: { прыжокИгрока: { события: ["игрок начал прыжок"],