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