-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gui.js
62 lines (58 loc) · 2 KB
/
Gui.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
class Gui{
constructor(){
this.elem = document.getElementById('info');
}
renderCell(data){
this.elem.innerHTML = '';
if(data ==false)return;
this.elem.appendChild(this.lifetime(data));
this.elem.appendChild(this.food(data));
this.elem.appendChild(this.speed(data));
this.elem.appendChild(this.size(data));
this.elem.appendChild(this.foodCost(data));
this.elem.appendChild(this.coords(data));
this.elem.appendChild(this.index(data));
}
lifetime(data){
var div = document.createElement('div');
div.className = 'stats';
div.innerHTML = `<div>Czas życia: </div><div>${Math.floor(data.lifeTime)}/${Math.floor(data.maxLifeTime)}</div>`;
return div;
}
food(data){
var div = document.createElement('div');
div.className = 'stats';
div.innerHTML = `<div>Jedzenie </div><div>${data.food}/${data.maxFood}</div>`;
return div;
}
speed(data){
var div = document.createElement('div');
div.className = 'stats';
div.innerHTML = `<div>Speed </div><div>${data.v}</div>`;
return div;
}
size(data){
var div = document.createElement('div');
div.className = 'stats';
div.innerHTML = `<div>MaxSize </div><div>${data.maxSize}</div>`;
return div;
}
foodCost(data){
var div = document.createElement('div');
div.className = 'stats';
div.innerHTML = `<div>Koszt jedzenia </div><div>${data.foodCost}</div>`;
return div;
}
coords(data){
var div = document.createElement('div');
div.className = 'stats';
div.innerHTML = `<div>x: ${Math.floor(data.x)}</div><div>y: ${Math.floor(data.y)}</div>`;
return div;
}
index(data){
var div = document.createElement('div');
div.className = 'stats';
div.innerHTML = `<div>Index: </div><div>${Math.floor(data.indx)}</div>`;
return div;
}
}