better UI
This commit is contained in:
parent
c92ec69523
commit
6a0863bd56
3 changed files with 28 additions and 10 deletions
|
@ -56,12 +56,22 @@ class Game extends GameBasic {
|
|||
|
||||
ctx.clearRect(0, 0, cs, cs);
|
||||
|
||||
ctx.strokeStyle = "rgb(255,255,255)";
|
||||
ctx.lineWidth = "8";
|
||||
ctx.textAlign = "center";
|
||||
ctx.textBaseline = "bottom";
|
||||
ctx.lineCap = "round";
|
||||
ctx.lineJoin = "round";
|
||||
ctx.font = "bold 16px sans-serif";
|
||||
|
||||
ctx.save();
|
||||
|
||||
ctx.translate(player.camera.x + cs / 2, player.camera.y + cs / 2);
|
||||
|
||||
ctx.drawImage(assetsIn[2], -width / 2, -height / 2, width, height);
|
||||
|
||||
let textArgs = [];
|
||||
|
||||
for (let ent of entities) {
|
||||
if (ent.health <= 0) continue;
|
||||
|
||||
|
@ -94,20 +104,28 @@ class Game extends GameBasic {
|
|||
|
||||
if (ent.type != 'Player') continue;
|
||||
|
||||
ctx.strokeStyle = "rgb(255,255,255)";
|
||||
ctx.lineWidth = "8";
|
||||
ctx.textAlign = "center";
|
||||
ctx.textBaseline = "bottom";
|
||||
ctx.font = "bold 16px sans-serif";
|
||||
textArgs = [`HP: ${ent.health} PT: ${ent.headCount}`, ent.pos.x, ent.pos.y - 64 / 2];
|
||||
|
||||
let args = [`HP: ${ent.health} PT: ${ent.headCount} XY: ${Math.round(ent.pos.x)}, ${Math.round(ent.pos.y)}`, ent.pos.x, ent.pos.y - 64 / 2];
|
||||
ctx.strokeText(...textArgs);
|
||||
ctx.fillText(...textArgs);
|
||||
|
||||
ctx.strokeText(...args);
|
||||
ctx.fillText(...args);
|
||||
ctx.textBaseline = "top";
|
||||
textArgs = [`${ent.username || 'Guest'}`, ent.pos.x, ent.pos.y + 64 / 2];
|
||||
|
||||
ctx.strokeText(...textArgs);
|
||||
ctx.fillText(...textArgs);
|
||||
}
|
||||
|
||||
ctx.restore();
|
||||
|
||||
ctx.textAlign = "start";
|
||||
ctx.textBaseline = "top";
|
||||
ctx.font = "bold 32px sans-serif";
|
||||
|
||||
textArgs = [`XY: ${-Math.round(player.camera.x)}, ${-Math.round(player.camera.y)}`,25,25];
|
||||
ctx.strokeText(...textArgs);
|
||||
ctx.fillText(...textArgs);
|
||||
|
||||
if (player.health <= 0 || player.isMenu) {
|
||||
this.doMenu();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue