Skip to content

Commit

Permalink
Merge branch 'feature/051-remote-play' of https://github.com/abbastoo…
Browse files Browse the repository at this point in the history
…f/transcendence into feature/075-jwt-auth-websocket
  • Loading branch information
Otto Andelin committed Aug 24, 2024
2 parents e150794 + c51c5f4 commit 58febf1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 27 deletions.
4 changes: 3 additions & 1 deletion Frontend/src/js/pong/classes/GameSession.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ class GameSession {
this.scoreBoard = new ScoreBoard(scene);
if (isRemote === true)
this.scoreBoard.showWaitText();
else
this.scoreBoard.showLoadingText();
this.playingField.addToScene();
this.ball.addToScene();

// Always connect to the server
if (!this.socket.connected) {
Expand Down Expand Up @@ -97,6 +98,7 @@ class GameSession {
this.inProgress = true;
this.leftPaddle.addToScene();
this.rightPaddle.addToScene();
this.ball.addToScene();
setTimeout(() => {
this.paused = false
const player1Text = `${this.player1Alias} ${this.player1Score}`;
Expand Down
45 changes: 19 additions & 26 deletions Frontend/src/js/pong/classes/ScoreBoard.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,41 +91,40 @@ class ScoreBoard {
this.createScoreBoard(player1Text, player2Text);
}

showGoalText() {
this.clearScores();
this.goalMesh = this.createText('GOAL !!!', 100, 0x00FF00, 0.3, 15.0); // green for GOAL text
this.goalMesh.position.set(0, 90.0, 300.0);
placeTextMesh(mesh) {
mesh.position.set(0, 90.0, 300.0);
if (globalState.invertedView === true) {
this.goalMesh.rotation.y = THREE.MathUtils.degToRad(180);
mesh.rotation.y = THREE.MathUtils.degToRad(180);
} else {
this.goalMesh.position.z = -300.0;
mesh.position.z = -300.0;
}
}
showGoalText() {
this.clearScores();
this.goalMesh = this.createText('GOAL !!!', 100, 0x00FF00, 0.3, 15.0); // green for GOAL text
this.placeTextMesh(this.goalMesh);
this.scene.add(this.goalMesh);
}

showGameStartText() {
this.clearScores();
this.messageMesh = this.createText('GAME START', 80, 0x00FF00, 0.3, 15.0)
this.messageMesh.position.set(0, 90.0, 300.0);
if (globalState.invertedView === true) {
this.messageMesh.rotation.y = THREE.MathUtils.degToRad(180);
}
else {
this.messageMesh.position.z = -300.0
}
this.placeTextMesh(this.messageMesh);
this.scene.add(this.messageMesh);
}

showWaitText() {
this.clearScores();
this.messageMesh = this.createText('Waiting for your opponent..', 50, 0x4455FF, 1.4, 4.0);
this.messageMesh.position.set(0, 90.0, 300.0);
if (globalState.invertedView === true) {
this.messageMesh.rotation.y = THREE.MathUtils.degToRad(180);
}
else {
this.messageMesh.position.z = -300.0
}
this.placeTextMesh(this.messageMesh);
this.scene.add(this.messageMesh);
}

showLoadingText() {
this.clearScores();
this.messageMesh = this.createText('Loading..', 80, 0xAAFF00, 1.4, 4.0);
this.placeTextMesh(this.messageMesh);
this.scene.add(this.messageMesh);
}

Expand All @@ -137,13 +136,7 @@ class ScoreBoard {
else {
this.messageMesh = this.createText('Your opponent has quit the game', 50, 0x2222FF, 1.4, 4.0);
}
this.messageMesh.position.set(0, 90.0, 300.0);
if (globalState.invertedView === true) {
this.messageMesh.rotation.y = THREE.MathUtils.degToRad(180);
}
else {
this.messageMesh.position.z = -300.0
}
this.placeTextMesh(this.messageMesh);
this.scene.add(this.messageMesh);
}

Expand Down

0 comments on commit 58febf1

Please sign in to comment.