Use nalgebra
This commit is contained in:
@@ -6,10 +6,10 @@
|
||||
|
||||
<body>
|
||||
<h1>Hello, world!</h1>
|
||||
<p id="iteration">Iteration: {{ iteration }}<p>
|
||||
<p id="iteration">Iteration: {{ iteration }} messages 0.<p>
|
||||
<ul id="objects">
|
||||
{% for object in objects %}
|
||||
<li>{{ object.name }} @ {{ object.x }}, {{ object.y }}</li>
|
||||
<li id="object-{{ object.id }}">{{ object.name }} @ {{ object.x }}, {{ object.y }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
@@ -21,18 +21,17 @@
|
||||
console.log("Connected");
|
||||
ws.send("MOAR");
|
||||
}
|
||||
let messages = 0;
|
||||
|
||||
ws.onmessage = function(e) {
|
||||
const data = JSON.parse(e.data);
|
||||
messages += 1;
|
||||
|
||||
document.getElementById("iteration").innerText = `Iteration: ${data.iteration}`;
|
||||
const ul = document.getElementById("objects");
|
||||
while(ul.firstChild) { ul.removeChild(ul.lastChild) }
|
||||
document.getElementById("iteration").innerText = `Iteration: ${data.iteration} messages ${messages}.`;
|
||||
for (n in data.objects) {
|
||||
const ob = data.objects[n];
|
||||
const li = document.createElement("li");
|
||||
const li = document.getElementById(`object-${ob.id}`);
|
||||
li.innerText = `${ob.name} @ ${ob.x}, ${ob.y}`;
|
||||
ul.append(li);
|
||||
}
|
||||
ws.send("MOAR");
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user