2MORPG - Your path to Multiplayer Online Role Playing Game development
Hi there! My name is Harry and I love game development! Especially Role-Playing Games, of course. They are quite easy to code and can be quite fun, especially if you know what you are doing ;)
MORPGs are a different breed, though; multiplayer programming can be quite difficult. Don't lose hope, though, because Harry is here to help! Go through my tutorials and I promise that you will learn how to create a simple, lag-free game that can be played over the Internet.
To write code, you will need to use an IDE. My recommendation is to use Visual Studio Community, which has all the features you will ever need.
Fighting multiplayer lag
Designing a MORPG that can handle hundreds, and sometimes even thousands of simultaneous players can be a very complex task. There are some aspects that can be controlled by us, the developers, such as building a fast server that's got a lot of RAM memory; still, other aspects are way beyond our control.
We can't make sure that all the clients/players utilize modern computers and have fast, lag-free Internet connections, for example. Sadly, network latency is often a frequent problem for most MORPGs. If you work as a one-man team, you can simulate Internet lag locally, by using your Wi-Fi connection. George Hardesty, CEO of Data Alliance, has come up with a clever trick.
He states that under ideal conditions, the average latency of a Wi-Fi connection is 3 to 4 milliseconds, but you can increase this value to 100... 200 ms by building a Wi-Fi network that utilizes a cheap router, which has a slower processor, and then adding as many devices (phones, tablets, baby monitors, IoT devices, etc.) to the Wi-Fi network as possible. Tools such as NetSpot can provide a lot of useful info about your laggy network, including latency and packet loss...
Okay, so we've learned quite a few things about RPG game development, the client/server architecture, chat systems and turn-based games so far. It's time for out first real-time multiplayer game demo, which will create a sphere model that can be moved around independently by each client. We are just setting up a basic, and yet solid foundation for a MORPG in this article, of course; feel free to check out this forum thread for a good list of additional advice and resources.
The code for our basic game is fully optimized, fat-free and lightning fast. Here's the source for the entire project.
Well, I'd say that the code doesn't look THAT scary. To keep it short and easy to understand, I had to simplify some things, though. The sphere entities are moved directly, by changing their x and y coordinates, for example, so they don't perform any collision detection...
This article will teach you how to create a two-player, turn-based multiplayer game. And if you think that these types of games aren't fun, you should definitely check out this extensive list of turn-based game hits. In our project, one of the computers will run as a server and client at the same time, while the second computer will only run as a client.
The code will be a bit more complex, because we are actually building a game this time. Don't worry, though; a huge chunk of the code includes function prototypes, various panel definitions, and so on – see for yourself.
In this game, players throw a dice, trying to reach the destination first. First, let's take a look at function main(). As you can see, this function doesn't do anything extraordinary; it is very well commented, so let's move on. The next image shows the server's and client's event functions...