Now scenes can be switched between game and mainmenu

This commit is contained in:
Alexander Bass 2022-06-19 20:38:09 -04:00
parent e755f4bed3
commit c406819dce
7 changed files with 28 additions and 13 deletions

View file

@ -1,12 +1,13 @@
import {statusElement} from "/scripts/interface/game/html.js"
export function updateConnectionStatus(connection) {
let obj = document.getElementById("status")
obj.textContent = `Server Connection: ${connection}`
statusElement.textContent = `Server Connection: ${connection}`
switch (connection) {
case "connected":
obj.style.color = "green";
statusElement.style.color = "green";
break;
case "disconnected":
obj.style.color = "red";
statusElement.style.color = "red";
break;
}

View file

@ -0,0 +1,2 @@
export let statusElement = document.getElementById("status")
export let buttonBar = document.getElementById("buttonBar")

View file

@ -1,5 +1,5 @@
import {tileArray} from "/scripts/display/tileRenderer.js"
import {buttonBar} from "/scripts/interface/game/html.js"
var button = 0;
function clickSelector(e) {
@ -33,7 +33,7 @@ for(let i=0;i < 5;i++) {
n = 5
};
span.appendChild(tileArray[n]);
document.getElementById("buttonBar").appendChild(span);
buttonBar.appendChild(span);
span.no = i;
span.addEventListener('click', e => {
clickSelector(e);
@ -44,3 +44,9 @@ for(let i=0;i < 5;i++) {
export function getButton() {
return button;
}
export function destroy() {
while (buttonBar.lastChild) {
buttonBar.removeChild(buttonBar.lastChild)
}
}

View file

@ -12,5 +12,5 @@ function submit(event) {
if (room == '' || name == '' || status.get() == 'disconnected') return
joinGame({room: room, name: name})
event.preventDefault();
changeScene()
changeScene("game")
}

View file

@ -1,8 +1,14 @@
import * as picker from "/scripts/interface/game/picker.js"
import { create } from "/scripts/interface/game/picker.js"
export function changeScene() {
document.getElementById('menu').style = "display: none;"
document.getElementById('container').style = ""
create();
export function changeScene(scene) {
if (scene == "game") {
document.getElementById('menu').style = "display: none;"
document.getElementById('container').style = ""
picker.create();
}
if (scene == "mainmenu") {
document.getElementById('menu').style = ""
document.getElementById('container').style = "display: none;"
picker.destroy();
}
};