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,5 +1,7 @@
import * as g from "./pong.js"
import * as g from "./global.js"
import * as d from "./draw.js";
import { socket } from "./ws.js";
import {InputEnum, EventInput} from "../shared_js/class/Event.js"
let gridDisplay = false;
@@ -26,10 +28,10 @@ function playerMove(delta: number, keys: string[])
{
g.player1.dir.y = 0;
if (keys.indexOf("w") != -1) {
g.player1.dir.y += -1;
socket.send(JSON.stringify(new EventInput(InputEnum.up)));
}
if (keys.indexOf("s") != -1) {
g.player1.dir.y += 1;
socket.send(JSON.stringify(new EventInput(InputEnum.down)));
}
g.player1.moveAndCollide(delta, [g.wall_top, g.wall_bottom]);