Skip to content

Commit

Permalink
Display room password on the game
Browse files Browse the repository at this point in the history
  • Loading branch information
ethinot committed Apr 20, 2023
1 parent 80b8aa1 commit 4710bf9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion client/src/components/Game.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const Game: FC<GameProps> = ({ setGameStarted }): JSX.Element => {

<canvas id="miniMap" className="miniMap"></canvas>

<p className="gamePassword">#ID696969</p>
<p id="gamePassword" className="gamePassword"></p>

<img id="soundBtn" src="./ress/mute.png" alt="" />
</>
Expand Down
9 changes: 9 additions & 0 deletions client/src/phaser/scenes/GameScene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import io from "socket.io-client";
import { getAuth } from "firebase/auth";
import app from "../../Firebase";
import { Buffer } from "buffer";
import { get } from "http";

const Socketorigin =
window.location.origin.split(":")[0] +
Expand Down Expand Up @@ -65,6 +66,7 @@ export default class GameScene extends Phaser.Scene {

this.cameras.main.setZoom(0.2);
this.initVolumeControl();
this.initGamePassword();
}

// Met a jour la position des joueurs
Expand Down Expand Up @@ -230,4 +232,11 @@ export default class GameScene extends Phaser.Scene {
else this.player?.setIsAudioMuted(soundState);
return isMuted;
}

initGamePassword() {
const gameID = localStorage.getItem("gameId") || "default";
const gamePassword = document.getElementById("gamePassword");
if (!gamePassword) return;
gamePassword.textContent = "Password : " + gameID;
}
}

0 comments on commit 4710bf9

Please sign in to comment.