forgot to connect the "new pixel placed" event 💀
This commit is contained in:
parent
480f8a2375
commit
97510b62b8
|
@ -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 = {
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue