Переглянути джерело

Add names below each entity

tags/v0.0.1
Fen Dweller 5 роки тому
джерело
коміт
dc8b6dd391
2 змінених файлів з 24 додано та 4 видалено
  1. +10
    -2
      macrovision.css
  2. +14
    -2
      macrovision.js

+ 10
- 2
macrovision.css Переглянути файл

@@ -109,8 +109,8 @@ body {

#world {
flex: 9 0 85vw;
min-height: 90vh;
max-height: 90vh;
min-height: 85vh;
max-height: 85vh;
overflow: hidden;
}

@@ -164,4 +164,12 @@ body {
body #test-canvas {
position: fixed;
top: 100vh;
}

.bottom-name {
text-align: center;
position: fixed;
width: 75px;
height: 50px;
transform: translate(125%, 0%);
}

+ 14
- 2
macrovision.js Переглянути файл

@@ -73,6 +73,11 @@ function updateEntityElement(entity, element) {

element.querySelector(".entity-name").innerText = entity.name;

const bottomName = document.querySelector("#bottom-name-" + element.dataset.key);

bottomName.style.left = position.x + "px";
bottomName.style.top = "95vh";
bottomName.innerText = entity.name;
}

function updateSizes() {
@@ -517,10 +522,17 @@ function displayEntity(entity, view, x, y) {

entities[entityIndex] = entity;

entityIndex += 1;

const world = document.querySelector("#entities");
world.appendChild(box);

const bottomName = document.createElement("div");
bottomName.classList.add("bottom-name");
bottomName.id = "bottom-name-" + entityIndex;
bottomName.innerText = entity.name;

world.appendChild(bottomName);
entityIndex += 1;

updateEntityElement(entity, box);
}



Завантаження…
Відмінити
Зберегти