cloud-game/web/js/global.js
Sadlil Rhythom 0e17092acb Refactor of cloud game overlord and overworker (#70)
* Introduce Makefile and go vendor directory for faster build

* WIP: Refactor cloud-game codebase with spliting overlord and worker binary

* Fix all issues and have a running build

* Complete first version of refactor
2019-09-12 03:35:21 +08:00

68 lines
1.2 KiB
JavaScript
Vendored

/*
Global Constants
*/
const DEBUG = false;
const KEY_BIT = ["a", "b", "x", "y", "select", "start", "up", "down", "left", "right"];
const INPUT_FPS = 100;
const INPUT_STATE_PACKET = 1;
const PINGPONGPS = 5;
const MENU_TOP_POSITION = 102;
const ICE_TIMEOUT = 2000;
/*
Global variables
*/
// Game state
let screenState = "loader";
let gameList = [];
let gameIdx = 9; // contra
let gamePickerTimer = null;
let roomID = null;
// Game controller state
let keyState = {
// control
a: false,
b: false,
x: false,
y: false,
start: false,
select: false,
// dpad
up: false,
down: false,
left: false,
right: false
}
let unchangePacket = INPUT_STATE_PACKET;
let gameInputTimer = null;
// Network state
let pc, inputChannel;
let localSessionDescription = "";
let remoteSessionDescription = "";
let conn;
// Touch menu state
let menuDrag = null;
let menuTop = MENU_TOP_POSITION;
// Screen state
let isLayoutSwitched = false;
var gameReady = false;
var inputReady = false;
var audioReady = false;
var iceSuccess = true;
var iceSent = false; // TODO: set to false in some init event
var defaultICE = [{urls: "stun:stun.l.google.com:19302"}]