refactoring
+ wip input to server
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user