some fixes
This commit is contained in:
parent
f8b014507f
commit
656f06291c
3 changed files with 31 additions and 19 deletions
|
@ -13,7 +13,7 @@ const legalTypes = {
|
|||
Player,
|
||||
NPC
|
||||
}
|
||||
const options = [
|
||||
const emojis = [
|
||||
'Troll',
|
||||
'Exit',
|
||||
'Elec Piano Loop',
|
||||
|
@ -98,19 +98,24 @@ class Game extends GameBasic {
|
|||
ctx.restore();
|
||||
|
||||
if (player.health <= 0 || player.isMenu) {
|
||||
ctx.fillStyle = 'rgba(0,0,0,0.5)';
|
||||
ctx.fillRect(0, 0, cs, cs);
|
||||
ctx.fillStyle = 'rgb(255,255,255)';
|
||||
ctx.textAlign = "center";
|
||||
ctx.textBaseline = "middle";
|
||||
ctx.font = "bold 48px sans-serif";
|
||||
if (player.health <= 0) ctx.fillText('You died! Click to respawn', cs / 2, cs / 2);
|
||||
if (player.isMenu) {
|
||||
let r = Math.floor(Math.abs(player.rot / 1.2) % options.length);
|
||||
ctx.fillText(`Click to react ${options[r]}`, cs / 2, cs / 2)
|
||||
ctx.font = "bold 16px sans-serif";
|
||||
ctx.fillText(`Wait for options ${options.join(', ')}`, cs / 2, cs / 2 + 50)
|
||||
}
|
||||
this.doMenu();
|
||||
}
|
||||
}
|
||||
doMenu() {
|
||||
let { ctx, player } = this;
|
||||
|
||||
ctx.fillStyle = 'rgba(0,0,0,0.5)';
|
||||
ctx.fillRect(0, 0, cs, cs);
|
||||
ctx.fillStyle = 'rgb(255,255,255)';
|
||||
ctx.textAlign = "center";
|
||||
ctx.textBaseline = "middle";
|
||||
ctx.font = "bold 48px sans-serif";
|
||||
if (player.health <= 0) ctx.fillText('You died! Click to respawn', cs / 2, cs / 2);
|
||||
if (player.isMenu) {
|
||||
let r = Math.floor(Math.abs(player.rot / 1.2) % emojis.length);
|
||||
ctx.fillText(`Click to react ${emojis[r]}`, cs / 2, cs / 2)
|
||||
ctx.font = "bold 16px sans-serif";
|
||||
ctx.fillText(`Wait for emojis ${emojis.join(', ')}`, cs / 2, cs / 2 + 50)
|
||||
}
|
||||
}
|
||||
click() {
|
||||
|
@ -121,7 +126,7 @@ class Game extends GameBasic {
|
|||
this.player = new Player(false, true);
|
||||
this.entities.push(this.player);
|
||||
} else if (player.isMenu) {
|
||||
player.r = Math.floor(Math.abs(player.rot / 1.2) % options.length);
|
||||
player.r = Math.floor(Math.abs(player.rot / 1.2) % emojis.length);
|
||||
player.isMenu = false;
|
||||
this.sync();
|
||||
} else {
|
||||
|
@ -147,7 +152,7 @@ class Game extends GameBasic {
|
|||
let type = (Object.keys(legalTypes).indexOf(x.type) == -1) ? Player : legalTypes[x.type];
|
||||
x.handleTick = type.prototype.handleTick;
|
||||
if (x.r != 1) {
|
||||
let a = new Audio(`assets/${options[x.r]}.wav`);
|
||||
let a = new Audio(`assets/${emojis[x.r]}.wav`);
|
||||
a.addEventListener('ended', () => {
|
||||
if (x.you == you) {
|
||||
that.player.playing = false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue