Starting to implement the networking

Yeah , i’m kinda lost with the networking. It seem like hard work to implement for the first time correctly. But i feel it’s very important right now because i want to structure my code in the future for this.

Interlude hot reloading server

I lost so time because things were not working because of me and because i hardcoded some value requiring multiple change when changing build target instead of one…. will i ever learn.

I found the perfect server for hot reloading. live-server Require npm , would have love to stay rust centric but i do so mutch npm on other project i’m already set up.

Also i copy paste some code the make the canvas big as the window in wasm. I prefer this way and i’ll need to integrate the fullscreen toggle from inside the code later on.

What are the message that need to be communicate

Server:

  • Send zombie game state
  • Send zombie spawn
  • Send zombie movement
  • Receive user input
    • Create entity for user input
    • Handle despawning of entity like zombie.

Client:

  • Receive zombie game state from server
  • Receive zombie spawn / despawn event
  • Receive zombie movement
  • Send user input
  • Spawn entity broadcasted by server
  1. The serveur when started, immediaty start a game in the waiting state, waiting for user connection.
  2. Receive player ready event.
  3. When all connected player have send ready event, start the game.

First step moving to shared

I move my code the shared for the game logic because the server and the client gonna use those structure to send and communicate the state of the game. I just copy everything for now and will progressively move thing that are not required for both in the good crate.

Starting the control flow

So to start thing up the first thing that happen is the server is started with a level configuration. And spawn the entity for the map (except collider for now)

  1. Zombie Spawn
  2. Windows