Advertisement

Design considerations for a 2D multiplayer game.

Started by June 19, 2016 05:38 PM
1 comment, last by MeltingIcecream 8 years, 5 months ago

I'm about to start writing a 2d sidescrolling game. Are there any design considerations I should take when creating the game to support networked-multiplayer? For example, If I have a TileMap type, which "glues" together the physics and everything else, I would need an MPTileMap type which wouldn't run physics, just use data from the host. But then I'm implementing a tilemap twice. There's gotta be a better way, right?

Note: I doubt this matters for this question, but I'm going to be writing this game in c# with MonoGame.

If you use object oriented design (which it sounds like you do) then your current TileMap sounds like it doesn't follow the "single responsibility principle."
A more factored design would be to have a TileMap that maps 2D coordinates to environment info (to use for rendering and simulation.)
Separately, you have a Renderer that uses the TileMap to figure out what to render, and you have a Simulator that uses the TileMap as a source of what the physics environment is.
You'd probably have a separate World which contains the Actors (players, projectiles, monsters, etc.) The Renderer and Simulator would know how to talk to both the World and the TileMap.

So, on your client, you would have a Renderer, a World, and a TileMap. The World is populated/driven by the incoming network packets.
On your server, you would have a Simulator, a World, and a TileMap. The World is populated by scripts and logged-in players, and updated through Simulation.
enum Bool { True, False, FileNotFound };
Advertisement

OK, that makes sense. Thanks!

This topic is closed to new replies.

Advertisement