refactoring

+ wip input to server
This commit is contained in:
LuckyLaszlo
2022-11-17 11:12:32 +01:00
parent a873b23d0f
commit 6fb1470dbb
19 changed files with 197 additions and 131 deletions

View File

@@ -1,29 +1,12 @@
import * as g from "./pong.js"
import * as g from "./global.js" // temp
import {startGame} from "./pong.js";
import {EventTypes, EventData, EventGameUpdate} from "../shared_js/class/Event.js"
const wsPort = 8042;
const wsUrl = "ws://" + document.location.hostname + ":" + wsPort + "/pong";
const socket = new WebSocket(wsUrl, "json");
enum EventTypes {
gameUpdate = 1,
start,
pause,
resume
}
interface EventData {
type: EventTypes;
}
class EventGameUpdate implements EventData {
type: EventTypes = EventTypes.gameUpdate;
player1 = {y: 0};
player2 = {y: 0};
ball = {x: 0, y: 0, speed: 0};
}
socket.addEventListener("message", logListener);
socket.addEventListener("message", matchmakingListener);