improve UI
This commit is contained in:
parent
5ab4e05afe
commit
cae503167f
4 changed files with 132 additions and 9 deletions
34
js/index.js
34
js/index.js
|
@ -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 () {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue