Added Working Playground

This commit is contained in:
2025-04-08 17:21:56 +02:00
parent a8220e6959
commit dcea0d24f5
7 changed files with 117 additions and 28 deletions

View File

@@ -1,4 +1,4 @@
import Loop from "./Game/Loop.js";
import Game from "./Game/Game.js";
class ServerConnectionManager {
constructor() {
@@ -7,31 +7,15 @@ class ServerConnectionManager {
this.body = document.getElementsByTagName("body")[0];
this.gameStarted = false;
this.loop = undefined;
this.game = new Game(this.socket);
// Socket.on Handler und Routen
this.socket.on("startGame", (data) => { this.startGame(data) });
this.socket.on("waitingForPlayers", (data) => { this.waitingForPlayers(data) });
this.socket.on("gameEnd", (msg) => { this.gameEnd(msg) });
this.basicSetup();
}
startGame(tileSize){
this.gameStarted = true;
this.body.innerHTML = "";
const tilesDiv = document.createElement("div")
this.body.appendChild(tilesDiv);
tilesDiv.id="tiles";
tilesDiv.classList.add("container")
this.loop = new Loop(this.socket, tilesDiv, tileSize);
}
waitingForPlayers(data){
document.getElementById("wM").innerText = data.msg;
document.getElementById("wS").innerText = data.waitingSeconds;