mirror of
https://github.com/giongto35/cloud-game.git
synced 2026-07-26 19:47:25 +00:00
parent
16578795e1
commit
1d0bcfdfc5
3 changed files with 17 additions and 2 deletions
2
static/js/controller.js
vendored
2
static/js/controller.js
vendored
|
|
@ -27,7 +27,7 @@ function showMenuScreen() {
|
|||
$("#btn-join").html("play");
|
||||
|
||||
// show menu scene
|
||||
$("#game-screen").show().delay(DEBUG ? 0 : 500).fadeOut(DEBUG ? 0 : 0, function () {
|
||||
$("#game-screen").show().delay(DEBUG ? 0 : 0).fadeOut(DEBUG ? 0 : 0, function () {
|
||||
log("Loading menu screen");
|
||||
$("#menu-screen").fadeIn(DEBUG ? 0 : 0, function () {
|
||||
pickGame(gameIdx);
|
||||
|
|
|
|||
2
static/js/global.js
vendored
2
static/js/global.js
vendored
|
|
@ -57,3 +57,5 @@ let menuTop = MENU_TOP_POSITION;
|
|||
// Screen state
|
||||
let isLayoutSwitched = false;
|
||||
|
||||
var gameReady = false;
|
||||
var iceSuccess = true;
|
||||
|
|
|
|||
15
static/js/ws.js
vendored
15
static/js/ws.js
vendored
|
|
@ -171,8 +171,14 @@ function startWebRTC() {
|
|||
log(`iceConnectionState: ${pc.iceConnectionState}`);
|
||||
|
||||
if (pc.iceConnectionState === "connected") {
|
||||
gameReady = true
|
||||
iceSuccess = true
|
||||
//conn.send(JSON.stringify({"id": "start", "data": ""}));
|
||||
}
|
||||
else if (pc.iceConnectionState === "failed") {
|
||||
gameReady = false
|
||||
iceSuccess = false
|
||||
}
|
||||
else if (pc.iceConnectionState === "disconnected") {
|
||||
stopInputTimer();
|
||||
}
|
||||
|
|
@ -182,7 +188,7 @@ function startWebRTC() {
|
|||
// video channel
|
||||
pc.ontrack = function (event) {
|
||||
document.getElementById("game-screen").srcObject = event.streams[0];
|
||||
$("#game-screen").show();
|
||||
//$("#game-screen").show();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -212,6 +218,13 @@ function startWebRTC() {
|
|||
}
|
||||
|
||||
function startGame() {
|
||||
if (!iceSuccess) {
|
||||
popup("Game cannot load. Please refresh")
|
||||
}
|
||||
// TODO: Add while loop
|
||||
if (!gameReady) {
|
||||
popup("Game is not ready yet. Please wait")
|
||||
}
|
||||
log("Starting game screen");
|
||||
screenState = "game";
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue