Commit 97510b62 authored by Grant's avatar Grant
Browse files

forgot to connect the "new pixel placed" event 💀

parent 480f8a23
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -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 = {
+6 −0
Original line number Diff line number Diff line
@@ -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);