improve UI

This commit is contained in:
biglyderv 2024-09-13 06:11:07 -04:00
parent 5ab4e05afe
commit cae503167f
No known key found for this signature in database
GPG key ID: 33AC87E9ACE66954
4 changed files with 132 additions and 9 deletions

View file

@ -52,6 +52,32 @@ function Game(inSize, exp, cs) {
this.dead = false;
}
Game.prototype.player = function () {
let { ctx, fac, base, exp, inSize, camera, cs } = this;
ctx.fillStyle = 'red';
ctx.rect(cs / 2 - 2, cs / 2 - 2, 4, 4);
ctx.fill();
if (toPoint(camera[0], camera[1], base, fac, exp, inSize) == 0) {
this.dead = true;
}
let cx = Math.floor(camera[0]) / tileSize;
let cy = Math.floor(camera[1]) / tileSize;
let sum = 0;
for (let i in base) {
sum += base[i]
}
sum *= fac;
let dim = Math.log(sum) / (Math.log(base.length) / 2);
document.querySelector('.ui-text').textContent = `Coordinates: ${cx},${cy}\nDimensionality: ${dim}`
}
Game.prototype.main = function () {
var { base, inSize, ctx, cs, frames, exp, camera, dat } = this;
if (this.dead) {
@ -82,13 +108,7 @@ Game.prototype.main = function () {
ctx.putImageData(dat, 0, 0, 0, 0, cs, cs);
ctx.fillStyle = 'red';
ctx.rect(cs / 2 - 2, cs / 2 - 2,4,4);
ctx.fill();
if (toPoint(camera[0], camera[1], base, this.fac, exp, inSize) == 0 ){
this.dead = true;
}
this.player();
}
Game.prototype.map = function () {