forgot to connect the "new pixel placed" event 💀

This commit is contained in:
Grant 2024-03-15 13:03:08 -06:00
parent 480f8a2375
commit 97510b62b8
2 changed files with 9 additions and 2 deletions

View File

@ -60,6 +60,7 @@ export class Canvas extends EventEmitter<CanvasEvents> {
Network.waitFor("pixelLastPlaced").then(
([time]) => (this.lastPlace = time)
);
Network.on("pixel", this.handlePixel);
this.draw();
}
@ -110,12 +111,12 @@ export class Canvas extends EventEmitter<CanvasEvents> {
});
}
handlePixel({ x, y, color }: Pixel) {
handlePixel = ({ x, y, color }: Pixel) => {
this.pixels[x + "_" + y] = {
color,
type: "full",
};
}
};
palleteCtx: IPalleteContext = {};
Pallete = {

View File

@ -4,6 +4,7 @@ import {
AuthSession,
ClientConfig,
ClientToServerEvents,
Pixel,
ServerToClientEvents,
} from "@sc07-canvas/lib/src/net";
@ -14,6 +15,7 @@ export interface INetworkEvents {
pixels: (data: { available: number }) => void;
pixelLastPlaced: (time: number) => void;
online: (count: number) => void;
pixel: (pixel: Pixel) => void;
}
type SentEventValue<K extends keyof INetworkEvents> = EventEmitter.ArgumentMap<
@ -60,6 +62,10 @@ class Network extends EventEmitter<INetworkEvents> {
this._emit("online", count);
});
this.socket.on("pixel", (pixel) => {
this.emit("pixel", pixel);
});
// this.socket.on("config", (config) => {
// Pallete.load(config.pallete);
// Canvas.load(config.canvas);