This commit is contained in:
giongto35 2019-04-08 18:25:26 +08:00
parent f9b4d7d1dc
commit aeeb4133da
6 changed files with 15 additions and 10 deletions

View file

@ -31,8 +31,8 @@ const wsIndex = "./static/index_ws.html"
// var webRTC *webrtc.WebRTC
var width = 256
var height = 240
var indexFN string = wsIndex
var service string = "http"
var indexFN string = gameboyIndex
var service string = "ws"
type IndexPageData struct {
Service string

View file

@ -6919,4 +6919,4 @@ body {
a {
color: lightblue;
}
}

View file

@ -3,9 +3,8 @@
<link type="text/css" rel="stylesheet" href="/static/css/gameboy.css">
</head>
<body>
<body scroll="no" style="overflow: hidden">
<div id="gameboy" class="green">
<div id="canvas"></div>
<div id="border"></div>
@ -88,8 +87,14 @@
C is start (in game) <br />
V is select game <br />
Q is super quit <br />
S to save <br />
L to load <br />
Room ID: <input type="text" id="roomID"><br>
Room ID: <input type="text" id="roomID"><br />
Play as player(1,2): <select id="playerIndex">
<option value="1">1</option>
<option value="2">2</option>
</select>
<!--Fullscreen media for better gaming experience<br /-->
</div><br>

View file

View file

@ -22,7 +22,7 @@ textarea {
<option value="zelda.rom">zelda.rom</option>
</select>
<button id="play" onclick="window.startGame()">Play</button>
Room ID: <input type="text" id="roomID"><br>
Room ID: <input type="text" id="roomID">
Play as player(1,2): <select id="playerIndex">
<option value="1">1</option>
<option value="2">2</option>

View file

@ -2,7 +2,7 @@
function startGame() {
log("Starting game screen");
// clear
endInput();
document.getElementById('div').innerHTML = "";
@ -15,7 +15,7 @@ function startGame() {
conn.onopen = () => {
log("WebSocket is opened. Send ping");
roomID = document.getElementById('roomID').value
conn.send(JSON.stringify({"id": "ping", "data": GAME_LIST[gameIdx].nes, "room_id": roomID}));
conn.send(JSON.stringify({"id": "ping", "data": GAME_LIST[gameIdx].nes, "room_id": roomID, "player_index": parseInt(playerIndex.value, 10)}));
}
conn.onerror = error => {