Now scenes can be switched between game and mainmenu
This commit is contained in:
parent
e755f4bed3
commit
c406819dce
|
@ -1,12 +1,13 @@
|
||||||
|
import {statusElement} from "/scripts/interface/game/html.js"
|
||||||
|
|
||||||
export function updateConnectionStatus(connection) {
|
export function updateConnectionStatus(connection) {
|
||||||
let obj = document.getElementById("status")
|
statusElement.textContent = `Server Connection: ${connection}`
|
||||||
obj.textContent = `Server Connection: ${connection}`
|
|
||||||
switch (connection) {
|
switch (connection) {
|
||||||
case "connected":
|
case "connected":
|
||||||
obj.style.color = "green";
|
statusElement.style.color = "green";
|
||||||
break;
|
break;
|
||||||
case "disconnected":
|
case "disconnected":
|
||||||
obj.style.color = "red";
|
statusElement.style.color = "red";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
2
www/scripts/interface/game/html.js
Normal file
2
www/scripts/interface/game/html.js
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
export let statusElement = document.getElementById("status")
|
||||||
|
export let buttonBar = document.getElementById("buttonBar")
|
|
@ -1,5 +1,5 @@
|
||||||
import {tileArray} from "/scripts/display/tileRenderer.js"
|
import {tileArray} from "/scripts/display/tileRenderer.js"
|
||||||
|
import {buttonBar} from "/scripts/interface/game/html.js"
|
||||||
var button = 0;
|
var button = 0;
|
||||||
|
|
||||||
function clickSelector(e) {
|
function clickSelector(e) {
|
||||||
|
@ -33,7 +33,7 @@ for(let i=0;i < 5;i++) {
|
||||||
n = 5
|
n = 5
|
||||||
};
|
};
|
||||||
span.appendChild(tileArray[n]);
|
span.appendChild(tileArray[n]);
|
||||||
document.getElementById("buttonBar").appendChild(span);
|
buttonBar.appendChild(span);
|
||||||
span.no = i;
|
span.no = i;
|
||||||
span.addEventListener('click', e => {
|
span.addEventListener('click', e => {
|
||||||
clickSelector(e);
|
clickSelector(e);
|
||||||
|
@ -44,3 +44,9 @@ for(let i=0;i < 5;i++) {
|
||||||
export function getButton() {
|
export function getButton() {
|
||||||
return button;
|
return button;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function destroy() {
|
||||||
|
while (buttonBar.lastChild) {
|
||||||
|
buttonBar.removeChild(buttonBar.lastChild)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -12,5 +12,5 @@ function submit(event) {
|
||||||
if (room == '' || name == '' || status.get() == 'disconnected') return
|
if (room == '' || name == '' || status.get() == 'disconnected') return
|
||||||
joinGame({room: room, name: name})
|
joinGame({room: room, name: name})
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
changeScene()
|
changeScene("game")
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,14 @@
|
||||||
|
import * as picker from "/scripts/interface/game/picker.js"
|
||||||
|
|
||||||
import { create } from "/scripts/interface/game/picker.js"
|
export function changeScene(scene) {
|
||||||
|
if (scene == "game") {
|
||||||
export function changeScene() {
|
document.getElementById('menu').style = "display: none;"
|
||||||
document.getElementById('menu').style = "display: none;"
|
document.getElementById('container').style = ""
|
||||||
document.getElementById('container').style = ""
|
picker.create();
|
||||||
create();
|
}
|
||||||
|
if (scene == "mainmenu") {
|
||||||
|
document.getElementById('menu').style = ""
|
||||||
|
document.getElementById('container').style = "display: none;"
|
||||||
|
picker.destroy();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue